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

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