mapFields.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) 2016-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::functionObjects::mapFields
28
29Group
30 grpFieldFunctionObjects
31
32Description
33 Maps input fields from local mesh to secondary mesh at runtime.
34
35 Operands:
36 \table
37 Operand | Type | Location
38 input | {vol,surface}<Type>Field <!--
39 --> | $FOAM_CASE/<time>/<inpField>
40 output file | - | -
41 output field | {vol,surface}<Type>Field <!--
42 --> | $FOAM_CASE/<time>/<outField>
43 \endtable
44
45 where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
46
47Usage
48 Minimal example by using \c system/controlDict.functions:
49 \verbatim
50 mapFields1
51 {
52 // Mandatory entries (unmodifiable)
53 type mapFields;
54 libs (fieldFunctionObjects);
55
56 // Mandatory (inherited) entries (runtime modifiable)
57 fields (<field1> <field2> ... <fieldN>);
58 mapRegion coarseMesh;
59 mapMethod cellVolumeWeight;
60 consistent true;
61
62 // Optional entries (runtime modifiable)
63 // patchMapMethod direct; // AMI-related entry
64 // enabled if consistent=false
65 // patchMap (<patchSrc> <patchTgt>);
66 // cuttingPatches (<patchTgt1> <patchTgt2> ... <patchTgtN>);
67
68 // Optional (inherited) entries
69 ...
70 }
71 \endverbatim
72
73 where the entries mean:
74 \table
75 Property | Description | Type | Req'd | Dflt
76 type | Type name: mapFields | word | yes | -
77 libs | Library name: fieldFunctionObjects | word | yes | -
78 fields | Names of operand fields | wordList | yes | -
79 mapRegion | Name of region to map to | word | yes | -
80 mapMethod | Mapping method | word | yes | -
81 consistent | Mapping meshes have consistent boundaries | bool | yes | -
82 patchMapMethod | Patch mapping method for AMI cases | word | no | -
83 patchMap | Coincident source/target patches in two cases <!--
84 --> | wordHashTable | no | -
85 cuttingPatches | Target patches cutting the source domain <!--
86 --> | wordList | no | -
87 \endtable
88
89 Options for the \c mapMethod entry:
90 \verbatim
91 direct
92 mapNearest
93 cellVolumeWeight
94 correctedCellVolumeWeight
95 \endverbatim
96
97 Options for the \c patchMapMethod entry:
98 \verbatim
99 nearestFaceAMI
100 faceAreaWeightAMI
101 \endverbatim
102
103 The inherited entries are elaborated in:
104 - \link functionObject.H \endlink
105
106 Usage by the \c postProcess utility is not available.
107
108See also
109 - Foam::functionObject
110 - Foam::functionObjects::fvMeshFunctionObject
111 - ExtendedCodeGuide::functionObjects::field::mapFields
112
113SourceFiles
114 mapFields.C
115 mapFieldsTemplates.C
116
117\*---------------------------------------------------------------------------*/
118
119#ifndef functionObjects_mapFields_H
120#define functionObjects_mapFields_H
121
122#include "fvMeshFunctionObject.H"
123#include "volFieldsFwd.H"
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126
127namespace Foam
128{
129
130class meshToMesh;
131
132namespace functionObjects
133{
134
135/*---------------------------------------------------------------------------*\
136 Class mapFields Declaration
137\*---------------------------------------------------------------------------*/
138
139class mapFields
140:
141 public fvMeshFunctionObject
142{
143 // Private Data
144
145 //- Locally cached map region mesh (map to this mesh)
146 autoPtr<fvMesh> mapRegionPtr_;
147
148 //- Mesh-to-mesh interpolation
149 autoPtr<meshToMesh> interpPtr_;
150
151 //- List of field names to interpolate
152 wordRes fieldNames_;
153
154
155 // Private Member Functions
156
157 //- Helper function to create the mesh-to-mesh interpolation
158 void createInterpolation(const dictionary& dict);
159
160 //- Helper function to evaluate constraint patches after mapping
161 template<class Type>
162 void evaluateConstraintTypes
163 (
164 GeometricField<Type, fvPatchField, volMesh>& fld
165 ) const;
166
167 //- Helper function to map the <Type> fields
168 template<class Type>
169 bool mapFieldType() const;
170
171 //- Helper function to write the <Type> fields
172 template<class Type>
173 bool writeFieldType() const;
174
175
176public:
177
178 //- Runtime type information
179 TypeName("mapFields");
180
181
182 // Constructors
183
184 //- Construct from Time and dictionary
186 (
187 const word& name,
188 const Time& runTime,
189 const dictionary& dict
190 );
191
192 //- No copy construct
193 mapFields(const mapFields&) = delete;
194
195 //- No copy assignment
196 void operator=(const mapFields&) = delete;
197
198
199 //- Destructor
200 virtual ~mapFields() = default;
201
202
203 // Member Functions
204
205 //- Read the mapFields data
206 virtual bool read(const dictionary&);
207
208 //- Execute, currently does nothing
209 virtual bool execute();
210
211 //- Calculate the mapFields and write
212 virtual bool write();
213};
214
215
216// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217
218} // End namespace functionObjects
219} // End namespace Foam
220
221// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223#ifdef NoRepository
224 #include "mapFieldsTemplates.C"
225#endif
226
227// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228
229#endif
230
231// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Maps input fields from local mesh to secondary mesh at runtime.
Definition: mapFields.H:225
mapFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: mapFields.C:139
mapFields(const mapFields &)=delete
No copy construct.
void operator=(const mapFields &)=delete
No copy assignment.
virtual bool execute()
Execute, currently does nothing.
Definition: mapFields.C:170
virtual bool write()
Calculate the mapFields and write.
Definition: mapFields.C:195
virtual ~mapFields()=default
Destructor.
TypeName("mapFields")
Runtime type information.
virtual bool read(const dictionary &)
Read the mapFields data.
Definition: mapFields.C:156
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73