meshToMesh0.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-2020 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 Class
25  Foam::meshToMesh0
26 
27 Description
28  Serial mesh to mesh interpolation class.
29 
30 SourceFiles
31  meshToMesh0.C
32  calculateMeshToMesh0Addressing.C
33  calculateMeshToMesh0Weights.C
34  meshToMesh0Templates.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef meshToMesh0_H
39 #define meshToMesh0_H
40 
41 #include "fvMesh.H"
42 #include "HashTable.H"
43 #include "fvPatchMapper.H"
44 #include "scalarList.H"
45 #include "className.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 template<class Type>
53 class indexedOctree;
54 
55 class treeDataCell;
56 
57 /*---------------------------------------------------------------------------*\
58  Class meshToMesh0 Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class meshToMesh0
62 {
63  // Private Data
64 
65  //- Source mesh reference
66  const fvMesh& fromMesh_;
67 
68  //- Target mesh reference
69  const fvMesh& toMesh_;
70 
71  //- fromMesh patch labels
72  HashTable<label> fromMeshPatches_;
73 
74  //- toMesh patch labels
75  HashTable<label> toMeshPatches_;
76 
77  //- Patch map
78  HashTable<word> patchMap_;
79 
80  //- toMesh patch labels which cut the from-mesh
81  HashTable<label> cuttingPatches_;
82 
83  //- Cell addressing
84  labelList cellAddressing_;
85 
86  //- Boundary addressing
87  labelListList boundaryAddressing_;
88 
89  //- Inverse-distance interpolation weights
90  mutable scalarListList* inverseDistanceWeightsPtr_;
91 
92  //- Inverse-volume interpolation weights
93  mutable scalarListList* inverseVolumeWeightsPtr_;
94 
95  //- Cell to cell overlap addressing
96  mutable labelListList* cellToCellAddressingPtr_;
97 
98  //- Overlap volume
99  mutable scalar V_;
100 
101 
102  // Private Member Functions
103 
104  //- Calculates mesh to mesh addressing pattern.
105  // For each cell from one mesh find the closest cell centre
106  // in the other mesh
107  void calcAddressing();
108 
109  void cellAddresses
110  (
111  labelList& cells,
112  const pointField& points,
113  const fvMesh& fromMesh,
114  const List<bool>& boundaryCell,
116  ) const;
117 
118  void calculateInverseDistanceWeights() const;
119 
120  void calculateInverseVolumeWeights() const;
121 
122  void calculateCellToCellAddressing() const;
123 
124  const scalarListList& inverseDistanceWeights() const;
125 
126  const scalarListList& inverseVolumeWeights() const;
127 
128  const labelListList& cellToCellAddressing() const;
129 
130 
131  // Private static data members
132 
133  //- Direct hit tolerance
134  static const scalar directHitTol;
135 
136 
137 public:
138 
139  // Declare name of the class and its debug switch
140  ClassName("meshToMesh0");
141 
142 
143  //- Enumeration specifying required accuracy
144  enum order
145  {
150  };
151 
152 
153  // Constructors
154 
155  //- Construct from the two meshes, the patch name map for the patches
156  // to be interpolated and the names of the toMesh-patches which
157  // cut the fromMesh
159  (
160  const fvMesh& fromMesh,
161  const fvMesh& toMesh,
162  const HashTable<word>& patchMap,
163  const wordList& cuttingPatchNames
164  );
165 
166  //- Construct from the two meshes assuming there is an exact mapping
167  // between the patches
169  (
170  const fvMesh& fromMesh,
171  const fvMesh& toMesh
172  );
173 
174 
175  //- Destructor
176  ~meshToMesh0();
177 
178 
179  //- Patch-field interpolation class
181  :
183  {
184  const labelList& directAddressing_;
185 
186 
187  public:
188 
189  // Constructors
190 
191  //- Construct given addressing
192  patchFieldInterpolator(const labelList& addr)
193  :
194  directAddressing_(addr)
195  {}
196 
197 
198  //- Destructor
199  virtual ~patchFieldInterpolator()
200  {}
201 
202 
203  // Member Functions
205  label size() const
206  {
207  return directAddressing_.size();
208  }
210  bool direct() const
211  {
212  return true;
213  }
215  bool hasUnmapped() const
216  {
217  return false;
218  }
220  const labelList& directAddressing() const
221  {
222  return directAddressing_;
223  }
224  };
225 
226 
227  // Member Functions
228 
229  // Access
231  const fvMesh& fromMesh() const
232  {
233  return fromMesh_;
234  }
236  const fvMesh& toMesh() const
237  {
238  return toMesh_;
239  }
240 
241  //- From toMesh cells to fromMesh cells
242  const labelList& cellAddressing() const
243  {
244  return cellAddressing_;
245  }
246 
247  //- Overlap volume
248  scalar V() const
249  {
250  return V_;
251  }
252 
253 
254  // Interpolation
255 
256  //- Map field
257  template<class Type, class CombineOp>
258  void mapField
259  (
260  Field<Type>&,
261  const Field<Type>&,
262  const labelList& adr,
263  const CombineOp& cop
264  ) const;
265 
266  //- Interpolate field using inverse-distance weights
267  template<class Type, class CombineOp>
268  void interpolateField
269  (
270  Field<Type>&,
272  const labelList& adr,
273  const scalarListList& weights,
274  const CombineOp& cop
275  ) const;
276 
277  //- Interpolate field using inverse-volume weights
278  template<class Type, class CombineOp>
279  void interpolateField
280  (
281  Field<Type>&,
283  const labelListList& adr,
284  const scalarListList& weights,
285  const CombineOp& cop
286  ) const;
287 
288 
289  //- Interpolate field using cell-point interpolation
290  template<class Type, class CombineOp>
291  void interpolateField
292  (
293  Field<Type>&,
295  const labelList& adr,
296  const vectorField& centres,
297  const CombineOp& cop
298  )const;
299 
300 
301  //- Interpolate internal volume field
302  template<class Type, class CombineOp>
304  (
305  Field<Type>&,
308  const CombineOp& cop = eqOp<Type>()
309  ) const;
310 
311  template<class Type, class CombineOp>
313  (
314  Field<Type>&,
317  const CombineOp& cop = eqOp<Type>()
318  ) const;
319 
320 
321  //- Interpolate volume field
322  template<class Type, class CombineOp>
323  void interpolate
324  (
328  const CombineOp& cop = eqOp<Type>()
329  ) const;
330 
331  template<class Type, class CombineOp>
332  void interpolate
333  (
337  const CombineOp& cop = eqOp<Type>()
338  ) const;
339 
340 
341  //- Interpolate volume field
342  template<class Type, class CombineOp>
344  (
347  const CombineOp& cop = eqOp<Type>()
348  ) const;
349 
350  template<class Type, class CombineOp>
352  (
355  const CombineOp& cop = eqOp<Type>()
356  ) const;
357 };
358 
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 } // End namespace Foam
363 
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 
366 #ifdef NoRepository
367  #include "meshToMesh0Templates.C"
368 #endif
369 
370 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
371 
372 #endif
373 
374 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void mapField(Field< Type > &, const Field< Type > &, const labelList &adr, const CombineOp &cop) const
Map field.
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:60
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:143
Generic GeometricField class.
void interpolateField(Field< Type > &, const GeometricField< Type, fvPatchField, volMesh > &, const labelList &adr, const scalarListList &weights, const CombineOp &cop) const
Interpolate field using inverse-distance weights.
void interpolateInternalField(Field< Type > &, const GeometricField< Type, fvPatchField, volMesh > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate internal volume field.
const fvMesh & toMesh() const
Definition: meshToMesh0.H:235
Definition: ops.H:70
const cellShapeList & cells
const pointField & points
const labelList & cellAddressing() const
From toMesh cells to fromMesh cells.
Definition: meshToMesh0.H:241
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:230
virtual ~patchFieldInterpolator()
Destructor.
Definition: meshToMesh0.H:198
~meshToMesh0()
Destructor.
Definition: meshToMesh0.C:194
Patch-field interpolation class.
Definition: meshToMesh0.H:179
patchFieldInterpolator(const labelList &addr)
Construct given addressing.
Definition: meshToMesh0.H:191
Non-pointer based hierarchical recursive searching.
Definition: treeDataEdge.H:47
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const labelList & directAddressing() const
Definition: meshToMesh0.H:219
virtual const scalarListList & weights() const
scalar V() const
Overlap volume.
Definition: meshToMesh0.H:247
bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: meshToMesh0.H:214
A class for managing temporary objects.
Definition: PtrList.H:53
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:43
Namespace for OpenFOAM.
ClassName("meshToMesh0")
void interpolate(GeometricField< Type, fvPatchField, volMesh > &, const GeometricField< Type, fvPatchField, volMesh > &, order=INTERPOLATE, const CombineOp &cop=eqOp< Type >()) const
Interpolate volume field.