Loading...
Searching...
No Matches
meshToMesh0.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-2020 OpenFOAM Foundation
9 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::meshToMesh0
29
30Description
31 Serial mesh to mesh interpolation class.
32
33Note
34 This class is due to be deprecated in favour of meshToMesh
35
36SourceFiles
37 meshToMesh0.C
38 calculateMeshToMesh0Addressing.C
39 calculateMeshToMesh0Weights.C
40 meshToMesh0Templates.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef Foam_meshToMesh0_H
45#define Foam_meshToMesh0_H
46
47#include "fvMesh.H"
48#include "HashTable.H"
49#include "fvPatchMapper.H"
50#include "scalarList.H"
51#include "className.H"
52
53// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54
55namespace Foam
56{
57
58// Forward Declarations
59template<class Type> class indexedOctree;
60class treeDataCell;
62/*---------------------------------------------------------------------------*\
63 Class meshToMesh0 Declaration
64\*---------------------------------------------------------------------------*/
65
66class meshToMesh0
67{
68 // Private Data
69
70 // Mesh References
71
72 const fvMesh& fromMesh_;
73 const fvMesh& toMesh_;
74
75 //- fromMesh patch labels
76 HashTable<label> fromMeshPatches_;
77
78 //- toMesh patch labels
79 HashTable<label> toMeshPatches_;
80
81 //- Patch map
82 HashTable<word> patchMap_;
83
84 //- toMesh patch labels which cut the from-mesh
85 HashTable<label> cuttingPatches_;
86
87 //- Cell addressing
88 labelList cellAddressing_;
89
90 //- Boundary addressing
91 labelListList boundaryAddressing_;
92
93 //- Inverse-distance interpolation weights
94 mutable std::unique_ptr<scalarListList> inverseDistanceWeightsPtr_;
95
96 //- Inverse-volume interpolation weights
97 mutable std::unique_ptr<scalarListList> inverseVolumeWeightsPtr_;
98
99 //- Cell to cell overlap addressing
100 mutable std::unique_ptr<labelListList> cellToCellAddressingPtr_;
101
102 //- Overlap volume
103 mutable scalar V_;
104
105
106 // Private Member Functions
107
108 //- Calculates mesh to mesh addressing pattern.
109 // For each cell from one mesh find the closest cell centre
110 // in the other mesh
111 void calcAddressing();
112
113 void cellAddresses
114 (
116 const pointField& points,
117 const fvMesh& fromMesh,
118 const List<bool>& boundaryCell,
119 const indexedOctree<treeDataCell>& cellTree
120 ) const;
121
122 void calculateInverseDistanceWeights() const;
123
124 void calculateInverseVolumeWeights() const;
125
126 void calculateCellToCellAddressing() const;
127
128 const scalarListList& inverseDistanceWeights() const;
129
130 const scalarListList& inverseVolumeWeights() const;
131
132 const labelListList& cellToCellAddressing() const;
133
134
135 // Private Static Data Members
136
137 //- Direct hit tolerance
138 static const scalar directHitTol;
139
140
141public:
142
143 // Declare name of the class and its debug switch
144 ClassName("meshToMesh0");
145
146
147 //- Enumeration specifying required accuracy
148 enum order
149 {
150 MAP,
154 };
155
156
157 // Constructors
158
159 //- Construct from the two meshes, the patch name map for the patches
160 // to be interpolated and the names of the toMesh-patches which
161 // cut the fromMesh
163 (
165 const fvMesh& toMesh,
166 const HashTable<word>& patchMap,
167 const wordList& cuttingPatchNames
168 );
169
170 //- Construct from the two meshes assuming there is an exact mapping
171 // between the patches
176 );
177
178
179 //- Destructor
180 ~meshToMesh0() = default;
181
182
183 //- Patch-field interpolation class
185 :
186 public fvPatchFieldMapper
187 {
188 const labelList& directAddressing_;
189
190
191 public:
192
193 // Constructors
194
195 //- Construct given addressing
197 :
198 directAddressing_(addr)
199 {}
200
201
202 //- Destructor
203 virtual ~patchFieldInterpolator() = default;
204
205
206 // Member Functions
207
208 label size() const
209 {
210 return directAddressing_.size();
211 }
212
213 bool direct() const
214 {
215 return true;
217
218 bool hasUnmapped() const
219 {
220 return false;
221 }
222
223 const labelList& directAddressing() const
224 {
225 return directAddressing_;
226 }
227 };
228
229
230 // Member Functions
231
232 // Access
233
234 const fvMesh& fromMesh() const
235 {
236 return fromMesh_;
237 }
238
239 const fvMesh& toMesh() const
240 {
241 return toMesh_;
242 }
243
244 //- From toMesh cells to fromMesh cells
245 const labelList& cellAddressing() const
246 {
247 return cellAddressing_;
248 }
250 //- Overlap volume
251 scalar V() const
252 {
253 return V_;
255
256
257 // Interpolation
258
259 //- Map field
260 template<class Type, class CombineOp>
261 void mapField
262 (
264 const Field<Type>&,
265 const labelList& adr,
266 const CombineOp& cop
267 ) const;
268
269 //- Interpolate field using inverse-distance weights
270 template<class Type, class CombineOp>
272 (
274 const VolumeField<Type>&,
275 const labelList& adr,
276 const scalarListList& weights,
277 const CombineOp& cop
278 ) const;
279
280 //- Interpolate field using inverse-volume weights
281 template<class Type, class CombineOp>
285 const VolumeField<Type>&,
286 const labelListList& adr,
287 const scalarListList& weights,
288 const CombineOp& cop
289 ) const;
290
292 //- Interpolate field using cell-point interpolation
293 template<class Type, class CombineOp>
295 (
297 const VolumeField<Type>&,
298 const labelList& adr,
299 const vectorField& centres,
300 const CombineOp& cop
301 ) const;
302
303
304 //- Interpolate internal volume field
305 template<class Type, class CombineOp>
307 (
309 const VolumeField<Type>&,
311 const CombineOp& cop = eqOp<Type>()
312 ) const;
313
314 template<class Type, class CombineOp>
316 (
318 const tmp<VolumeField<Type>>&,
320 const CombineOp& cop = eqOp<Type>()
321 ) const;
322
323
324 //- Interpolate volume field
325 template<class Type, class CombineOp>
326 void interpolate
327 (
329 const VolumeField<Type>&,
331 const CombineOp& cop = eqOp<Type>()
332 ) const;
333
334 template<class Type, class CombineOp>
335 void interpolate
336 (
338 const tmp<VolumeField<Type>>&,
340 const CombineOp& cop = eqOp<Type>()
341 ) const;
342
343
344 //- Interpolate volume field
345 template<class Type, class CombineOp>
347 (
348 const VolumeField<Type>&,
350 const CombineOp& cop = eqOp<Type>()
351 ) const;
352
353 template<class Type, class CombineOp>
355 (
356 const tmp<VolumeField<Type>>&,
358 const CombineOp& cop = eqOp<Type>()
359 ) const;
360};
361
362
363// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364
365} // End namespace Foam
366
367// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368
369#ifdef NoRepository
370 #include "meshToMesh0Templates.C"
371#endif
372
373// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
374
375#endif
376
377// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A HashTable similar to std::unordered_map.
Definition HashTable.H:124
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
A FieldMapper for finite-volume patch fields.
fvPatchFieldMapper()=default
Default construct.
Non-pointer based hierarchical recursive searching.
Patch-field interpolation class.
patchFieldInterpolator(const labelList &addr)
Construct given addressing.
const labelList & directAddressing() const
Return the direct addressing values.
bool hasUnmapped() const
Any unmapped values?
bool direct() const
Is it a direct (non-interpolating) mapper?
virtual ~patchFieldInterpolator()=default
Destructor.
label size() const
The size of the mapper.
ClassName("meshToMesh0")
scalar V() const
Overlap volume.
const fvMesh & toMesh() const
void interpolate(VolumeField< Type > &, const VolumeField< Type > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.
tmp< VolumeField< Type > > interpolate(const tmp< VolumeField< Type > > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
meshToMesh0(const fvMesh &fromMesh, const fvMesh &toMesh, const HashTable< word > &patchMap, const wordList &cuttingPatchNames)
Construct from the two meshes, the patch name map for the patches.
Definition meshToMesh0.C:38
void mapField(Field< Type > &, const Field< Type > &, const labelList &adr, const CombineOp &cop) const
Map field.
order
Enumeration specifying required accuracy.
void interpolateInternalField(Field< Type > &, const VolumeField< Type > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate internal volume field.
const labelList & cellAddressing() const
From toMesh cells to fromMesh cells.
~meshToMesh0()=default
Destructor.
const fvMesh & fromMesh() const
void interpolateField(Field< Type > &, const VolumeField< Type > &, const labelList &adr, const scalarListList &weights, const CombineOp &cop) const
Interpolate field using inverse-distance weights.
tmp< VolumeField< Type > > interpolate(const VolumeField< Type > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.
A class for managing temporary objects.
Definition tmp.H:75
Encapsulation of data needed to search in/for cells. Used to find the cell containing a point (e....
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
Definition className.H:74
const pointField & points
const cellShapeList & cells
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
List< word > wordList
List of word.
Definition fileName.H:60
GeometricField< Type, fvPatchField, volMesh > VolumeField
A volume field for a given type.
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Field< vector > vectorField
Specialisation of Field<T> for vector.
vectorField pointField
pointField is a vectorField.