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