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 -------------------------------------------------------------------------------
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  // 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  directAMI
100  mapNearestAMI
101  faceAreaWeightAMI
102  partialFaceAreaWeightAMI
103  \endverbatim
104 
105  The inherited entries are elaborated in:
106  - \link functionObject.H \endlink
107 
108  Usage by the \c postProcess utility is not available.
109 
110 See also
111  - Foam::functionObject
112  - Foam::functionObjects::fvMeshFunctionObject
113  - ExtendedCodeGuide::functionObjects::field::mapFields
114 
115 SourceFiles
116  mapFields.C
117  mapFieldsTemplates.C
118 
119 \*---------------------------------------------------------------------------*/
120 
121 #ifndef functionObjects_mapFields_H
122 #define functionObjects_mapFields_H
123 
124 #include "fvMeshFunctionObject.H"
125 #include "volFieldsFwd.H"
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 namespace Foam
130 {
131 
132 class meshToMesh;
133 
134 namespace functionObjects
135 {
136 
137 /*---------------------------------------------------------------------------*\
138  Class mapFields Declaration
139 \*---------------------------------------------------------------------------*/
140 
141 class mapFields
142 :
143  public fvMeshFunctionObject
144 {
145  // Private Data
146 
147  //- Locally cached map region mesh (map to this mesh)
148  autoPtr<fvMesh> mapRegionPtr_;
149 
150  //- Mesh-to-mesh interpolation
151  autoPtr<meshToMesh> interpPtr_;
152 
153  //- List of field names to interpolate
154  wordRes fieldNames_;
155 
156 
157  // Private Member Functions
158 
159  //- Helper function to create the mesh-to-mesh interpolation
160  void createInterpolation(const dictionary& dict);
161 
162  //- Helper function to evaluate constraint patches after mapping
163  template<class Type>
164  void evaluateConstraintTypes
165  (
166  GeometricField<Type, fvPatchField, volMesh>& fld
167  ) const;
168 
169  //- Helper function to map the <Type> fields
170  template<class Type>
171  bool mapFieldType() const;
172 
173  //- Helper function to write the <Type> fields
174  template<class Type>
175  bool writeFieldType() const;
176 
177 
178 public:
179 
180  //- Runtime type information
181  TypeName("mapFields");
182 
183 
184  // Constructors
185 
186  //- Construct from Time and dictionary
187  mapFields
188  (
189  const word& name,
190  const Time& runTime,
191  const dictionary& dict
192  );
193 
194  //- No copy construct
195  mapFields(const mapFields&) = delete;
196 
197  //- No copy assignment
198  void operator=(const mapFields&) = delete;
199 
200 
201  //- Destructor
202  virtual ~mapFields() = default;
203 
204 
205  // Member Functions
206 
207  //- Read the mapFields data
208  virtual bool read(const dictionary&);
209 
210  //- Execute, currently does nothing
211  virtual bool execute();
212 
213  //- Calculate the mapFields and write
214  virtual bool write();
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace functionObjects
221 } // End namespace Foam
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 #ifdef NoRepository
226  #include "mapFieldsTemplates.C"
227 #endif
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
volFieldsFwd.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::mapFields::write
virtual bool write()
Calculate the mapFields and write.
Definition: mapFields.C:195
fvMeshFunctionObject.H
Foam::functionObjects::mapFields::mapFields
mapFields(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: mapFields.C:139
Foam::functionObjects::mapFields::read
virtual bool read(const dictionary &)
Read the mapFields data.
Definition: mapFields.C:156
Foam::functionObjects::mapFields
Maps input fields from local mesh to secondary mesh at runtime.
Definition: mapFields.H:224
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
mapFieldsTemplates.C
Foam::functionObjects::mapFields::operator=
void operator=(const mapFields &)=delete
No copy assignment.
Foam::functionObjects::mapFields::execute
virtual bool execute()
Execute, currently does nothing.
Definition: mapFields.C:170
Foam::functionObjects::mapFields::TypeName
TypeName("mapFields")
Runtime type information.
Foam::functionObjects::mapFields::~mapFields
virtual ~mapFields()=default
Destructor.
fld
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))
Definition: gmvOutputLagrangian.H:23
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::GeometricField< Type, fvPatchField, volMesh >