MapMeshes.H
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-2018 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 #ifndef MapMeshes_H
27 #define MapMeshes_H
28 
29 #include "MapVolFields.H"
30 #include "MapConsistentVolFields.H"
31 #include "mapLagrangian.H"
32 #include "UnMapped.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 template<template<class> class CombineOp>
41 (
42  const fvMesh& meshSource,
43  const fvMesh& meshTarget,
44  const meshToMesh0::order& mapOrder
45 )
46 {
47  // Create the interpolation scheme
48  meshToMesh0 meshToMesh0Interp(meshSource, meshTarget);
49 
50  Info<< nl
51  << "Consistently creating and mapping fields for time "
52  << meshSource.time().timeName() << nl << endl;
53 
54  {
55  // Search for list of objects for this time
56  IOobjectList objects(meshSource, meshSource.time().timeName());
57 
58  // Map volFields
59  // ~~~~~~~~~~~~~
60  MapConsistentVolFields<scalar>
61  (
62  objects,
63  meshToMesh0Interp,
64  mapOrder,
65  CombineOp<scalar>()
66  );
67  MapConsistentVolFields<vector>
68  (
69  objects,
70  meshToMesh0Interp,
71  mapOrder,
72  CombineOp<vector>()
73  );
74  MapConsistentVolFields<sphericalTensor>
75  (
76  objects,
77  meshToMesh0Interp,
78  mapOrder,
79  CombineOp<sphericalTensor>()
80  );
81  MapConsistentVolFields<symmTensor>
82  (
83  objects,
84  meshToMesh0Interp,
85  mapOrder,
86  CombineOp<symmTensor>()
87  );
88  MapConsistentVolFields<tensor>
89  (
90  objects,
91  meshToMesh0Interp,
92  mapOrder,
93  CombineOp<tensor>()
94  );
95  }
96 
97  {
98  // Search for list of target objects for this time
99  IOobjectList objects(meshTarget, meshTarget.time().timeName());
100 
101  // Mark surfaceFields as unmapped
102  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103  UnMapped<surfaceScalarField>(objects);
104  UnMapped<surfaceVectorField>(objects);
105  UnMapped<surfaceSphericalTensorField>(objects);
106  UnMapped<surfaceSymmTensorField>(objects);
107  UnMapped<surfaceTensorField>(objects);
108 
109  // Mark pointFields as unmapped
110  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111  UnMapped<pointScalarField>(objects);
112  UnMapped<pointVectorField>(objects);
113  UnMapped<pointSphericalTensorField>(objects);
114  UnMapped<pointSymmTensorField>(objects);
115  UnMapped<pointTensorField>(objects);
116  }
117 
118  mapLagrangian(meshToMesh0Interp);
119 }
120 
121 
122 template<template<class> class CombineOp>
123 void MapSubMesh
124 (
125  const fvMesh& meshSource,
126  const fvMesh& meshTarget,
127  const HashTable<word>& patchMap,
128  const wordList& cuttingPatches,
129  const meshToMesh0::order& mapOrder
130 )
131 {
132  // Create the interpolation scheme
133  meshToMesh0 meshToMesh0Interp
134  (
135  meshSource,
136  meshTarget,
137  patchMap,
138  cuttingPatches
139  );
140 
141  Info<< nl
142  << "Mapping fields for time " << meshSource.time().timeName()
143  << nl << endl;
144 
145  {
146  // Search for list of source objects for this time
147  IOobjectList objects(meshSource, meshSource.time().timeName());
148 
149  // Map volFields
150  // ~~~~~~~~~~~~~
151  MapVolFields<scalar>
152  (
153  objects,
154  meshToMesh0Interp,
155  mapOrder,
156  CombineOp<scalar>()
157  );
158  MapVolFields<vector>
159  (
160  objects,
161  meshToMesh0Interp,
162  mapOrder,
163  CombineOp<vector>()
164  );
165  MapVolFields<sphericalTensor>
166  (
167  objects,
168  meshToMesh0Interp,
169  mapOrder,
170  CombineOp<sphericalTensor>()
171  );
172  MapVolFields<symmTensor>
173  (
174  objects,
175  meshToMesh0Interp,
176  mapOrder,
177  CombineOp<symmTensor>()
178  );
179  MapVolFields<tensor>
180  (
181  objects,
182  meshToMesh0Interp,
183  mapOrder,
184  CombineOp<tensor>()
185  );
186  }
187 
188  {
189  // Search for list of target objects for this time
190  IOobjectList objects(meshTarget, meshTarget.time().timeName());
191 
192  // Mark surfaceFields as unmapped
193  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194  UnMapped<surfaceScalarField>(objects);
195  UnMapped<surfaceVectorField>(objects);
196  UnMapped<surfaceSphericalTensorField>(objects);
197  UnMapped<surfaceSymmTensorField>(objects);
198  UnMapped<surfaceTensorField>(objects);
199 
200  // Mark pointFields as unmapped
201  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202  UnMapped<pointScalarField>(objects);
203  UnMapped<pointVectorField>(objects);
204  UnMapped<pointSphericalTensorField>(objects);
205  UnMapped<pointSymmTensorField>(objects);
206  UnMapped<pointTensorField>(objects);
207  }
208 
209  mapLagrangian(meshToMesh0Interp);
210 }
211 
212 
213 template<template<class> class CombineOp>
215 (
216  const fvMesh& meshSource,
217  const fvMesh& meshTarget,
218  const meshToMesh0::order& mapOrder
219 )
220 {
221  HashTable<word> patchMap;
222  HashTable<label> cuttingPatchTable;
223 
224  forAll(meshTarget.boundary(), patchi)
225  {
226  if (!isA<processorFvPatch>(meshTarget.boundary()[patchi]))
227  {
228  patchMap.insert
229  (
230  meshTarget.boundary()[patchi].name(),
231  meshTarget.boundary()[patchi].name()
232  );
233  }
234  else
235  {
236  cuttingPatchTable.insert
237  (
238  meshTarget.boundaryMesh()[patchi].name(),
239  -1
240  );
241  }
242  }
243 
244  MapSubMesh<CombineOp>
245  (
246  meshSource,
247  meshTarget,
248  patchMap,
249  cuttingPatchTable.toc(),
250  mapOrder
251  );
252 }
253 
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 } // End namespace Foam
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:434
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const word & name() const
Return name.
Definition: IOobject.H:303
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
void MapConsistentSubMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const meshToMesh0::order &mapOrder)
Definition: MapMeshes.H:215
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:60
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:143
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:622
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:239
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
Maps lagrangian positions and fields.
An STL-conforming hash table.
Definition: HashTable.H:61
static const char nl
Definition: Ostream.H:260
objects
void mapLagrangian(const meshToMesh0 &meshToMesh0Interp)
Maps lagrangian positions and fields.
label patchi
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:202
void MapSubMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const HashTable< word > &patchMap, const wordList &cuttingPatches, const meshToMesh0::order &mapOrder)
Definition: MapMeshes.H:124
Namespace for OpenFOAM.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:540
void MapConsistentMesh(const fvMesh &meshSource, const fvMesh &meshTarget, const meshToMesh0::order &mapOrder)
Definition: MapMeshes.H:41