OpenFOAM logo
Open Source CFD Toolkit

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-2005 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 "primitiveMesh.H"
00053 #include "fvBoundaryMesh.H"
00054 #include "surfaceInterpolation.H"
00055 #include "scalarIOField.H"
00056 #include "volFieldsFwd.H"
00057 #include "surfaceFieldsFwd.H"
00058 #include "pointFieldsFwd.H"
00059 #include "slicedVolFieldsFwd.H"
00060 #include "slicedSurfaceFieldsFwd.H"
00061 #include "lduAddressing.H"
00062 #include "className.H"
00063 
00064 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00065 
00066 namespace Foam
00067 {
00068 
00069 class fvMeshLduAddressing;
00070 
00071 /*---------------------------------------------------------------------------*\
00072                            Class fvMesh Declaration
00073 \*---------------------------------------------------------------------------*/
00074 
00075 class fvMesh
00076 :
00077     public polyMesh,
00078     public surfaceInterpolation
00079 {
00080     // Private data
00081 
00082         //- Boundary mesh
00083         fvBoundaryMesh boundary_;
00084 
00085         //- vector of valid directions in mesh
00086         //  defined according to the presence of empty patches
00087         Vector<label> directions_;
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 scalarIOField* V0Ptr_;
00102 
00103         //- Cell volumes old-old time level
00104         mutable scalarIOField* V00Ptr_;
00105 
00106         //- Face area vectors
00107         mutable slicedSurfaceVectorField* SfPtr_;
00108 
00109         //- Mag face area vectors
00110         mutable surfaceScalarField* magSfPtr_;
00111 
00112         //- Cell centres
00113         mutable slicedVolVectorField* CPtr_;
00114 
00115         //- Face centres
00116         mutable slicedSurfaceVectorField* CfPtr_;
00117 
00118         //- Face motion fluxes
00119         mutable surfaceScalarField* phiPtr_;
00120 
00121 
00122     // Private Member Functions
00123 
00124         // Storage management
00125 
00126             //- Clear geometry but not the cell volumes
00127             void clearGeomNotVol();
00128 
00129             //- Clear geometry
00130             void clearGeom();
00131 
00132             //- Clear addressing
00133             void clearAddressing();
00134 
00135             //- Clear all geometry and addressing
00136             void clearOut();
00137 
00138 
00139        // Make geometric data
00140 
00141             Vector<label> makeDirections();
00142             void makeSf() const;
00143             void makeMagSf() const;
00144             void makePhi() const;
00145 
00146             void makeC() const;
00147             void makeCf() const;
00148 
00149 
00150         //- Disallow construct as copy
00151         fvMesh(const fvMesh&);
00152 
00153         //- Disallow assignment
00154         void operator=(const fvMesh&);
00155 
00156 
00157 public:
00158 
00159     // Public typedefs
00160 
00161         typedef fvMesh Mesh;
00162         typedef fvBoundaryMesh BoundaryMesh;
00163 
00164 
00165     // Declare name of the class and it's debug switch
00166     ClassName("fvMesh");
00167 
00168 
00169     // Constructors
00170 
00171         //- Construct from IOobject
00172         explicit fvMesh(const IOobject& io);
00173 
00174         //- Construct from components without boundary.
00175         //  Boundary is added using addFvPatches() member function
00176         fvMesh
00177         (
00178             const IOobject& io,
00179             const pointField& points,
00180             const faceList& faces,
00181             const cellList& cells
00182         );
00183 
00184 
00185     // Destructor
00186 
00187         virtual ~fvMesh();
00188 
00189 
00190     // Member Functions
00191 
00192         // Helpers
00193 
00194             //- Add boundary patches. Constructor helper
00195             void addFvPatches(const List<polyPatch*>&);
00196 
00197             //- Update the mesh based on the mesh files saved in time
00198             //  directories
00199             virtual readUpdateState readUpdate();
00200 
00201 
00202         // Access
00203 
00204             //- Return reference to DB
00205             const Time& time() const
00206             {
00207                 return polyMesh::time();
00208             }
00209 
00210             //- Return reference to name 
00211             //  Note: name() is currently ambiguous due to derivation from
00212             //  surfaceInterpolation
00213             const word& name() const
00214             {
00215                 return polyMesh::name();
00216             }
00217 
00218             //- Return reference to boundary mesh
00219             const fvBoundaryMesh& boundary() const;
00220 
00221             //- Return the vector of valid directions in mesh
00222             //  defined according to the presence of empty patches
00223             const Vector<label>& directions() const
00224             {
00225                 return directions_;
00226             }
00227 
00228             //- Return the number of valid dimensions in the mesh
00229             label nD() const
00230             {
00231                 return cmptSum(directions_ + Vector<label>::one)/2;
00232             }
00233 
00234 
00235             //- Return ldu addressing
00236             const lduAddressing& ldu() const;
00237 
00238             //- Internal face owner
00239             const unallocLabelList& owner() const
00240             {
00241                 return ldu().lowerAddr();
00242             }
00243 
00244             //- Internal face neighbour
00245             const unallocLabelList& neighbour() const
00246             {
00247                 return ldu().upperAddr();
00248             }
00249 
00250 
00251             //- Return cell volumes
00252             const scalarField& V() const;
00253 
00254             //- Return old-time cell volumes
00255             const scalarField& V0() const;
00256 
00257             //- Return old-old-time cell volumes
00258             const scalarField& V00() const;
00259 
00260             //- Return cell face area vectors
00261             const surfaceVectorField& Sf() const;
00262 
00263             //- Return cell face area magnitudes
00264             const surfaceScalarField& magSf() const;
00265 
00266             //- Return cell face motion fluxes
00267             const surfaceScalarField& phi() const;
00268 
00269             //- Return cell centres as volVectorField
00270             const volVectorField& C() const;
00271 
00272             //- Return face centres as surfaceVectorField
00273             const surfaceVectorField& Cf() const;
00274 
00275 
00276         // Edit
00277 
00278             //- Construct all optional data and clear basic info from basicMesh
00279             void constructAndClear() const;
00280 
00281             //- Update mesh corresponding to the given map
00282             virtual void updateMesh(const mapPolyMesh& mpm);
00283 
00284             //- Move points, returns volumes swept by faces in motion
00285             virtual tmp<scalarField> movePoints(const vectorField&);
00286 
00287             //- Map all fields in time using given map.
00288             virtual void mapFields(const mapPolyMesh& mpm);
00289 
00290             //- Remove boundary patches. Warning: fvPatchFields hold ref to
00291             //  these fvPatches.
00292             void removeFvBoundary();
00293 
00294             //- Return cell face motion fluxes
00295             surfaceScalarField& setPhi();
00296 
00297             //- Return old-time cell volumes
00298             scalarField& setV0();
00299 
00300 
00301         // Write
00302 
00303             //- Write the underlying polyMesh and other data
00304             virtual bool write
00305             (
00306                 IOstream::streamFormat fmt,
00307                 IOstream::versionNumber ver,
00308                 IOstream::compressionType cmp
00309             ) const;
00310 
00311             //- Write mesh using IO settings from time
00312             virtual bool write() const;
00313 
00314 
00315     // Member Operators
00316 
00317         bool operator!=(const fvMesh&) const;
00318         bool operator==(const fvMesh&) const;
00319 };
00320 
00321 
00322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00323 
00324 } // End namespace Foam
00325 
00326 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00327 
00328 #endif
00329 
00330 // ************************************************************************* //
For further information go to www.openfoam.org