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