FreeFOAM The Cross-Platform CFD Toolkit
meshToMesh.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) 1991-2010 OpenCFD Ltd.
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::meshToMesh
26 
27 Description
28  mesh to mesh interpolation class.
29 
30 SourceFiles
31  meshToMesh.C
32  calculateMeshToMeshAddressing.C
33  calculateMeshToMeshWeights.C
34  meshToMeshInterpolate.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef meshtoMesh_H
39 #define meshtoMesh_H
40 
41 #include <finiteVolume/fvMesh.H>
42 #include <OpenFOAM/HashTable.H>
44 #include <OpenFOAM/scalarList.H>
45 #include <OpenFOAM/className.H>
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 template<class Type>
53 class octree;
54 
55 class octreeDataCell;
56 
57 /*---------------------------------------------------------------------------*\
58  Class meshToMesh Declaration
59 \*---------------------------------------------------------------------------*/
60 
62 {
63  // Private data
64 
65  // mesh references
66 
67  const fvMesh& fromMesh_;
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 
92  // Private Member Functions
93 
94  void calcAddressing();
95 
96  void cellAddresses
97  (
99  const pointField& points,
100  const fvMesh& fromMesh,
101  const List<bool>& boundaryCell,
102  const octree<octreeDataCell>& oc
103  ) const;
104 
105  void calculateInverseDistanceWeights() const;
106 
107  const scalarListList& inverseDistanceWeights() const;
108 
109 
110  // Private static data members
111 
112  //- Direct hit tolerance
113  static const scalar directHitTol;
114 
115 
116 public:
117 
118  // Declare name of the class and its debug switch
119  ClassName("meshToMesh");
120 
121 
122  //- Enumeration specifying required accuracy
123  enum order
124  {
128  };
129 
130 
131  // Constructors
132 
133  //- Construct from the two meshes, the patch name map for the patches
134  // to be interpolated and the names of the toMesh-patches which
135  // cut the fromMesh
136  meshToMesh
137  (
138  const fvMesh& fromMesh,
139  const fvMesh& toMesh,
140  const HashTable<word>& patchMap,
141  const wordList& cuttingPatchNames
142  );
143 
144  //- Construct from the two meshes assuming there is an exact mapping
145  // between the patches
146  meshToMesh
147  (
148  const fvMesh& fromMesh,
149  const fvMesh& toMesh
150  );
151 
152 
153  // Destructor
154 
155  ~meshToMesh();
156 
157 
158  //- Patch-field interpolation class
160  :
161  public fvPatchFieldMapper
162  {
163  const labelList& directAddressing_;
164 
165  public:
166 
167  // Constructors
168 
169  //- Construct given addressing
171  :
172  directAddressing_(addr)
173  {}
174 
175 
176  // Destructor
177 
179  {}
180 
181 
182  // Member Functions
183 
184  label size() const
185  {
186  return directAddressing_.size();
187  }
188 
189  bool direct() const
190  {
191  return true;
192  }
193 
195  {
196  return directAddressing_;
197  }
198  };
199 
200 
201  // Member Functions
202 
203  // Access
204 
205  const fvMesh& fromMesh() const
206  {
207  return fromMesh_;
208  }
209 
210  const fvMesh& toMesh() const
211  {
212  return toMesh_;
213  }
214 
215  //- From toMesh cells to fromMesh cells
216  const labelList& cellAddressing() const
217  {
218  return cellAddressing_;
219  }
220 
221  // Interpolation
222 
223  //- Map field
224  template<class Type>
225  void mapField
226  (
227  Field<Type>&,
228  const Field<Type>&,
229  const labelList& adr
230  ) const;
231 
232  //- Interpolate field using inverse-distance weights
233  template<class Type>
234  void interpolateField
235  (
236  Field<Type>&,
238  const labelList& adr,
239  const scalarListList& weights
240  ) const;
241 
242  //- Interpolate field using cell-point interpolation
243  template<class Type>
244  void interpolateField
245  (
246  Field<Type>&,
248  const labelList& adr,
249  const vectorField& centres
250  ) const;
251 
252 
253  //- Interpolate internal volume field
254  template<class Type>
256  (
257  Field<Type>&,
260  ) const;
261 
262  template<class Type>
264  (
265  Field<Type>&,
268  ) const;
269 
270 
271  //- Interpolate volume field
272  template<class Type>
273  void interpolate
274  (
278  ) const;
279 
280  template<class Type>
281  void interpolate
282  (
286  ) const;
287 
288 
289  //- Interpolate volume field
290  template<class Type>
292  (
295  ) const;
296 
297  template<class Type>
299  (
302  ) const;
303 };
304 
305 
306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
307 
308 } // End namespace Foam
309 
310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 
312 #ifdef NoRepository
313 # include "meshToMeshInterpolate.C"
314 #endif
315 
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
317 
318 #endif
319 
320 // ************************ vim: set sw=4 sts=4 et: ************************ //