OpenFOAM logo
Open Source CFD Toolkit

polyMesh.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     polyMesh
00027 
00028 Description
00029     Mesh consisting of general polyhedral cells.
00030 
00031 SourceFiles
00032     polyMesh.C
00033     polyMeshCalcFaceCells.C
00034     polyMeshClear.C
00035     polyMeshCorrectFaceDirections.C
00036     polyMeshCreate.C
00037     polyMeshIO.C
00038     polyMeshPurgePolygons.C
00039     polyMeshShapeMeshTools.C
00040 
00041 \*---------------------------------------------------------------------------*/
00042 
00043 #ifndef polyMesh_H
00044 #define polyMesh_H
00045 
00046 #include "objectRegistry.H"
00047 #include "primitiveMesh.H"
00048 #include "pointField.H"
00049 #include "faceList.H"
00050 #include "cellList.H"
00051 #include "cellShapeList.H"
00052 #include "pointIOField.H"
00053 #include "faceIOList.H"
00054 #include "labelIOList.H"
00055 #include "polyBoundaryMesh.H"
00056 #include "pointZoneMesh.H"
00057 #include "faceZoneMesh.H"
00058 #include "cellZoneMesh.H"
00059 
00060 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00061 
00062 namespace Foam
00063 {
00064 
00065 class parallelInfo;
00066 class mapPolyMesh;
00067 
00068 /*---------------------------------------------------------------------------*\
00069                           Class polyMesh Declaration
00070 \*---------------------------------------------------------------------------*/
00071 
00072 class polyMesh
00073 :
00074     public objectRegistry,
00075     public primitiveMesh
00076 {
00077 
00078 public:
00079 
00080     // Public data types
00081 
00082         //- Enumeration defining the state of the mesh after a read update.
00083         //  Used for post-processing applications, where the mesh
00084         //  needs to update based on the files written in time
00085         //  directores
00086         enum readUpdateState
00087         {
00088             UNCHANGED,
00089             POINTS_MOVED,
00090             TOPO_CHANGE,
00091             TOPO_PATCH_CHANGE
00092         };
00093 
00094 
00095 private:
00096 
00097     // Permanent data
00098 
00099         // Primitive mesh data
00100 
00101             //- Points
00102             pointIOField points_;
00103 
00104             //- Faces
00105             faceIOList faces_;
00106 
00107             //- Face owner
00108             labelIOList allOwner_;
00109 
00110             //- Face neighbour
00111             labelIOList allNeighbour_;
00112 
00113             //- Boundary mesh
00114             mutable polyBoundaryMesh boundary_;
00115 
00116 
00117         // Zoning information
00118 
00119             //- Point zones
00120             pointZoneMesh pointZones_;
00121 
00122             //- Face zones
00123             faceZoneMesh faceZones_;
00124 
00125             //- Cell zones
00126             cellZoneMesh cellZones_;
00127 
00128 
00129         //- Parallel info
00130         mutable parallelInfo* parallelDataPtr_;
00131 
00132 
00133         // Mesh motion related data
00134 
00135             //- Is the mesh moving
00136             bool moving_;
00137 
00138             //- Current time index for mesh motion
00139             mutable label curMotionTimeIndex_;
00140 
00141             //- Old points (for the last mesh motion)
00142             mutable pointField* oldPointsPtr_;
00143 
00144 
00145     // Private member functions
00146 
00147         //- Disallow construct as copy
00148         polyMesh(const polyMesh&);
00149 
00150         //- Disallow default bitwise assignment
00151         void operator=(const polyMesh&);
00152 
00153         //- Initialise the polyMesh from the primitive data
00154         void initMesh();
00155 
00156         //- Initialise the polyMesh from the given set of cells
00157         void initMesh(cellList& c);
00158 
00159         //- Calculate the cell shapes from the primitive
00160         //  polyhedral information
00161         void calcCellShapes() const;
00162 
00163 
00164         // Helper functions for constructor from cell shapes
00165     
00166             labelListList cellShapePointCells(const cellShapeList&) const;
00167 
00168             labelList facePatchFaceCells
00169             (
00170                 const faceList& patchFaces,
00171                 const labelListList& pointCells,
00172                 const faceListList& cellsFaceShapes,
00173                 const label patchID
00174             ) const;
00175 
00176 
00177 public:
00178 
00179     //- Runtime type information
00180     TypeName("polyMesh");
00181 
00182     //- Return the default region name
00183     static word defaultRegion;
00184 
00185     //- Return the mesh sub-directory name (usually "polyMesh")
00186     static word meshSubDir;
00187 
00188 
00189     // Constructors
00190 
00191         //- Construct from IOobject
00192         explicit polyMesh(const IOobject& io);
00193 
00194         //- Construct from components without boundary.
00195         //  Boundary is added using addPatches() member function
00196         polyMesh
00197         (
00198             const IOobject& io,
00199             const pointField& points,
00200             const faceList& faces,
00201             const cellList& cells
00202         );
00203 
00204         //- Construct from cell shapes
00205         polyMesh
00206         (
00207             const IOobject& io,
00208             const pointField& points,
00209             const cellShapeList& shapes,
00210             const faceListList& boundaryFaces,
00211             const wordList& boundaryPatchNames,
00212             const wordList& boundaryPatchTypes,
00213             const word& defaultBoundaryPatchType,
00214             const wordList& boundaryPatchPhysicalTypes
00215         );
00216 
00217 
00218     // Destructor
00219 
00220         virtual ~polyMesh();
00221 
00222 
00223     // Member Functions
00224 
00225         // Database
00226 
00227             //- Over-ride the objectRegistry dbDir
00228             //  if this is single-region case
00229             virtual const fileName& dbDir() const;
00230 
00231             //- Return the local mesh directory (dbDir()/meshSubDir)
00232             fileName meshDir() const;
00233 
00234             //- Return the current instance directory for points
00235             //  Used in the consruction of gemometric mesh data dependent
00236             //  on points
00237             const fileName& pointsInstance() const;
00238 
00239             //- Return the current instance directory for faces
00240             const fileName& facesInstance() const;
00241 
00242             //- Set the instance for mesh files
00243             void setInstance(const fileName&);
00244 
00245 
00246         // Access
00247 
00248             //- Return raw points
00249             const pointField& allPoints() const;
00250 
00251             //- Return raw faces
00252             const faceList& allFaces() const;
00253 
00254             //- Return old mesh motion points
00255             const pointField& oldAllPoints() const;
00256 
00257             //- Return face owner
00258             const labelList& allOwner() const;
00259 
00260             //- Return face neighbour
00261             const labelList& allNeighbour() const;
00262 
00263             //- Return boundary mesh
00264             const polyBoundaryMesh& boundaryMesh() const
00265             {
00266                 return boundary_;
00267             }
00268 
00269             //- Return point zone mesh
00270             const pointZoneMesh& pointZones() const
00271             {
00272                 return pointZones_;
00273             }
00274 
00275             //- Return face zone mesh
00276             const faceZoneMesh& faceZones() const
00277             {
00278                 return faceZones_;
00279             }
00280 
00281             //- Return cell zone mesh
00282             const cellZoneMesh& cellZones() const
00283             {
00284                 return cellZones_;
00285             }
00286 
00287 
00288             //- Return parallel info
00289             const parallelInfo& parallelData() const;
00290 
00291 
00292         // Mesh motion
00293 
00294             //- Is mesh moving
00295             bool moving() const
00296             {
00297                 return moving_;
00298             }
00299 
00300             //- Move points, returns volumes swept by faces in motion
00301             virtual tmp<scalarField> movePoints(const pointField&);
00302 
00303             //- Reset motion
00304             void resetMotion() const;
00305 
00306 
00307         // Topological change
00308 
00309             //- Return non-const access to the pointZones
00310             pointZoneMesh& pointZones()
00311             {
00312                 return pointZones_;
00313             }
00314 
00315             //- Return non-const access to the faceZones
00316             faceZoneMesh& faceZones()
00317             {
00318                 return faceZones_;
00319             }
00320 
00321             //- Return non-const access to the cellZones
00322             cellZoneMesh& cellZones()
00323             {
00324                 return cellZones_;
00325             }
00326 
00327             //- Add boundary patches
00328             void addPatches(const List<polyPatch*>&);
00329 
00330             //- Add mesh zones
00331             void addZones
00332             (
00333                 const List<pointZone*>& pz,
00334                 const List<faceZone*>& fz,
00335                 const List<cellZone*>& cz
00336             );
00337 
00338             //- Update the mesh based on the mesh files saved in
00339             //  time directories
00340             virtual readUpdateState readUpdate();
00341 
00342             //- Update the mesh corresponding to given map
00343             virtual void updateMesh(const mapPolyMesh& mpm);
00344 
00345             //- Remove boundary patches
00346             void removeBoundary();
00347 
00348             //- Reset mesh primitive data. Assumes all patch info correct
00349             //  (so does e.g. parallel communication). If not use
00350             //  validBoundary=false
00351             //  (still assumes patchStarts[0] = nInternalFaces and last
00352             //  patch ends at nActiveFaces) and change patches with addPatches.
00353             void resetPrimitives
00354             (
00355                 const label nUsedFaces,
00356                 const pointField& allPoints,
00357                 const faceList& allFaces,
00358                 const labelList& allOwner,
00359                 const labelList& allNeighbour,
00360                 const labelList& patchSizes,
00361                 const labelList& patchStarts,
00362                 const bool validBoundary = true
00363             );
00364 
00365 
00366         //  Storage management
00367 
00368             //- Clear geometry
00369             void clearGeom();
00370 
00371             //- Clear addressing
00372             void clearAddressing();
00373 
00374             //- Clear all geometry and addressing unnecessary for CFD
00375             void clearOut();
00376 
00377             //- Clear primitive data (points, faces and cells)
00378             void clearPrimitives();
00379 
00380             //- Remove all files
00381             void removeFiles(const fileName& dir) const;
00382 };
00383 
00384 
00385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00386 
00387 } // End namespace Foam
00388 
00389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00390 
00391 #endif
00392 
00393 // ************************************************************************* //
For further information go to www.openfoam.org