BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / sampling / meshToMeshInterpolation / meshToMesh / meshToMesh.H
blob785829cc60fc71d9b15af846986b5904f8a25429
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
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"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 template<class Type>
53 class indexedOctree;
55 class treeDataCell;
57 /*---------------------------------------------------------------------------*\
58                          Class meshToMesh Declaration
59 \*---------------------------------------------------------------------------*/
61 class meshToMesh
63     // Private data
65         // mesh references
67         const fvMesh& fromMesh_;
68         const fvMesh& toMesh_;
70         //- fromMesh patch labels
71         HashTable<label> fromMeshPatches_;
73         //- toMesh patch labels
74         HashTable<label> toMeshPatches_;
76         //- Patch map
77         HashTable<word> patchMap_;
79         //- toMesh patch labels which cut the from-mesh
80         HashTable<label> cuttingPatches_;
82         //- Cell addressing
83         labelList cellAddressing_;
85         //- Boundary addressing
86         labelListList boundaryAddressing_;
88         //- Inverse-distance interpolation weights
89         mutable scalarListList* inverseDistanceWeightsPtr_;
92     // Private Member Functions
94         void calcAddressing();
96         void cellAddresses
97         (
98             labelList& cells,
99             const pointField& points,
100             const fvMesh& fromMesh,
101             const List<bool>& boundaryCell,
102             const indexedOctree<treeDataCell>& oc
103         ) const;
105         void calculateInverseDistanceWeights() const;
107         const scalarListList& inverseDistanceWeights() const;
110     // Private static data members
112         //- Direct hit tolerance
113         static const scalar directHitTol;
116 public:
118     // Declare name of the class and its debug switch
119     ClassName("meshToMesh");
122     //- Enumeration specifying required accuracy
123     enum order
124     {
125         MAP,
126         INTERPOLATE,
127         CELL_POINT_INTERPOLATE
128     };
131     // Constructors
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         );
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         );
153     //- Destructor
154     ~meshToMesh();
157     //- Patch-field interpolation class
158     class patchFieldInterpolator
159     :
160         public fvPatchFieldMapper
161     {
162         const labelList& directAddressing_;
164     public:
166         // Constructors
168             //- Construct given addressing
169             patchFieldInterpolator(const labelList& addr)
170             :
171                 directAddressing_(addr)
172             {}
175         //- Destructor
176         virtual ~patchFieldInterpolator()
177         {}
180         // Member Functions
182             label size() const
183             {
184                 return directAddressing_.size();
185             }
187             bool direct() const
188             {
189                 return true;
190             }
192             const labelList& directAddressing() const
193             {
194                 return directAddressing_;
195             }
196     };
199     // Member Functions
201         // Access
203             const fvMesh& fromMesh() const
204             {
205                 return fromMesh_;
206             }
208             const fvMesh& toMesh() const
209             {
210                 return toMesh_;
211             }
213             //- From toMesh cells to fromMesh cells
214             const labelList& cellAddressing() const
215             {
216                 return cellAddressing_;
217             }
219         // Interpolation
221             //- Map field
222             template<class Type>
223             void mapField
224             (
225                 Field<Type>&,
226                 const Field<Type>&,
227                 const labelList& adr
228             ) const;
230             //- Interpolate field using inverse-distance weights
231             template<class Type>
232             void interpolateField
233             (
234                 Field<Type>&,
235                 const GeometricField<Type, fvPatchField, volMesh>&,
236                 const labelList& adr,
237                 const scalarListList& weights
238             ) const;
240             //- Interpolate field using cell-point interpolation
241             template<class Type>
242             void interpolateField
243             (
244                 Field<Type>&,
245                 const GeometricField<Type, fvPatchField, volMesh>&,
246                 const labelList& adr,
247                 const vectorField& centres
248             ) const;
251             //- Interpolate internal volume field
252             template<class Type>
253             void interpolateInternalField
254             (
255                 Field<Type>&,
256                 const GeometricField<Type, fvPatchField, volMesh>&,
257                 order=INTERPOLATE
258             ) const;
260             template<class Type>
261             void interpolateInternalField
262             (
263                 Field<Type>&,
264                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
265                 order=INTERPOLATE
266             ) const;
269             //- Interpolate volume field
270             template<class Type>
271             void interpolate
272             (
273                 GeometricField<Type, fvPatchField, volMesh>&,
274                 const GeometricField<Type, fvPatchField, volMesh>&,
275                 order=INTERPOLATE
276             ) const;
278             template<class Type>
279             void interpolate
280             (
281                 GeometricField<Type, fvPatchField, volMesh>&,
282                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
283                 order=INTERPOLATE
284             ) const;
287             //- Interpolate volume field
288             template<class Type>
289             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
290             (
291                 const GeometricField<Type, fvPatchField, volMesh>&,
292                 order=INTERPOLATE
293             ) const;
295             template<class Type>
296             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
297             (
298                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
299                 order=INTERPOLATE
300             ) const;
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 } // End namespace Foam
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 #ifdef NoRepository
311 #   include "meshToMeshInterpolate.C"
312 #endif
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
316 #endif
318 // ************************************************************************* //