mapMeshes.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "mapMeshes.H"
27 #include "processorFvPatch.H"
28 #include "mapLagrangian.H"
29 #include "MapVolFields.H"
30 #include "MapConsistentVolFields.H"
31 #include "UnMapped.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
36 (
37  const fvMesh& meshSource,
38  const fvMesh& meshTarget,
39  const meshToMesh0::order& mapOrder
40 )
41 {
42  // Create the interpolation scheme
43  meshToMesh0 meshToMesh0Interp(meshSource, meshTarget);
44 
45  Info<< nl
46  << "Consistently creating and mapping fields for time "
47  << meshSource.time().name() << nl << endl;
48 
49  {
50  // Search for list of objects for this time
51  IOobjectList objects(meshSource, meshSource.time().name());
52 
53  // Map volFields
54  // ~~~~~~~~~~~~~
55  MapConsistentVolFields<scalar>
56  (
57  objects,
58  meshToMesh0Interp,
59  mapOrder
60  );
61  MapConsistentVolFields<vector>
62  (
63  objects,
64  meshToMesh0Interp,
65  mapOrder
66  );
67  MapConsistentVolFields<sphericalTensor>
68  (
69  objects,
70  meshToMesh0Interp,
71  mapOrder
72  );
73  MapConsistentVolFields<symmTensor>
74  (
75  objects,
76  meshToMesh0Interp,
77  mapOrder
78  );
79  MapConsistentVolFields<tensor>
80  (
81  objects,
82  meshToMesh0Interp,
83  mapOrder
84  );
85  }
86 
87  {
88  // Search for list of target objects for this time
89  IOobjectList objects(meshTarget, meshTarget.time().name());
90 
91  // Mark surfaceFields as unmapped
92  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93  UnMapped<surfaceScalarField>(objects);
94  UnMapped<surfaceVectorField>(objects);
95  UnMapped<surfaceSphericalTensorField>(objects);
96  UnMapped<surfaceSymmTensorField>(objects);
97  UnMapped<surfaceTensorField>(objects);
98 
99  // Mark pointFields as unmapped
100  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
101  UnMapped<pointScalarField>(objects);
102  UnMapped<pointVectorField>(objects);
103  UnMapped<pointSphericalTensorField>(objects);
104  UnMapped<pointSymmTensorField>(objects);
105  UnMapped<pointTensorField>(objects);
106  }
107 
108  mapLagrangian(meshToMesh0Interp);
109 }
110 
111 
112 void Foam::mapSubMesh
113 (
114  const fvMesh& meshSource,
115  const fvMesh& meshTarget,
116  const HashTable<word>& patchMap,
117  const wordList& cuttingPatches,
118  const meshToMesh0::order& mapOrder
119 )
120 {
121  // Create the interpolation scheme
122  meshToMesh0 meshToMesh0Interp
123  (
124  meshSource,
125  meshTarget,
126  patchMap,
127  cuttingPatches
128  );
129 
130  Info<< nl
131  << "Mapping fields for time " << meshSource.time().name()
132  << nl << endl;
133 
134  {
135  // Search for list of source objects for this time
136  IOobjectList objects(meshSource, meshSource.time().name());
137 
138  // Map volFields
139  // ~~~~~~~~~~~~~
140  MapVolFields<scalar>
141  (
142  objects,
143  meshToMesh0Interp,
144  mapOrder
145  );
146  MapVolFields<vector>
147  (
148  objects,
149  meshToMesh0Interp,
150  mapOrder
151  );
152  MapVolFields<sphericalTensor>
153  (
154  objects,
155  meshToMesh0Interp,
156  mapOrder
157  );
158  MapVolFields<symmTensor>
159  (
160  objects,
161  meshToMesh0Interp,
162  mapOrder
163  );
164  MapVolFields<tensor>
165  (
166  objects,
167  meshToMesh0Interp,
168  mapOrder
169  );
170  }
171 
172  {
173  // Search for list of target objects for this time
174  IOobjectList objects(meshTarget, meshTarget.time().name());
175 
176  // Mark surfaceFields as unmapped
177  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
178  UnMapped<surfaceScalarField>(objects);
179  UnMapped<surfaceVectorField>(objects);
180  UnMapped<surfaceSphericalTensorField>(objects);
181  UnMapped<surfaceSymmTensorField>(objects);
182  UnMapped<surfaceTensorField>(objects);
183 
184  // Mark pointFields as unmapped
185  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
186  UnMapped<pointScalarField>(objects);
187  UnMapped<pointVectorField>(objects);
188  UnMapped<pointSphericalTensorField>(objects);
189  UnMapped<pointSymmTensorField>(objects);
190  UnMapped<pointTensorField>(objects);
191  }
192 
193  mapLagrangian(meshToMesh0Interp);
194 }
195 
196 
198 (
199  const fvMesh& meshSource,
200  const fvMesh& meshTarget,
201  const meshToMesh0::order& mapOrder
202 )
203 {
204  HashTable<word> patchMap;
205  HashTable<label> cuttingPatchTable;
206 
207  forAll(meshTarget.boundary(), patchi)
208  {
209  if (!isA<processorFvPatch>(meshTarget.boundary()[patchi]))
210  {
211  patchMap.insert
212  (
213  meshTarget.boundary()[patchi].name(),
214  meshTarget.boundary()[patchi].name()
215  );
216  }
217  else
218  {
219  cuttingPatchTable.insert
220  (
221  meshTarget.poly().boundary()[patchi].name(),
222  -1
223  );
224  }
225  }
226 
227  mapSubMesh
228  (
229  meshSource,
230  meshTarget,
231  patchMap,
232  cuttingPatchTable.toc(),
233  mapOrder
234  );
235 }
236 
237 
239 (
240  const fvMesh& meshTarget,
241  const wordList& cuttingPatches
242 )
243 {
244  // Add the processor patches to the cutting list
245  HashTable<label> cuttingPatchTable;
246  forAll(cuttingPatches, i)
247  {
248  cuttingPatchTable.insert(cuttingPatches[i], i);
249  }
250 
251  forAll(meshTarget.boundary(), patchi)
252  {
253  if (isA<processorFvPatch>(meshTarget.boundary()[patchi]))
254  {
255  if
256  (
257  !cuttingPatchTable.found
258  (
259  meshTarget.poly().boundary()[patchi].name()
260  )
261  )
262  {
263  cuttingPatchTable.insert
264  (
265  meshTarget.poly().boundary()[patchi].name(),
266  -1
267  );
268  }
269  }
270  }
271 
272  return cuttingPatchTable.toc();
273 }
274 
275 
276 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
label patchi
Maps lagrangian positions and fields.
List< word > wordList
A List of words.
Definition: fileName.H:54
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
void mapSubMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const HashTable< word > &patchMap, const wordList &cuttingPatches, const meshToMesh0::order &mapOrder)
int order(const scalar s)
messageStream Info
void mapConsistentMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const meshToMesh0::order &mapOrder)
void mapLagrangian(const meshToMesh0 &meshToMesh0Interp)
Maps lagrangian positions and fields.
wordList addProcessorPatches(const fvMesh &meshTarget, const wordList &cuttingPatches)
static const char nl
Definition: Ostream.H:297
void mapConsistentSubMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const meshToMesh0::order &mapOrder)
objects