OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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     Foam::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 "HashTable.H"
00044 #include "fvPatchMapper.H"
00045 #include "scalarList.H"
00046 #include "className.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 template<class Type>
00054 class octree;
00055 
00056 class octreeDataCell;
00057 
00058 /*---------------------------------------------------------------------------*\
00059                            Class meshToMesh Declaration
00060 \*---------------------------------------------------------------------------*/
00061 
00062 class meshToMesh
00063 {
00064     // Private data
00065 
00066         // mesh references
00067 
00068         const fvMesh& fromMesh_;
00069         const fvMesh& toMesh_;
00070 
00071         //- fromMesh patch labels
00072         HashTable<label> fromMeshPatches_;
00073 
00074         //- toMesh patch labels
00075         HashTable<label> toMeshPatches_;
00076 
00077         //- Patch map
00078         HashTable<word> patchMap_;
00079 
00080         //- toMesh patch labels which cut the from-mesh
00081         HashTable<label> cuttingPatches_;
00082 
00083         //- Cell addressing
00084         labelList cellAddressing_;
00085 
00086         //- Boundary addressing
00087         labelListList boundaryAddressing_;
00088 
00089         //- Inverse-distance interpolation weights
00090         mutable scalarListList* inverseDistanceWeightsPtr_;
00091 
00092 
00093     // Private Member Functions
00094 
00095         void calcAddressing();
00096 
00097         void cellAddresses
00098         (
00099             labelList& cells,
00100             const pointField& points,
00101             const fvMesh& fromMesh,
00102             const List<bool>& boundaryCell,
00103             const octree<octreeDataCell>& oc
00104         ) const;
00105 
00106         void calculateInverseDistanceWeights() const;
00107 
00108         const scalarListList& inverseDistanceWeights() const;
00109 
00110 
00111     // Private static data members
00112 
00113         //- Direct hit tolerance
00114         static const scalar directHitTol;
00115 
00116 
00117 public:
00118 
00119     // Declare name of the class and its debug switch
00120     ClassName("meshToMesh");
00121 
00122 
00123     //- Enumeration specifying required accuracy
00124     enum order
00125     {
00126         MAP,
00127         INTERPOLATE,
00128         CELL_POINT_INTERPOLATE
00129     };
00130 
00131 
00132     // Constructors
00133 
00134         //- Construct from the two meshes, the patch name map for the patches
00135         //  to be interpolated and the names of the toMesh-patches which
00136         //  cut the fromMesh
00137         meshToMesh
00138         (
00139             const fvMesh& fromMesh,
00140             const fvMesh& toMesh,
00141             const HashTable<word>& patchMap,
00142             const wordList& cuttingPatchNames
00143         );
00144 
00145         //- Construct from the two meshes assuming there is an exact mapping
00146         //  between the patches
00147         meshToMesh
00148         (
00149             const fvMesh& fromMesh,
00150             const fvMesh& toMesh
00151         );
00152 
00153 
00154     // Destructor
00155 
00156         ~meshToMesh();
00157 
00158 
00159     //- Patch-field interpolation class
00160     class patchFieldInterpolator
00161     :
00162         public fvPatchFieldMapper
00163     {
00164         const labelList& directAddressing_;
00165 
00166     public:
00167 
00168         // Constructors
00169 
00170             //- Construct given addressing
00171             patchFieldInterpolator(const labelList& addr)
00172             :
00173                 directAddressing_(addr)
00174             {}
00175 
00176 
00177         // Destructor
00178 
00179             virtual ~patchFieldInterpolator()
00180             {}
00181 
00182 
00183         // Member Functions
00184 
00185             label size() const
00186             {
00187                 return directAddressing_.size();
00188             }
00189 
00190             bool direct() const
00191             {
00192                 return true;
00193             }
00194 
00195             const labelList& directAddressing() const
00196             {
00197                 return directAddressing_;
00198             }
00199     };
00200 
00201 
00202     // Member Functions
00203 
00204         // Access
00205 
00206             const fvMesh& fromMesh() const
00207             {
00208                 return fromMesh_;
00209             }
00210  
00211             const fvMesh& toMesh() const
00212             {
00213                 return toMesh_;
00214             }
00215 
00216             //- From toMesh cells to fromMesh cells
00217             const labelList& cellAddressing() const
00218             {
00219                 return cellAddressing_;
00220             }
00221 
00222         // Interpolation
00223 
00224             //- Map field
00225             template<class Type>
00226             void mapField
00227             (
00228                 Field<Type>&,
00229                 const Field<Type>&,
00230                 const labelList& adr
00231             ) const;
00232 
00233             //- Interpolate field using inverse-distance weights
00234             template<class Type>
00235             void interpolateField
00236             (
00237                 Field<Type>&,
00238                 const GeometricField<Type, fvPatchField, volMesh>&,
00239                 const labelList& adr,
00240                 const scalarListList& weights
00241             ) const;
00242 
00243             //- Interpolate field using cell-point interpolation
00244             template<class Type>
00245             void interpolateField
00246             (
00247                 Field<Type>&,
00248                 const GeometricField<Type, fvPatchField, volMesh>&,
00249                 const labelList& adr,
00250                 const vectorField& centres
00251             ) const;
00252 
00253 
00254             //- Interpolate internal volume field
00255             template<class Type>
00256             void interpolateInternalField
00257             (
00258                 Field<Type>&,
00259                 const GeometricField<Type, fvPatchField, volMesh>&,
00260                 order=INTERPOLATE
00261             ) const;
00262 
00263             template<class Type>
00264             void interpolateInternalField
00265             (
00266                 Field<Type>&,
00267                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
00268                 order=INTERPOLATE
00269             ) const;
00270 
00271 
00272             //- Interpolate volume field
00273             template<class Type>
00274             void interpolate
00275             (
00276                 GeometricField<Type, fvPatchField, volMesh>&,
00277                 const GeometricField<Type, fvPatchField, volMesh>&,
00278                 order=INTERPOLATE
00279             ) const;
00280 
00281             template<class Type>
00282             void interpolate
00283             (
00284                 GeometricField<Type, fvPatchField, volMesh>&,
00285                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
00286                 order=INTERPOLATE
00287             ) const;
00288 
00289 
00290             //- Interpolate volume field
00291             template<class Type>
00292             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
00293             (
00294                 const GeometricField<Type, fvPatchField, volMesh>&,
00295                 order=INTERPOLATE
00296             ) const;
00297 
00298             template<class Type>
00299             tmp<GeometricField<Type, fvPatchField, volMesh> > interpolate
00300             (
00301                 const tmp<GeometricField<Type, fvPatchField, volMesh> >&,
00302                 order=INTERPOLATE
00303             ) const;
00304 };
00305 
00306 
00307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00308 
00309 } // End namespace Foam
00310 
00311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00312 
00313 #ifdef NoRepository
00314 #   include "meshToMeshInterpolate.C"
00315 #endif
00316 
00317 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00318 
00319 #endif
00320 
00321 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd