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-2016 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
74  HashTable<label> fromMeshPatches_;
75 
76  //- toMesh patch labels
77  HashTable<label> toMeshPatches_;
78 
79  //- Patch map
80  HashTable<word> patchMap_;
81 
82  //- toMesh patch labels which cut the from-mesh
83  HashTable<label> cuttingPatches_;
84 
85  //- Cell addressing
86  labelList cellAddressing_;
87 
88  //- Boundary addressing
89  labelListList boundaryAddressing_;
90 
91  //- Inverse-distance interpolation weights
92  mutable scalarListList* inverseDistanceWeightsPtr_;
93 
94  //- Inverse-volume interpolation weights
95  mutable scalarListList* inverseVolumeWeightsPtr_;
96 
97  //- Cell to cell overlap addressing
98  mutable labelListList* cellToCellAddressingPtr_;
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  {
183  const labelList& directAddressing_;
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
204  label size() const
205  {
206  return directAddressing_.size();
207  }
209  bool direct() const
210  {
211  return true;
212  }
214  bool hasUnmapped() const
215  {
216  return false;
217  }
219  const labelList& directAddressing() const
220  {
221  return directAddressing_;
222  }
223  };
224 
225 
226  // Member Functions
227 
228  // Access
230  const fvMesh& fromMesh() const
231  {
232  return fromMesh_;
233  }
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 // ************************************************************************* //
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:163
mesh to mesh interpolation class.
Definition: meshToMesh0.H:63
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:142
Generic GeometricField class.
virtual const scalarListList & weights() const
Definition: FieldMapper.H:103
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:234
Definition: ops.H:70
const cellShapeList & cells
const pointField & points
const labelList & cellAddressing() const
From toMesh cells to fromMesh cells.
Definition: meshToMesh0.H:240
Foam::fvPatchFieldMapper.
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:229
virtual ~patchFieldInterpolator()
Destructor.
Definition: meshToMesh0.H:197
~meshToMesh0()
Destructor.
Definition: meshToMesh0.C:194
Patch-field interpolation class.
Definition: meshToMesh0.H:178
patchFieldInterpolator(const labelList &addr)
Construct given addressing.
Definition: meshToMesh0.H:190
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:218
scalar V() const
Overlap volume.
Definition: meshToMesh0.H:246
bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: meshToMesh0.H:213
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.