1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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/>.
28 mesh to mesh interpolation class.
32 calculateMeshToMeshAddressing.C
33 calculateMeshToMeshWeights.C
34 meshToMeshInterpolate.C
36 \*---------------------------------------------------------------------------*/
42 #include "HashTable.H"
43 #include "fvPatchMapper.H"
44 #include "scalarList.H"
45 #include "className.H"
46 #include "tolerancesSwitch.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 /*---------------------------------------------------------------------------*\
59 Class meshToMesh Declaration
60 \*---------------------------------------------------------------------------*/
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_;
81 HashTable<word> patchMap_;
83 //- toMesh patch labels which cut the from-mesh
84 HashTable<label> cuttingPatches_;
87 labelList cellAddressing_;
89 //- Boundary addressing
90 labelListList boundaryAddressing_;
92 //- Inverse-distance interpolation weights
93 mutable scalarListList* inverseDistanceWeightsPtr_;
96 // Private Member Functions
100 //- Return addressing
104 const pointField& points,
105 const fvMesh& fromMesh,
106 const List<bool>& boundaryCell,
107 const octree<octreeDataCell>& oc,
108 bool forceFind = false
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;
134 // Declare name of the class and its debug switch
135 ClassName("meshToMesh");
138 //- Enumeration specifying required accuracy
143 CELL_POINT_INTERPOLATE
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
154 const fvMesh& fromMesh,
155 const fvMesh& toMesh,
156 const HashTable<word>& patchMap,
157 const wordList& cuttingPatchNames
160 //- Construct from the two meshes assuming there is an exact mapping
161 // between the patches
164 const fvMesh& fromMesh,
173 //- Patch-field interpolation class
174 class patchFieldInterpolator
176 public fvPatchFieldMapper
178 const labelList& directAddressing_;
184 //- Construct given addressing
185 patchFieldInterpolator(const labelList& addr)
187 directAddressing_(addr)
193 virtual ~patchFieldInterpolator()
199 virtual label size() const
201 return directAddressing_.size();
204 virtual label sizeBeforeMapping() const
206 return directAddressing_.size();
209 virtual bool direct() const
214 const labelList& directAddressing() const
216 return directAddressing_;
225 const fvMesh& fromMesh() const
230 const fvMesh& toMesh() const
235 //- From toMesh cells to fromMesh cells
236 const labelList& cellAddressing() const
238 return cellAddressing_;
252 //- Interpolate field using inverse-distance weights
254 void interpolateField
257 const GeometricField<Type, fvPatchField, volMesh>&,
258 const labelList& adr,
259 const scalarListList& weights
262 //- Interpolate field using cell-point interpolation
264 void interpolateField
267 const GeometricField<Type, fvPatchField, volMesh>&,
268 const labelList& adr,
269 const vectorField& centres
273 //- Interpolate internal volume field
275 void interpolateInternalField
278 const GeometricField<Type, fvPatchField, volMesh>&,
283 void interpolateInternalField
286 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
291 //- Interpolate volume field
295 GeometricField<Type, fvPatchField, volMesh>&,
296 const GeometricField<Type, fvPatchField, volMesh>&,
303 GeometricField<Type, fvPatchField, volMesh>&,
304 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
309 //- Interpolate volume field
311 tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
313 const GeometricField<Type, fvPatchField, volMesh>&,
318 tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
320 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
328 } // End namespace Foam
330 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
333 # include "meshToMeshInterpolate.C"
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 // ************************************************************************* //