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

fvMeshAdder.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::fvMeshAdder
00027 
00028 Description
00029     Adds two fvMeshes without using any polyMesh morphing.
00030     Uses fvMeshAdder.
00031 
00032 SourceFiles
00033     fvMeshAdder.C
00034     fvMeshAdderTemplates.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef fvMeshAdder_H
00039 #define fvMeshAdder_H
00040 
00041 #include "polyMeshAdder.H"
00042 #include "fvPatchFieldsFwd.H"
00043 #include "fvsPatchFieldsFwd.H"
00044 #include "fvPatchFieldMapper.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 // Forward declaration of classes
00052 class IOobject;
00053 class faceCoupleInfo;
00054 class IOobjectList;
00055 class fvMesh;
00056 class volMesh;
00057 class surfaceMesh;
00058 class mapAddedPolyMesh;
00059 
00060 /*---------------------------------------------------------------------------*\
00061                            Class fvMeshAdder Declaration
00062 \*---------------------------------------------------------------------------*/
00063 
00064 class fvMeshAdder
00065 :
00066     public polyMeshAdder
00067 {
00068 
00069 private:
00070 
00071 
00072     // Private class
00073 
00074     class directFvPatchFieldMapper
00075     :
00076         public fvPatchFieldMapper
00077     {
00078         // Private data
00079 
00080             const labelList& directAddressing_;
00081 
00082     public:
00083 
00084         // Constructors
00085 
00086             //- Construct from components
00087             directFvPatchFieldMapper(const labelList& directAddressing)
00088             :
00089                 fvPatchFieldMapper(),
00090                 directAddressing_(directAddressing)
00091             {}
00092 
00093 
00094         // Destructor
00095 
00096             virtual ~directFvPatchFieldMapper()
00097             {}
00098 
00099 
00100         // Member Functions
00101 
00102             label size() const
00103             {
00104                 return directAddressing_.size();
00105             }
00106 
00107             bool direct() const
00108             {
00109                 return true;
00110             }
00111 
00112             const unallocLabelList& directAddressing() const
00113             {
00114                 return directAddressing_;
00115             }
00116     };
00117 
00118 
00119     // Private Member Functions
00120 
00121         //- Calculate map from new patch faces to old patch faces. -1 where
00122         //  could not map.
00123         static labelList calcPatchMap
00124         (
00125             const label oldStart,
00126             const label oldSize,
00127             const labelList& oldToNew,
00128             const polyPatch& newPatch,
00129             const label unmappedIndex
00130         );
00131 
00132         //- Map from old to new according to map. Handles map = -1.
00133         template<class Type>
00134         static void map
00135         (
00136             const Field<Type>&,
00137             const labelList& map,
00138             Field<Type>&
00139         );
00140 
00141         //- Update single volField.
00142         template<class Type>
00143         static void MapVolField
00144         (
00145             const mapAddedPolyMesh& meshMap,
00146 
00147             GeometricField<Type, fvPatchField, volMesh>& fld,
00148             const GeometricField<Type, fvPatchField, volMesh>& fldToAdd
00149         );
00150 
00151         //- Update single surfaceField.
00152         template<class Type>
00153         static void MapSurfaceField
00154         (
00155             const mapAddedPolyMesh& meshMap,
00156 
00157             GeometricField<Type, fvsPatchField, surfaceMesh>& fld,
00158             const GeometricField<Type, fvsPatchField, surfaceMesh>& fldToAdd
00159         );
00160 
00161 public:
00162 
00163     // Member Functions
00164 
00165         //- Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
00166         static autoPtr<mapAddedPolyMesh> add
00167         (
00168             fvMesh& mesh0,
00169             const fvMesh& mesh1,
00170             const faceCoupleInfo& coupleInfo,
00171             const bool validBoundary = true
00172         );
00173 
00174         //- Map all volFields of Type
00175         template<class Type>
00176         static void MapVolFields
00177         (
00178             const mapAddedPolyMesh&,
00179             const fvMesh& mesh,
00180             const fvMesh& meshToAdd
00181         );
00182 
00183         //- Map all surfaceFields of Type
00184         template<class Type>
00185         static void MapSurfaceFields
00186         (
00187             const mapAddedPolyMesh&,
00188             const fvMesh& mesh,
00189             const fvMesh& meshToAdd
00190         );
00191 };
00192 
00193 
00194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00195 
00196 } // End namespace Foam
00197 
00198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00199 
00200 #ifdef NoRepository
00201 #   include "fvMeshAdderTemplates.C"
00202 #endif
00203 
00204 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00205 
00206 #endif
00207 
00208 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd