OpenFOAM logo
Open Source CFD Toolkit

meshToMesh.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     meshToMesh
00027 
00028 Description
00029     mesh to mesh interpolation class.
00030 
00031 SourceFiles
00032     meshToMesh.C
00033     calculateMeshToMeshAddressing.C
00034     calculateMeshToMeshWeights.C
00035     meshToMeshInterpolate.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef meshtoMesh_H
00040 #define meshtoMesh_H
00041 
00042 #include "fvMesh.H"
00043 #include "pointMesh.H"
00044 #include "HashTable.H"
00045 #include "fvPatchMapper.H"
00046 #include "scalarList.H"
00047 #include "className.H"
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 template<class Type>
00055 class octree;
00056 
00057 class octreeDataCell;
00058 
00059 /*---------------------------------------------------------------------------*\
00060                            Class meshToMesh Declaration
00061 \*---------------------------------------------------------------------------*/
00062 
00063 class meshToMesh
00064 {
00065     // Private data
00066 
00067         // mesh references
00068 
00069         const fvMesh& fromMesh_;
00070         const fvMesh& toMesh_;
00071 
00072         //- fromMesh patch labels
00073         HashTable<label> fromMeshPatches_;
00074 
00075         //- toMesh patch labels
00076         HashTable<label> toMeshPatches_;
00077 
00078         //- Patch map
00079         HashTable<word> patchMap_;
00080 
00081         //- toMesh patch labels which cut the from-mesh
00082         HashTable<label> cuttingPatches_;
00083 
00084         //- Point mesh used for interpolation
00085         pointMesh fromPointMesh_;
00086 
00087         //- Cell addressing
00088         labelList cellAddressing_;
00089 
00090         //- Boundary addressing
00091         labelListList boundaryAddressing_;
00092 
00093         //- Inverse-distance interpolation weights
00094         mutable scalarListList* inverseDistanceWeightsPtr_;
00095 
00096 
00097     // Private Member Functions
00098 
00099         void calcAddressing();
00100 
00101         void cellAddresses
00102         (
00103             labelList& cells,
00104             const pointField& points,
00105             const fvMesh& fromMesh,
00106             const List<bool>& boundaryCell,
00107             const octree<octreeDataCell>& oc
00108         ) const;
00109 
00110         void calculateInverseDistanceWeights() const;
00111 
00112         const scalarListList& inverseDistanceWeights() const;
00113 
00114 
00115     // Private static data members
00116 
00117         //- Direct hit tolerance
00118         static const scalar directHitTol;
00119 
00120 
00121 public:
00122 
00123     // Declare name of the class and it's debug switch
00124     ClassName("meshToMesh");
00125 
00126 
00127     //- Enumeration specifying required accuracy
00128     enum order
00129     {
00130         MAP,
00131         INTERPOLATE,
00132         CELL_POINT_INTERPOLATE
00133     };
00134 
00135 
00136     // Constructors
00137 
00138         //- Construct from the two meshes, the patch name map for the patches
00139         //  to be interpolated and the names of the toMesh-patches which
00140         //  cut the fromMesh
00141         meshToMesh
00142         (
00143             const fvMesh& fromMesh,
00144             const fvMesh& toMesh,
00145             const HashTable<word>& patchMap,
00146             const wordList& cuttingPatchNames
00147         );
00148 
00149         //- Construct from the two meshes assuming there is an exact mapping
00150         //  between the patches
00151         meshToMesh
00152         (
00153             const fvMesh& fromMesh,
00154             const fvMesh& toMesh
00155         );
00156 
00157 
00158     // Destructor
00159 
00160         ~meshToMesh();
00161 
00162 
00163     //- Patch-field interpolation class
00164     class patchFieldInterpolator
00165     :
00166         public fvPatchFieldMapper
00167     {
00168         const labelList& directAddressing_;
00169 
00170     public:
00171 
00172         // Constructors
00173 
00174             //- Construct given addressing
00175             patchFieldInterpolator(const labelList& addr)
00176             :
00177                 directAddressing_(addr)
00178             {}
00179 
00180 
00181         // Destructor
00182 
00183             virtual ~patchFieldInterpolator()
00184             {}
00185 
00186 
00187         // Member Functions
00188 
00189             label size() const
00190             {
00191                 return directAddressing_.size();
00192             }
00193 
00194             bool direct() const
00195             {
00196                 return true;
00197             }
00198 
00199             const labelList& directAddressing() const
00200             {
00201                 return directAddressing_;
00202             }
00203     };
00204 
00205 
00206     // Member Functions
00207 
00208         // Access
00209 
00210             const fvMesh& fromMesh() const
00211             {
00212                 return fromMesh_;
00213             }
00214  
00215             const fvMesh& toMesh() const
00216             {
00217                 return toMesh_;
00218             }
00219 
00220 
00221         // Interpolation
00222 
00223             //- Map field
00224             template<class Type>
00225             void mapField
00226             (
00227                 Field<Type>&,
00228                 const Field<Type>&,
00229                 const labelList& adr
00230             ) const;
00231 
00232             //- Interpolate field using inverse-distance weights
00233             template<class Type>
00234             void interpolateField
00235             (
00236                 Field<Type>&,
00237                 const GeometricField<Type, fvPatchField, volMesh>&,
00238                 const labelList& adr,
00239                 const scalarListList& weights
00240             ) const;
00241 
00242             //- Interpolate field using cell-point interpolation
00243             template<class Type>
00244             void interpolateField
00245             (
00246                 Field<Type>&,
00247                 const GeometricField<Type, fvPatchField, volMesh>&,
00248                 const labelList& adr,
00249                 const vectorField& centres
00250             ) const;
00251 
00252 
00253             //- Interpolate internal volume field
00254             template<class Type>
00255             void interpolateInternalField
00256             (
00257                 Field<Type>&,
00258                 const GeometricField<Type, fvPatchField, volMesh>&,
00259                 order=INTERPOLATE
00260             ) const;
00261 
00262             template<class Type>
00263             void interpolateInternalField
00264             (
00265                 Field<Type>&,
00266                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
00267                 order=INTERPOLATE
00268             ) const;
00269 
00270 
00271             //- Interpolate volume field
00272             template<class Type>
00273             void interpolate
00274             (
00275                 GeometricField<Type, fvPatchField, volMesh>&,
00276                 const GeometricField<Type, fvPatchField, volMesh>&,
00277                 order=INTERPOLATE
00278             ) const;
00279 
00280             template<class Type>
00281             void interpolate
00282             (
00283                 GeometricField<Type, fvPatchField, volMesh>&,
00284                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
00285                 order=INTERPOLATE
00286             ) const;
00287 
00288 
00289             //- Interpolate volume field
00290             template<class Type>
00291             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
00292             (
00293                 const GeometricField<Type, fvPatchField, volMesh>&,
00294                 order=INTERPOLATE
00295             ) const;
00296 
00297             template<class Type>
00298             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
00299             (
00300                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
00301                 order=INTERPOLATE
00302             ) const;
00303 };
00304 
00305 
00306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00307 
00308 } // End namespace Foam
00309 
00310 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00311 
00312 #ifdef NoRepository
00313 #   include "meshToMeshInterpolate.C"
00314 #endif
00315 
00316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00317 
00318 #endif
00319 
00320 // ************************************************************************* //
For further information go to www.openfoam.org