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-2023 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 "scalarList.H"
44 #include "className.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 template<class Type>
52 class indexedOctree;
53 
54 class treeDataCell;
55 
56 /*---------------------------------------------------------------------------*\
57  Class meshToMesh0 Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class meshToMesh0
61 {
62  // Private Data
63 
64  //- Source mesh reference
65  const fvMesh& fromMesh_;
66 
67  //- Target mesh reference
68  const fvMesh& toMesh_;
69 
70  //- fromMesh patch labels
71  HashTable<label> fromMeshPatches_;
72 
73  //- toMesh patch labels
74  HashTable<label> toMeshPatches_;
75 
76  //- Patch map
77  HashTable<word> patchMap_;
78 
79  //- toMesh patch labels which cut the from-mesh
80  HashTable<label> cuttingPatches_;
81 
82  //- Cell addressing
83  labelList cellAddressing_;
84 
85  //- Boundary addressing
86  labelListList boundaryAddressing_;
87 
88  //- Inverse-distance interpolation weights
89  mutable scalarListList* inverseDistanceWeightsPtr_;
90 
91  //- Inverse-volume interpolation weights
92  mutable scalarListList* inverseVolumeWeightsPtr_;
93 
94  //- Cell to cell overlap addressing
95  mutable labelListList* cellToCellAddressingPtr_;
96 
97  //- Overlap volume
98  mutable scalar V_;
99 
100 
101  // Private Member Functions
102 
103  //- Calculates mesh to mesh addressing pattern.
104  // For each cell from one mesh find the closest cell centre
105  // in the other mesh
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  // Member Functions
179 
180  // Access
181 
182  const fvMesh& fromMesh() const
183  {
184  return fromMesh_;
185  }
186 
187  const fvMesh& toMesh() const
188  {
189  return toMesh_;
190  }
191 
192  //- From toMesh cells to fromMesh cells
193  const labelList& cellAddressing() const
194  {
195  return cellAddressing_;
196  }
197 
198  //- Overlap volume
199  scalar V() const
200  {
201  return V_;
202  }
203 
204 
205  // Interpolation
206 
207  //- Map field
208  template<class Type>
209  void mapField
210  (
211  Field<Type>&,
212  const Field<Type>&,
213  const labelList& adr
214  ) const;
215 
216  //- Interpolate field using inverse-distance weights
217  template<class Type>
218  void interpolateField
219  (
220  Field<Type>&,
221  const VolField<Type>&,
222  const labelList& adr,
223  const scalarListList& weights
224  ) const;
225 
226  //- Interpolate field using inverse-volume weights
227  template<class Type>
228  void interpolateField
229  (
230  Field<Type>&,
231  const VolField<Type>&,
232  const labelListList& adr,
233  const scalarListList& weights
234  ) const;
235 
236 
237  //- Interpolate field using cell-point interpolation
238  template<class Type>
239  void interpolateField
240  (
241  Field<Type>&,
242  const VolField<Type>&,
243  const labelList& adr,
244  const vectorField& centres
245  )const;
246 
247 
248  //- Interpolate internal volume field
249  template<class Type>
251  (
252  Field<Type>&,
253  const VolField<Type>&,
255  ) const;
256 
257  template<class Type>
259  (
260  Field<Type>&,
261  const tmp<VolField<Type>>&,
263  ) const;
264 
265 
266  //- Interpolate volume field
267  template<class Type>
268  void interpolate
269  (
271  const VolField<Type>&,
273  ) const;
274 
275  template<class Type>
276  void interpolate
277  (
279  const tmp<VolField<Type>>&,
281  ) const;
282 
283 
284  //- Interpolate volume field
285  template<class Type>
287  (
288  const VolField<Type>&,
290  ) const;
291 
292  template<class Type>
294  (
295  const tmp<VolField<Type>>&,
297  ) const;
298 };
299 
300 
301 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 
303 } // End namespace Foam
304 
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 
307 #ifdef NoRepository
308  #include "meshToMesh0Templates.C"
309 #endif
310 
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
312 
313 #endif
314 
315 // ************************************************************************* //
Generic GeometricField class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Non-pointer based hierarchical recursive searching.
Definition: indexedOctree.H:72
Serial mesh to mesh interpolation class.
Definition: meshToMesh0.H:60
const fvMesh & fromMesh() const
Definition: meshToMesh0.H:181
ClassName("meshToMesh0")
scalar V() const
Overlap volume.
Definition: meshToMesh0.H:198
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.
void interpolateField(Field< Type > &, const VolField< Type > &, const labelList &adr, const scalarListList &weights) const
Interpolate field using inverse-distance weights.
const fvMesh & toMesh() const
Definition: meshToMesh0.H:186
~meshToMesh0()
Destructor.
void interpolateInternalField(Field< Type > &, const VolField< Type > &, order=INTERPOLATE) const
Interpolate internal volume field.
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:143
void mapField(Field< Type > &, const Field< Type > &, const labelList &adr) const
Map field.
void interpolate(VolField< Type > &, const VolField< Type > &, order=INTERPOLATE) const
Interpolate volume field.
const labelList & cellAddressing() const
From toMesh cells to fromMesh cells.
Definition: meshToMesh0.H:192
A class for managing temporary objects.
Definition: tmp.H:55
Macro definitions for declaring ClassName(), NamespaceName(), etc.
const pointField & points
const cellShapeList & cells
Namespace for OpenFOAM.