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

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