OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

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