FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::meshToMesh
00026 
00027 Description
00028     mesh to mesh interpolation class.
00029 
00030 SourceFiles
00031     meshToMesh.C
00032     calculateMeshToMeshAddressing.C
00033     calculateMeshToMeshWeights.C
00034     meshToMeshInterpolate.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef meshtoMesh_H
00039 #define meshtoMesh_H
00040 
00041 #include <finiteVolume/fvMesh.H>
00042 #include <OpenFOAM/HashTable.H>
00043 #include <finiteVolume/fvPatchMapper.H>
00044 #include <OpenFOAM/scalarList.H>
00045 #include <OpenFOAM/className.H>
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 template<class Type>
00053 class octree;
00054 
00055 class octreeDataCell;
00056 
00057 /*---------------------------------------------------------------------------*\
00058                            Class meshToMesh Declaration
00059 \*---------------------------------------------------------------------------*/
00060 
00061 class meshToMesh
00062 {
00063     // Private data
00064 
00065         // mesh references
00066 
00067         const fvMesh& fromMesh_;
00068         const fvMesh& toMesh_;
00069 
00070         //- fromMesh patch labels
00071         HashTable<label> fromMeshPatches_;
00072 
00073         //- toMesh patch labels
00074         HashTable<label> toMeshPatches_;
00075 
00076         //- Patch map
00077         HashTable<word> patchMap_;
00078 
00079         //- toMesh patch labels which cut the from-mesh
00080         HashTable<label> cuttingPatches_;
00081 
00082         //- Cell addressing
00083         labelList cellAddressing_;
00084 
00085         //- Boundary addressing
00086         labelListList boundaryAddressing_;
00087 
00088         //- Inverse-distance interpolation weights
00089         mutable scalarListList* inverseDistanceWeightsPtr_;
00090 
00091 
00092     // Private Member Functions
00093 
00094         void calcAddressing();
00095 
00096         void cellAddresses
00097         (
00098             labelList& cells,
00099             const pointField& points,
00100             const fvMesh& fromMesh,
00101             const List<bool>& boundaryCell,
00102             const octree<octreeDataCell>& oc
00103         ) const;
00104 
00105         void calculateInverseDistanceWeights() const;
00106 
00107         const scalarListList& inverseDistanceWeights() const;
00108 
00109 
00110     // Private static data members
00111 
00112         //- Direct hit tolerance
00113         static const scalar directHitTol;
00114 
00115 
00116 public:
00117 
00118     // Declare name of the class and its debug switch
00119     ClassName("meshToMesh");
00120 
00121 
00122     //- Enumeration specifying required accuracy
00123     enum order
00124     {
00125         MAP,
00126         INTERPOLATE,
00127         CELL_POINT_INTERPOLATE
00128     };
00129 
00130 
00131     // Constructors
00132 
00133         //- Construct from the two meshes, the patch name map for the patches
00134         //  to be interpolated and the names of the toMesh-patches which
00135         //  cut the fromMesh
00136         meshToMesh
00137         (
00138             const fvMesh& fromMesh,
00139             const fvMesh& toMesh,
00140             const HashTable<word>& patchMap,
00141             const wordList& cuttingPatchNames
00142         );
00143 
00144         //- Construct from the two meshes assuming there is an exact mapping
00145         //  between the patches
00146         meshToMesh
00147         (
00148             const fvMesh& fromMesh,
00149             const fvMesh& toMesh
00150         );
00151 
00152 
00153     // Destructor
00154 
00155         ~meshToMesh();
00156 
00157 
00158     //- Patch-field interpolation class
00159     class patchFieldInterpolator
00160     :
00161         public fvPatchFieldMapper
00162     {
00163         const labelList& directAddressing_;
00164 
00165     public:
00166 
00167         // Constructors
00168 
00169             //- Construct given addressing
00170             patchFieldInterpolator(const labelList& addr)
00171             :
00172                 directAddressing_(addr)
00173             {}
00174 
00175 
00176         // Destructor
00177 
00178             virtual ~patchFieldInterpolator()
00179             {}
00180 
00181 
00182         // Member Functions
00183 
00184             label size() const
00185             {
00186                 return directAddressing_.size();
00187             }
00188 
00189             bool direct() const
00190             {
00191                 return true;
00192             }
00193 
00194             const labelList& directAddressing() const
00195             {
00196                 return directAddressing_;
00197             }
00198     };
00199 
00200 
00201     // Member Functions
00202 
00203         // Access
00204 
00205             const fvMesh& fromMesh() const
00206             {
00207                 return fromMesh_;
00208             }
00209  
00210             const fvMesh& toMesh() const
00211             {
00212                 return toMesh_;
00213             }
00214 
00215             //- From toMesh cells to fromMesh cells
00216             const labelList& cellAddressing() const
00217             {
00218                 return cellAddressing_;
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 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines