Forward compatibility: flex
[foam-extend-3.2.git] / src / sampling / meshToMeshInterpolation / meshToMesh / meshToMesh.H
blob4f585932892b1119249c01f5e0c008fa7cb83681
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::meshToMesh
27 Description
28     mesh to mesh interpolation class.
30 SourceFiles
31     meshToMesh.C
32     calculateMeshToMeshAddressing.C
33     calculateMeshToMeshWeights.C
34     meshToMeshInterpolate.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef meshtoMesh_H
39 #define meshtoMesh_H
41 #include "fvMesh.H"
42 #include "HashTable.H"
43 #include "fvPatchMapper.H"
44 #include "scalarList.H"
45 #include "className.H"
46 #include "tolerancesSwitch.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 template<class Type>
54 class octree;
56 class octreeDataCell;
58 /*---------------------------------------------------------------------------*\
59                            Class meshToMesh Declaration
60 \*---------------------------------------------------------------------------*/
62 class meshToMesh
64     // Private data
66         // Mesh references
68         //- Source mesh reference - containing data
69         const fvMesh& fromMesh_;
71         //- Target mesh reference - mapping target
72         const fvMesh& toMesh_;
74         //- fromMesh patch labels
75         HashTable<label> fromMeshPatches_;
77         //- toMesh patch labels
78         HashTable<label> toMeshPatches_;
80         //- Patch map
81         HashTable<word> patchMap_;
83         //- toMesh patch labels which cut the from-mesh
84         HashTable<label> cuttingPatches_;
86         //- Cell addressing
87         labelList cellAddressing_;
89         //- Boundary addressing
90         labelListList boundaryAddressing_;
92         //- Inverse-distance interpolation weights
93         mutable scalarListList* inverseDistanceWeightsPtr_;
96     // Private Member Functions
98         // Access
100             //- Return addressing
101             void cellAddresses
102             (
103                 labelList& cells,
104                 const pointField& points,
105                 const fvMesh& fromMesh,
106                 const List<bool>& boundaryCell,
107                 const octree<octreeDataCell>& oc,
108                 bool forceFind = false
109             ) const;
111             //- Return inverse distance weights
112             const scalarListList& inverseDistanceWeights() const;
114         // Data calculation functions
116             //- Calculate weights
117             void calculateInverseDistanceWeights() const;
119             //- Calculate addressing
120             void calcAddressing();
123     // Private static data members
125         //- Direct hit tolerance
126         static const debug::tolerancesSwitch directHitTol;
128         //- Cell centre distance required to establish a hit
129         static const debug::tolerancesSwitch cellCentreDistanceTol;
132 public:
134     // Declare name of the class and its debug switch
135     ClassName("meshToMesh");
138     //- Enumeration specifying required accuracy
139     enum order
140     {
141         MAP,
142         INTERPOLATE,
143         CELL_POINT_INTERPOLATE
144     };
147     // Constructors
149         //- Construct from the two meshes, the patch name map for the patches
150         //  to be interpolated and the names of the toMesh-patches which
151         //  cut the fromMesh
152         meshToMesh
153         (
154             const fvMesh& fromMesh,
155             const fvMesh& toMesh,
156             const HashTable<word>& patchMap,
157             const wordList& cuttingPatchNames
158         );
160         //- Construct from the two meshes assuming there is an exact mapping
161         //  between the patches
162         meshToMesh
163         (
164             const fvMesh& fromMesh,
165             const fvMesh& toMesh
166         );
169     //- Destructor
170     ~meshToMesh();
173     //- Patch-field interpolation class
174     class patchFieldInterpolator
175     :
176         public fvPatchFieldMapper
177     {
178         const labelList& directAddressing_;
180     public:
182         // Constructors
184             //- Construct given addressing
185             patchFieldInterpolator(const labelList& addr)
186             :
187                 directAddressing_(addr)
188             {}
191         // Destructor
193             virtual ~patchFieldInterpolator()
194             {}
197         // Member Functions
199             virtual label size() const
200             {
201                 return directAddressing_.size();
202             }
204             virtual label sizeBeforeMapping() const
205             {
206                 return directAddressing_.size();
207             }
209             virtual bool direct() const
210             {
211                 return true;
212             }
214             const labelList& directAddressing() const
215             {
216                 return directAddressing_;
217             }
218     };
221     // Member Functions
223         // Access
225             const fvMesh& fromMesh() const
226             {
227                 return fromMesh_;
228             }
230             const fvMesh& toMesh() const
231             {
232                 return toMesh_;
233             }
235             //- From toMesh cells to fromMesh cells
236             const labelList& cellAddressing() const
237             {
238                 return cellAddressing_;
239             }
241         // Interpolation
243             //- Map field
244             template<class Type>
245             void mapField
246             (
247                 Field<Type>&,
248                 const Field<Type>&,
249                 const labelList& adr
250             ) const;
252             //- Interpolate field using inverse-distance weights
253             template<class Type>
254             void interpolateField
255             (
256                 Field<Type>&,
257                 const GeometricField<Type, fvPatchField, volMesh>&,
258                 const labelList& adr,
259                 const scalarListList& weights
260             ) const;
262             //- Interpolate field using cell-point interpolation
263             template<class Type>
264             void interpolateField
265             (
266                 Field<Type>&,
267                 const GeometricField<Type, fvPatchField, volMesh>&,
268                 const labelList& adr,
269                 const vectorField& centres
270             ) const;
273             //- Interpolate internal volume field
274             template<class Type>
275             void interpolateInternalField
276             (
277                 Field<Type>&,
278                 const GeometricField<Type, fvPatchField, volMesh>&,
279                 order = INTERPOLATE
280             ) const;
282             template<class Type>
283             void interpolateInternalField
284             (
285                 Field<Type>&,
286                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
287                 order = INTERPOLATE
288             ) const;
291             //- Interpolate volume field
292             template<class Type>
293             void interpolate
294             (
295                 GeometricField<Type, fvPatchField, volMesh>&,
296                 const GeometricField<Type, fvPatchField, volMesh>&,
297                 order = INTERPOLATE
298             ) const;
300             template<class Type>
301             void interpolate
302             (
303                 GeometricField<Type, fvPatchField, volMesh>&,
304                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
305                 order = INTERPOLATE
306             ) const;
309             //- Interpolate volume field
310             template<class Type>
311             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
312             (
313                 const GeometricField<Type, fvPatchField, volMesh>&,
314                 order = INTERPOLATE
315             ) const;
317             template<class Type>
318             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
319             (
320                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
321                 order = INTERPOLATE
322             ) const;
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 } // End namespace Foam
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
332 #ifdef NoRepository
333 #   include "meshToMeshInterpolate.C"
334 #endif
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
338 #endif
340 // ************************************************************************* //