1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 mesh to mesh interpolation class.
33 calculateMeshToMeshAddressing.C
34 calculateMeshToMeshWeights.C
35 meshToMeshInterpolate.C
37 \*---------------------------------------------------------------------------*/
43 #include "HashTable.H"
44 #include "fvPatchMapper.H"
45 #include "scalarList.H"
46 #include "className.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 /*---------------------------------------------------------------------------*\
59 Class meshToMesh Declaration
60 \*---------------------------------------------------------------------------*/
68 const fvMesh& fromMesh_;
69 const fvMesh& toMesh_;
71 //- fromMesh patch labels
72 HashTable<label> fromMeshPatches_;
74 //- toMesh patch labels
75 HashTable<label> toMeshPatches_;
78 HashTable<word> patchMap_;
80 //- toMesh patch labels which cut the from-mesh
81 HashTable<label> cuttingPatches_;
84 labelList cellAddressing_;
86 //- Boundary addressing
87 labelListList boundaryAddressing_;
89 //- Inverse-distance interpolation weights
90 mutable scalarListList* inverseDistanceWeightsPtr_;
93 // Private Member Functions
95 void calcAddressing();
100 const pointField& points,
101 const fvMesh& fromMesh,
102 const List<bool>& boundaryCell,
103 const octree<octreeDataCell>& oc,
104 bool forceFind = false
107 void calculateInverseDistanceWeights() const;
109 const scalarListList& inverseDistanceWeights() const;
112 // Private static data members
114 //- Direct hit tolerance
115 static const scalar directHitTol;
117 //- Cell centre distance required to establish a hit
118 static const scalar cellCentreDistanceTol;
123 // Declare name of the class and its debug switch
124 ClassName("meshToMesh");
127 //- Enumeration specifying required accuracy
132 CELL_POINT_INTERPOLATE
138 //- Construct from the two meshes, the patch name map for the patches
139 // to be interpolated and the names of the toMesh-patches which
143 const fvMesh& fromMesh,
144 const fvMesh& toMesh,
145 const HashTable<word>& patchMap,
146 const wordList& cuttingPatchNames
149 //- Construct from the two meshes assuming there is an exact mapping
150 // between the patches
153 const fvMesh& fromMesh,
163 //- Patch-field interpolation class
164 class patchFieldInterpolator
166 public fvPatchFieldMapper
168 const labelList& directAddressing_;
174 //- Construct given addressing
175 patchFieldInterpolator(const labelList& addr)
177 directAddressing_(addr)
183 virtual ~patchFieldInterpolator()
189 virtual label size() const
191 return directAddressing_.size();
194 virtual label sizeBeforeMapping() const
196 return directAddressing_.size();
199 virtual bool direct() const
204 const labelList& directAddressing() const
206 return directAddressing_;
215 const fvMesh& fromMesh() const
220 const fvMesh& toMesh() const
225 //- From toMesh cells to fromMesh cells
226 const labelList& cellAddressing() const
228 return cellAddressing_;
242 //- Interpolate field using inverse-distance weights
244 void interpolateField
247 const GeometricField<Type, fvPatchField, volMesh>&,
248 const labelList& adr,
249 const scalarListList& weights
252 //- Interpolate field using cell-point interpolation
254 void interpolateField
257 const GeometricField<Type, fvPatchField, volMesh>&,
258 const labelList& adr,
259 const vectorField& centres
263 //- Interpolate internal volume field
265 void interpolateInternalField
268 const GeometricField<Type, fvPatchField, volMesh>&,
273 void interpolateInternalField
276 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
281 //- Interpolate volume field
285 GeometricField<Type, fvPatchField, volMesh>&,
286 const GeometricField<Type, fvPatchField, volMesh>&,
293 GeometricField<Type, fvPatchField, volMesh>&,
294 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
299 //- Interpolate volume field
301 tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
303 const GeometricField<Type, fvPatchField, volMesh>&,
308 tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
310 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 } // End namespace Foam
320 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
323 # include "meshToMeshInterpolate.C"
326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
330 // ************************************************************************* //