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

fvMesh.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open So
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::fvMesh
00027 
00028 Description
00029     Mesh data needed to do the Finite Volume discretisation.
00030 
00031     NOTE ON USAGE:
00032     fvMesh contains all the topological and geometric information
00033     related to the mesh.  It is also responsible for keeping the data
00034     up-to-date.  This is done by deleting the cell volume, face area,
00035     cell/face centre, addressing and other derived information as
00036     required and recalculating it as necessary.  The fvMesh therefore
00037     reserves the right to delete the derived information upon every
00038     topological (mesh refinement/morphing) or geometric change (mesh
00039     motion).  It is therefore unsafe to keep local references to the
00040     derived data outside of the time loop.
00041 
00042 SourceFiles
00043     fvMesh.C
00044     fvMeshGeometry.C
00045 
00046 \*---------------------------------------------------------------------------*/
00047 
00048 #ifndef fvMesh_H
00049 #define fvMesh_H
00050 
00051 #include "polyMesh.H"
00052 #include "lduMesh.H"
00053 #include "primitiveMesh.H"
00054 #include "fvBoundaryMesh.H"
00055 #include "surfaceInterpolation.H"
00056 #include "DimensionedField.H"
00057 #include "volFieldsFwd.H"
00058 #include "surfaceFieldsFwd.H"
00059 #include "pointFieldsFwd.H"
00060 #include "slicedVolFieldsFwd.H"
00061 #include "slicedSurfaceFieldsFwd.H"
00062 #include "className.H"
00063 
00064 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00065 
00066 namespace Foam
00067 {
00068 
00069 class fvMeshLduAddressing;
00070 class volMesh;
00071 
00072 
00073 /*---------------------------------------------------------------------------*\
00074                            Class fvMesh Declaration
00075 \*---------------------------------------------------------------------------*/
00076 
00077 class fvMesh
00078 :
00079     public polyMesh,
00080     public lduMesh,
00081     public surfaceInterpolation
00082 {
00083     // Private data
00084 
00085         //- Boundary mesh
00086         fvBoundaryMesh boundary_;
00087 
00088 
00089     // Demand-driven data
00090 
00091         mutable fvMeshLduAddressing* lduPtr_;
00092 
00093         //- Current time index for cell volumes
00094         //  Note.  The whole mechanism will be replaced once the
00095         //  dimensionedField is created and the dimensionedField
00096         //  will take care of the old-time levels.
00097         mutable label curTimeIndex_;
00098 
00099         //- Cell volumes old time level
00100         mutable void* VPtr_;
00101 
00102         //- Cell volumes old time level
00103         mutable DimensionedField<scalar, volMesh>* V0Ptr_;
00104 
00105         //- Cell volumes old-old time level
00106         mutable DimensionedField<scalar, volMesh>* V00Ptr_;
00107 
00108         //- Face area vectors
00109         mutable slicedSurfaceVectorField* SfPtr_;
00110 
00111         //- Mag face area vectors
00112         mutable surfaceScalarField* magSfPtr_;
00113 
00114         //- Cell centres
00115         mutable slicedVolVectorField* CPtr_;
00116 
00117         //- Face centres
00118         mutable slicedSurfaceVectorField* CfPtr_;
00119 
00120         //- Face motion fluxes
00121         mutable surfaceScalarField* phiPtr_;
00122 
00123 
00124     // Private Member Functions
00125 
00126         // Storage management
00127 
00128             //- Clear geometry but not the old-time cell volumes
00129             void clearGeomNotOldVol();
00130 
00131             //- Clear geometry
00132             void clearGeom();
00133 
00134             //- Clear addressing
00135             void clearAddressing();
00136 
00137 
00138        // Make geometric data
00139 
00140             void makeSf() const;
00141             void makeMagSf() const;
00142 
00143             void makeC() const;
00144             void makeCf() const;
00145 
00146 
00147         //- Disallow construct as copy
00148         fvMesh(const fvMesh&);
00149 
00150         //- Disallow assignment
00151         void operator=(const fvMesh&);
00152 
00153 
00154 public:
00155 
00156     // Public typedefs
00157 
00158         typedef fvMesh Mesh;
00159         typedef fvBoundaryMesh BoundaryMesh;
00160 
00161 
00162     // Declare name of the class and its debug switch
00163     ClassName("fvMesh");
00164 
00165 
00166     // Constructors
00167 
00168         //- Construct from IOobject
00169         explicit fvMesh(const IOobject& io);
00170 
00171         //- Construct from components without boundary.
00172         //  Boundary is added using addFvPatches() member function
00173         fvMesh
00174         (
00175             const IOobject& io,
00176             const Xfer<pointField>& points,
00177             const Xfer<faceList>& faces,
00178             const Xfer<labelList>& allOwner,
00179             const Xfer<labelList>& allNeighbour,
00180             const bool syncPar = true
00181         );
00182 
00183         //- Construct without boundary from cells rather than owner/neighbour.
00184         //  Boundary is added using addPatches() member function
00185         fvMesh
00186         (
00187             const IOobject& io,
00188             const Xfer<pointField>& points,
00189             const Xfer<faceList>& faces,
00190             const Xfer<cellList>& cells,
00191             const bool syncPar = true
00192         );
00193 
00194 
00195     // Destructor
00196 
00197         virtual ~fvMesh();
00198 
00199 
00200     // Member Functions
00201 
00202         // Helpers
00203 
00204             //- Add boundary patches. Constructor helper
00205             void addFvPatches
00206             (
00207                 const List<polyPatch*>&,
00208                 const bool validBoundary = true
00209             );
00210 
00211             //- Update the mesh based on the mesh files saved in time
00212             //  directories
00213             virtual readUpdateState readUpdate();
00214 
00215 
00216         // Access
00217 
00218             //- Return the top-level database
00219             const Time& time() const
00220             {
00221                 return polyMesh::time();
00222             }
00223 
00224             //- Return the object registry - resolve conflict polyMesh/lduMesh
00225             virtual const objectRegistry& thisDb() const
00226             {
00227                 return polyMesh::thisDb();
00228             }
00229 
00230             //- Return reference to name
00231             //  Note: name() is currently ambiguous due to derivation from
00232             //  surfaceInterpolation
00233             const word& name() const
00234             {
00235                 return polyMesh::name();
00236             }
00237 
00238             //- Return reference to boundary mesh
00239             const fvBoundaryMesh& boundary() const;
00240 
00241             //- Return ldu addressing
00242             virtual const lduAddressing& lduAddr() const;
00243 
00244             //- Return a list of pointers for each patch
00245             //  with only those pointing to interfaces being set
00246             virtual lduInterfacePtrsList interfaces() const
00247             {
00248                 return boundary().interfaces();
00249             }
00250 
00251             //- Internal face owner
00252             const unallocLabelList& owner() const
00253             {
00254                 return lduAddr().lowerAddr();
00255             }
00256 
00257             //- Internal face neighbour
00258             const unallocLabelList& neighbour() const
00259             {
00260                 return lduAddr().upperAddr();
00261             }
00262 
00263             //- Return cell volumes
00264             const DimensionedField<scalar, volMesh>& V() const;
00265 
00266             //- Return old-time cell volumes
00267             const DimensionedField<scalar, volMesh>& V0() const;
00268 
00269             //- Return old-old-time cell volumes
00270             const DimensionedField<scalar, volMesh>& V00() const;
00271 
00272             //- Return cell face area vectors
00273             const surfaceVectorField& Sf() const;
00274 
00275             //- Return cell face area magnitudes
00276             const surfaceScalarField& magSf() const;
00277 
00278             //- Return cell face motion fluxes
00279             const surfaceScalarField& phi() const;
00280 
00281             //- Return cell centres as volVectorField
00282             const volVectorField& C() const;
00283 
00284             //- Return face centres as surfaceVectorField
00285             const surfaceVectorField& Cf() const;
00286 
00287 
00288         // Edit
00289 
00290             //- Clear all geometry and addressing
00291             void clearOut();
00292 
00293             //- Update mesh corresponding to the given map
00294             virtual void updateMesh(const mapPolyMesh& mpm);
00295 
00296             //- Move points, returns volumes swept by faces in motion
00297             virtual tmp<scalarField> movePoints(const pointField&);
00298 
00299             //- Map all fields in time using given map.
00300             virtual void mapFields(const mapPolyMesh& mpm);
00301 
00302             //- Remove boundary patches. Warning: fvPatchFields hold ref to
00303             //  these fvPatches.
00304             void removeFvBoundary();
00305 
00306             //- Return cell face motion fluxes
00307             surfaceScalarField& setPhi();
00308 
00309             //- Return old-time cell volumes
00310             DimensionedField<scalar, volMesh>& setV0();
00311 
00312 
00313         // Write
00314 
00315             //- Write the underlying polyMesh and other data
00316             virtual bool writeObjects
00317             (
00318                 IOstream::streamFormat fmt,
00319                 IOstream::versionNumber ver,
00320                 IOstream::compressionType cmp
00321             ) const;
00322 
00323             //- Write mesh using IO settings from time
00324             virtual bool write() const;
00325 
00326 
00327     // Member Operators
00328 
00329         bool operator!=(const fvMesh&) const;
00330         bool operator==(const fvMesh&) const;
00331 };
00332 
00333 
00334 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00335 
00336 } // End namespace Foam
00337 
00338 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00339 
00340 #ifdef NoRepository
00341 #   include "fvPatchFvMeshTemplates.C"
00342 #endif
00343 
00344 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00345 
00346 #endif
00347 
00348 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd