Loading...
Searching...
No Matches
FieldMapper.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2015-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::FieldMapper
29
30Description
31 Abstract base class to hold the Field mapping addressing and weights.
32
33\*---------------------------------------------------------------------------*/
34
35#ifndef Foam_FieldMapper_H
36#define Foam_FieldMapper_H
37
38#include "mapDistributeBase.H"
39#include "nullObject.H"
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43namespace Foam
44{
45
46/*---------------------------------------------------------------------------*\
47 Class FieldMapper Declaration
48\*---------------------------------------------------------------------------*/
49
50class FieldMapper
51{
52public:
53
54 // Constructors
55
56 //- Default construct
57 FieldMapper() = default;
59
60 //- Destructor
61 virtual ~FieldMapper() = default;
62
63
64 // Member Functions
65
66 //- The size of the mapper
67 virtual label size() const = 0;
68
69 //- Is it a direct (non-interpolating) mapper?
70 virtual bool direct() const = 0;
72 //- Does the mapper have remote contributions?
73 virtual bool distributed() const
74 {
75 return false;
76 }
77
78 //- Any unmapped values?
79 // I.e. do all size() elements get value
80 virtual bool hasUnmapped() const = 0;
81
82 //- Return the direct addressing values
83 virtual const labelUList& directAddressing() const
84 {
86 << "attempt to access null direct addressing"
87 << abort(FatalError);
88
89 return labelUList::null();
90 }
92 //- Return the distribution map
93 virtual const mapDistributeBase& distributeMap() const
94 {
96 << "attempt to access null distributeMap"
97 << abort(FatalError);
98
100 }
101
102 //- Return the interpolation addressing
103 virtual const labelListList& addressing() const
104 {
106 << "attempt to access null interpolation addressing"
107 << abort(FatalError);
108
109 return labelListList::null();
110 }
111
112 //- Return the interpolation weights
113 virtual const scalarListList& weights() const
114 {
116 << "attempt to access null interpolation weights"
117 << abort(FatalError);
118
119 return scalarListList::null();
120 }
121
122
123 // Member Operators
124
125 //- Perform mapping on the given field
126 template<class Type>
128 {
129 return tmp<Field<Type>>::New(fld, *this);
130 }
131};
132
133
134// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135
136} // End namespace Foam
137
138// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139
140#endif
141
142// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
FieldMapper()=default
Default construct.
virtual const labelUList & directAddressing() const
Return the direct addressing values.
Definition FieldMapper.H:91
virtual ~FieldMapper()=default
Destructor.
virtual const scalarListList & weights() const
Return the interpolation weights.
virtual label size() const =0
The size of the mapper.
virtual bool distributed() const
Does the mapper have remote contributions?
Definition FieldMapper.H:76
virtual const labelListList & addressing() const
Return the interpolation addressing.
virtual bool hasUnmapped() const =0
Any unmapped values?
tmp< Field< Type > > operator()(const Field< Type > &fld) const
Perform mapping on the given field.
virtual const mapDistributeBase & distributeMap() const
Return the distribution map.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
static const List< labelList > & null() noexcept
Definition List.H:138
static const UList< label > & null() noexcept
Definition UList.H:225
Class containing processor-to-processor mapping information.
A class for managing temporary objects.
Definition tmp.H:75
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
const T & NullObjectRef() noexcept
Const reference (of type T) to the nullObject.
Definition nullObject.H:228
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
UList< label > labelUList
A UList of labels.
Definition UList.H:75