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-2022 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 "surfaceMesh.H"
28 #include "processorFvPatch.H"
29 #include "mapLagrangian.H"
30 #include "MapVolFields.H"
31 #include "MapConsistentVolFields.H"
32 #include "UnMapped.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
37 (
38  const fvMesh& meshSource,
39  const fvMesh& meshTarget,
40  const meshToMesh0::order& mapOrder
41 )
42 {
43  // Create the interpolation scheme
44  meshToMesh0 meshToMesh0Interp(meshSource, meshTarget);
45 
46  Info<< nl
47  << "Consistently creating and mapping fields for time "
48  << meshSource.time().name() << nl << endl;
49 
50  {
51  // Search for list of objects for this time
52  IOobjectList objects(meshSource, meshSource.time().name());
53 
54  // Map volFields
55  // ~~~~~~~~~~~~~
56  MapConsistentVolFields<scalar>
57  (
58  objects,
59  meshToMesh0Interp,
60  mapOrder
61  );
62  MapConsistentVolFields<vector>
63  (
64  objects,
65  meshToMesh0Interp,
66  mapOrder
67  );
68  MapConsistentVolFields<sphericalTensor>
69  (
70  objects,
71  meshToMesh0Interp,
72  mapOrder
73  );
74  MapConsistentVolFields<symmTensor>
75  (
76  objects,
77  meshToMesh0Interp,
78  mapOrder
79  );
80  MapConsistentVolFields<tensor>
81  (
82  objects,
83  meshToMesh0Interp,
84  mapOrder
85  );
86  }
87 
88  {
89  // Search for list of target objects for this time
90  IOobjectList objects(meshTarget, meshTarget.time().name());
91 
92  // Mark surfaceFields as unmapped
93  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94  UnMapped<surfaceScalarField>(objects);
95  UnMapped<surfaceVectorField>(objects);
96  UnMapped<surfaceSphericalTensorField>(objects);
97  UnMapped<surfaceSymmTensorField>(objects);
98  UnMapped<surfaceTensorField>(objects);
99 
100  // Mark pointFields as unmapped
101  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102  UnMapped<pointScalarField>(objects);
103  UnMapped<pointVectorField>(objects);
104  UnMapped<pointSphericalTensorField>(objects);
105  UnMapped<pointSymmTensorField>(objects);
106  UnMapped<pointTensorField>(objects);
107  }
108 
109  mapLagrangian(meshToMesh0Interp);
110 }
111 
112 
113 void Foam::mapSubMesh
114 (
115  const fvMesh& meshSource,
116  const fvMesh& meshTarget,
117  const HashTable<word>& patchMap,
118  const wordList& cuttingPatches,
119  const meshToMesh0::order& mapOrder
120 )
121 {
122  // Create the interpolation scheme
123  meshToMesh0 meshToMesh0Interp
124  (
125  meshSource,
126  meshTarget,
127  patchMap,
128  cuttingPatches
129  );
130 
131  Info<< nl
132  << "Mapping fields for time " << meshSource.time().name()
133  << nl << endl;
134 
135  {
136  // Search for list of source objects for this time
137  IOobjectList objects(meshSource, meshSource.time().name());
138 
139  // Map volFields
140  // ~~~~~~~~~~~~~
141  MapVolFields<scalar>
142  (
143  objects,
144  meshToMesh0Interp,
145  mapOrder
146  );
147  MapVolFields<vector>
148  (
149  objects,
150  meshToMesh0Interp,
151  mapOrder
152  );
153  MapVolFields<sphericalTensor>
154  (
155  objects,
156  meshToMesh0Interp,
157  mapOrder
158  );
159  MapVolFields<symmTensor>
160  (
161  objects,
162  meshToMesh0Interp,
163  mapOrder
164  );
165  MapVolFields<tensor>
166  (
167  objects,
168  meshToMesh0Interp,
169  mapOrder
170  );
171  }
172 
173  {
174  // Search for list of target objects for this time
175  IOobjectList objects(meshTarget, meshTarget.time().name());
176 
177  // Mark surfaceFields as unmapped
178  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
179  UnMapped<surfaceScalarField>(objects);
180  UnMapped<surfaceVectorField>(objects);
181  UnMapped<surfaceSphericalTensorField>(objects);
182  UnMapped<surfaceSymmTensorField>(objects);
183  UnMapped<surfaceTensorField>(objects);
184 
185  // Mark pointFields as unmapped
186  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
187  UnMapped<pointScalarField>(objects);
188  UnMapped<pointVectorField>(objects);
189  UnMapped<pointSphericalTensorField>(objects);
190  UnMapped<pointSymmTensorField>(objects);
191  UnMapped<pointTensorField>(objects);
192  }
193 
194  mapLagrangian(meshToMesh0Interp);
195 }
196 
197 
199 (
200  const fvMesh& meshSource,
201  const fvMesh& meshTarget,
202  const meshToMesh0::order& mapOrder
203 )
204 {
205  HashTable<word> patchMap;
206  HashTable<label> cuttingPatchTable;
207 
208  forAll(meshTarget.boundary(), patchi)
209  {
210  if (!isA<processorFvPatch>(meshTarget.boundary()[patchi]))
211  {
212  patchMap.insert
213  (
214  meshTarget.boundary()[patchi].name(),
215  meshTarget.boundary()[patchi].name()
216  );
217  }
218  else
219  {
220  cuttingPatchTable.insert
221  (
222  meshTarget.boundaryMesh()[patchi].name(),
223  -1
224  );
225  }
226  }
227 
228  mapSubMesh
229  (
230  meshSource,
231  meshTarget,
232  patchMap,
233  cuttingPatchTable.toc(),
234  mapOrder
235  );
236 }
237 
238 
240 (
241  const fvMesh& meshTarget,
242  const wordList& cuttingPatches
243 )
244 {
245  // Add the processor patches to the cutting list
246  HashTable<label> cuttingPatchTable;
247  forAll(cuttingPatches, i)
248  {
249  cuttingPatchTable.insert(cuttingPatches[i], i);
250  }
251 
252  forAll(meshTarget.boundary(), patchi)
253  {
254  if (isA<processorFvPatch>(meshTarget.boundary()[patchi]))
255  {
256  if
257  (
258  !cuttingPatchTable.found
259  (
260  meshTarget.boundaryMesh()[patchi].name()
261  )
262  )
263  {
264  cuttingPatchTable.insert
265  (
266  meshTarget.boundaryMesh()[patchi].name(),
267  -1
268  );
269  }
270  }
271  }
272 
273  return cuttingPatchTable.toc();
274 }
275 
276 
277 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:251
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:260
void mapConsistentSubMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const meshToMesh0::order &mapOrder)
objects