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