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-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
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 
26 Class
27  Foam::functionObjects::mapFields
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
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 
47 Usage
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 
65  // When consistent=false
66 
67  // Manual: createPatchMap false;
68  // patchMap (<patchSrc> <patchTgt>);
69  // cuttingPatches (<patchTgt1> <patchTgt2> ... <patchTgtN>);
70 
71  // Automatic: createPatchMap true;
72  // Creates the patchMap and cuttingPatches automatically
73 
74  // Optional (inherited) entries
75  ...
76  }
77  \endverbatim
78 
79  where the entries mean:
80  \table
81  Property | Description | Type | Req'd | Dflt
82  type | Type name: mapFields | word | yes | -
83  libs | Library name: fieldFunctionObjects | word | yes | -
84  fields | Names of operand fields | wordList | yes | -
85  mapRegion | Name of region to map to | word | yes | -
86  mapMethod | Mapping method | word | yes | -
87  consistent | Mapping meshes have consistent boundaries | bool | yes | -
88  patchMapMethod | Patch mapping method for AMI cases | word | no | -
89  createPatchMap | Automatically create patchMap and cuttingPatches| <!--
90  --> | bool | no | -
91  patchMap | Mapping between coincident source and target patches <!--
92  --> | wordHashTable | no | -
93  cuttingPatches | Target patches cutting the source domain <!--
94  --> | wordList | no | -
95  \endtable
96 
97  Options for the \c mapMethod entry:
98  \verbatim
99  direct
100  mapNearest
101  cellVolumeWeight
102  correctedCellVolumeWeight
103  \endverbatim
104 
105  Options for the \c patchMapMethod entry:
106  \verbatim
107  nearestFaceAMI
108  faceAreaWeightAMI
109  \endverbatim
110 
111  The inherited entries are elaborated in:
112  - \link functionObject.H \endlink
113 
114  Usage by the \c postProcess utility is not available.
115 
116 See also
117  - Foam::functionObject
118  - Foam::functionObjects::fvMeshFunctionObject
119  - ExtendedCodeGuide::functionObjects::field::mapFields
120 
121 SourceFiles
122  mapFields.C
123  mapFieldsTemplates.C
124 
125 \*---------------------------------------------------------------------------*/
126 
127 #ifndef functionObjects_mapFields_H
128 #define functionObjects_mapFields_H
129 
130 #include "fvMeshFunctionObject.H"
131 #include "volFieldsFwd.H"
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 namespace Foam
136 {
137 
138 class meshToMesh;
139 
140 namespace functionObjects
141 {
142 
143 /*---------------------------------------------------------------------------*\
144  Class mapFields Declaration
145 \*---------------------------------------------------------------------------*/
146 
147 class mapFields
148 :
149  public fvMeshFunctionObject
150 {
151  // Private Data
152 
153  //- Locally cached map region mesh (map to this mesh)
154  autoPtr<fvMesh> mapRegionPtr_;
155 
156  //- Mesh-to-mesh interpolation
157  autoPtr<meshToMesh> interpPtr_;
158 
159  //- List of field names to interpolate
160  wordRes fieldNames_;
161 
162 
163  // Private Member Functions
164 
165  //- Helper function to create the mesh-to-mesh interpolation
166  void createInterpolation(const dictionary& dict);
167 
168  //- Helper function to evaluate constraint patches after mapping
169  template<class Type>
170  void evaluateConstraintTypes
171  (
172  GeometricField<Type, fvPatchField, volMesh>& fld
173  ) const;
174 
175  //- Helper function to map the <Type> fields
176  template<class Type>
177  bool mapFieldType() const;
178 
179  //- Helper function to write the <Type> fields
180  template<class Type>
181  bool writeFieldType() const;
182 
183 
184 public:
185 
186  //- Runtime type information
187  TypeName("mapFields");
188 
189 
190  // Constructors
191 
192  //- Construct from Time and dictionary
193  mapFields
194  (
195  const word& name,
196  const Time& runTime,
197  const dictionary& dict
198  );
199 
200  //- No copy construct
201  mapFields(const mapFields&) = delete;
202 
203  //- No copy assignment
204  void operator=(const mapFields&) = delete;
205 
206 
207  //- Destructor
208  virtual ~mapFields() = default;
209 
210 
211  // Member Functions
212 
213  //- Read the mapFields data
214  virtual bool read(const dictionary&);
215 
216  //- Execute, currently does nothing
217  virtual bool execute();
218 
219  //- Calculate the mapFields and write
220  virtual bool write();
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace functionObjects
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #ifdef NoRepository
232  #include "mapFieldsTemplates.C"
233 #endif
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
dictionary dict
Forwards and collection of common volume field types.
engineTime & runTime
mapFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: mapFields.C:248
const word & name() const noexcept
Return the name of this functionObject.
virtual bool read(const dictionary &)
Read the mapFields data.
Definition: mapFields.C:265
void operator=(const mapFields &)=delete
No copy assignment.
virtual bool write()
Calculate the mapFields and write.
Definition: mapFields.C:304
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual ~mapFields()=default
Destructor.
virtual bool execute()
Execute, currently does nothing.
Definition: mapFields.C:279
TypeName("mapFields")
Runtime type information.
Namespace for OpenFOAM.