1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
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
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/>.
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"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 /*---------------------------------------------------------------------------*\
58 Class meshToMesh Declaration
59 \*---------------------------------------------------------------------------*/
67 const fvMesh& fromMesh_;
68 const fvMesh& toMesh_;
70 //- fromMesh patch labels
71 HashTable<label> fromMeshPatches_;
73 //- toMesh patch labels
74 HashTable<label> toMeshPatches_;
77 HashTable<word> patchMap_;
79 //- toMesh patch labels which cut the from-mesh
80 HashTable<label> cuttingPatches_;
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();
99 const pointField& points,
100 const fvMesh& fromMesh,
101 const List<bool>& boundaryCell,
102 const indexedOctree<treeDataCell>& oc
105 void calculateInverseDistanceWeights() const;
107 const scalarListList& inverseDistanceWeights() const;
110 // Private static data members
112 //- Direct hit tolerance
113 static const scalar directHitTol;
118 // Declare name of the class and its debug switch
119 ClassName("meshToMesh");
122 //- Enumeration specifying required accuracy
127 CELL_POINT_INTERPOLATE
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
138 const fvMesh& fromMesh,
139 const fvMesh& toMesh,
140 const HashTable<word>& patchMap,
141 const wordList& cuttingPatchNames
144 //- Construct from the two meshes assuming there is an exact mapping
145 // between the patches
148 const fvMesh& fromMesh,
157 //- Patch-field interpolation class
158 class patchFieldInterpolator
160 public fvPatchFieldMapper
162 const labelList& directAddressing_;
168 //- Construct given addressing
169 patchFieldInterpolator(const labelList& addr)
171 directAddressing_(addr)
176 virtual ~patchFieldInterpolator()
184 return directAddressing_.size();
192 const labelList& directAddressing() const
194 return directAddressing_;
203 const fvMesh& fromMesh() const
208 const fvMesh& toMesh() const
213 //- From toMesh cells to fromMesh cells
214 const labelList& cellAddressing() const
216 return cellAddressing_;
230 //- Interpolate field using inverse-distance weights
232 void interpolateField
235 const GeometricField<Type, fvPatchField, volMesh>&,
236 const labelList& adr,
237 const scalarListList& weights
240 //- Interpolate field using cell-point interpolation
242 void interpolateField
245 const GeometricField<Type, fvPatchField, volMesh>&,
246 const labelList& adr,
247 const vectorField& centres
251 //- Interpolate internal volume field
253 void interpolateInternalField
256 const GeometricField<Type, fvPatchField, volMesh>&,
261 void interpolateInternalField
264 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
269 //- Interpolate volume field
273 GeometricField<Type, fvPatchField, volMesh>&,
274 const GeometricField<Type, fvPatchField, volMesh>&,
281 GeometricField<Type, fvPatchField, volMesh>&,
282 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
287 //- Interpolate volume field
289 tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
291 const GeometricField<Type, fvPatchField, volMesh>&,
296 tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
298 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
306 } // End namespace Foam
308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
311 # include "meshToMeshInterpolate.C"
314 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 // ************************************************************************* //