OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide 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-2009 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     Foam::polyMesh
00027 
00028 Description
00029     Mesh consisting of general polyhedral cells.
00030 
00031 SourceFiles
00032     polyMesh.C
00033     polyMeshInitMesh.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 owner_;
00108 
00109             //- Face neighbour
00110             labelIOList neighbour_;
00111 
00112             //- Have the primitives been cleared
00113             bool clearedPrimitives_;
00114 
00115 
00116             //- Boundary mesh
00117             mutable polyBoundaryMesh boundary_;
00118 
00119             //- Mesh bounding-box.
00120             //  Created from points on construction, updated when the mesh moves
00121             boundBox bounds_;
00122 
00123             //- vector of non-constrained directions in mesh
00124             //  defined according to the presence of empty and wedge patches
00125             mutable Vector<label> geometricD_;
00126 
00127             //- vector of valid directions in mesh
00128             //  defined according to the presence of empty patches
00129             mutable Vector<label> solutionD_;
00130 
00131 
00132         // Zoning information
00133 
00134             //- Point zones
00135             pointZoneMesh pointZones_;
00136 
00137             //- Face zones
00138             faceZoneMesh faceZones_;
00139 
00140             //- Cell zones
00141             cellZoneMesh cellZones_;
00142 
00143 
00144         //- Parallel info
00145         mutable globalMeshData* globalMeshDataPtr_;
00146 
00147 
00148         // Mesh motion related data
00149 
00150             //- Is the mesh moving
00151             bool moving_;
00152 
00153             //- Is the mesh changing (moving and/or topology changing)
00154             bool changing_;
00155 
00156             //- Current time index for mesh motion
00157             mutable label curMotionTimeIndex_;
00158 
00159             //- Old points (for the last mesh motion)
00160             mutable pointField* oldPointsPtr_;
00161 
00162 
00163     // Private member functions
00164 
00165         //- Disallow construct as copy
00166         polyMesh(const polyMesh&);
00167 
00168         //- Disallow default bitwise assignment
00169         void operator=(const polyMesh&);
00170 
00171         //- Initialise the polyMesh from the primitive data
00172         void initMesh();
00173 
00174         //- Initialise the polyMesh from the given set of cells
00175         void initMesh(cellList& c);
00176 
00177         //- Calculate the valid directions in the mesh from the boundaries
00178         void calcDirections() const;
00179 
00180         //- Calculate the cell shapes from the primitive
00181         //  polyhedral information
00182         void calcCellShapes() const;
00183 
00184 
00185         // Helper functions for constructor from cell shapes
00186 
00187             labelListList cellShapePointCells(const cellShapeList&) const;
00188 
00189             labelList facePatchFaceCells
00190             (
00191                 const faceList& patchFaces,
00192                 const labelListList& pointCells,
00193                 const faceListList& cellsFaceShapes,
00194                 const label patchID
00195             ) const;
00196 
00197 
00198 public:
00199 
00200     // Public typedefs
00201 
00202         typedef polyMesh Mesh;
00203         typedef polyBoundaryMesh BoundaryMesh;
00204 
00205 
00206     //- Runtime type information
00207     TypeName("polyMesh");
00208 
00209     //- Return the default region name
00210     static word defaultRegion;
00211 
00212     //- Return the mesh sub-directory name (usually "polyMesh")
00213     static word meshSubDir;
00214 
00215 
00216     // Constructors
00217 
00218         //- Construct from IOobject
00219         explicit polyMesh(const IOobject& io);
00220 
00221         //- Construct without boundary from components.
00222         //  Boundary is added using addPatches() member function
00223         polyMesh
00224         (
00225             const IOobject& io,
00226             const Xfer<pointField>& points,
00227             const Xfer<faceList>& faces,
00228             const Xfer<labelList>& owner,
00229             const Xfer<labelList>& neighbour,
00230             const bool syncPar = true
00231         );
00232 
00233         //- Construct without boundary with cells rather than owner/neighbour.
00234         //  Boundary is added using addPatches() member function
00235         polyMesh
00236         (
00237             const IOobject& io,
00238             const Xfer<pointField>& points,
00239             const Xfer<faceList>& faces,
00240             const Xfer<cellList>& cells,
00241             const bool syncPar = true
00242         );
00243 
00244         //- Construct from cell shapes
00245         polyMesh
00246         (
00247             const IOobject& io,
00248             const Xfer<pointField>& points,
00249             const cellShapeList& shapes,
00250             const faceListList& boundaryFaces,
00251             const wordList& boundaryPatchNames,
00252             const wordList& boundaryPatchTypes,
00253             const word& defaultBoundaryPatchName,
00254             const word& defaultBoundaryPatchType,
00255             const wordList& boundaryPatchPhysicalTypes,
00256             const bool syncPar = true
00257         );
00258 
00259 
00260     // Destructor
00261 
00262         virtual ~polyMesh();
00263 
00264 
00265     // Member Functions
00266 
00267         // Database
00268 
00269             //- Override the objectRegistry dbDir for a single-region case
00270             virtual const fileName& dbDir() const;
00271 
00272             //- Return the local mesh directory (dbDir()/meshSubDir)
00273             fileName meshDir() const;
00274 
00275             //- Return the current instance directory for points
00276             //  Used in the consruction of gemometric mesh data dependent
00277             //  on points
00278             const fileName& pointsInstance() const;
00279 
00280             //- Return the current instance directory for faces
00281             const fileName& facesInstance() const;
00282 
00283             //- Set the instance for mesh files
00284             void setInstance(const fileName&);
00285 
00286 
00287         // Access
00288 
00289             //- Return raw points
00290             virtual const pointField& points() const;
00291 
00292             //- Return raw faces
00293             virtual const faceList& faces() const;
00294 
00295             //- Return face owner
00296             virtual const labelList& faceOwner() const;
00297 
00298             //- Return face neighbour
00299             virtual const labelList& faceNeighbour() const;
00300 
00301             //- Return old points for mesh motion
00302             virtual const pointField& oldPoints() const;
00303 
00304             //- Return boundary mesh
00305             const polyBoundaryMesh& boundaryMesh() const
00306             {
00307                 return boundary_;
00308             }
00309 
00310             //- Return mesh bounding box
00311             const boundBox& bounds() const
00312             {
00313                 return bounds_;
00314             }
00315 
00316             //- Return the vector of geometric directions in mesh.
00317             //  Defined according to the presence of empty and wedge patches.
00318             //  1 indicates unconstrained direction and -1 a constrained
00319             //  direction.
00320             const Vector<label>& geometricD() const;
00321 
00322             //- Return the number of valid geometric dimensions in the mesh
00323             label nGeometricD() const;
00324 
00325             //- Return the vector of solved-for directions in mesh.
00326             //  Differs from geometricD in that it includes for wedge cases
00327             //  the circumferential direction in case of swirl.
00328             //  1 indicates valid direction and -1 an invalid direction.
00329             const Vector<label>& solutionD() const;
00330 
00331             //- Return the number of valid solved-for dimensions in the mesh
00332             label nSolutionD() const;
00333 
00334             //- Return point zone mesh
00335             const pointZoneMesh& pointZones() const
00336             {
00337                 return pointZones_;
00338             }
00339 
00340             //- Return face zone mesh
00341             const faceZoneMesh& faceZones() const
00342             {
00343                 return faceZones_;
00344             }
00345 
00346             //- Return cell zone mesh
00347             const cellZoneMesh& cellZones() const
00348             {
00349                 return cellZones_;
00350             }
00351 
00352             //- Return parallel info
00353             const globalMeshData& globalData() const;
00354 
00355             //- Return the object registry
00356             const objectRegistry& thisDb() const
00357             {
00358                 return *this;
00359             }
00360 
00361         // Mesh motion
00362 
00363             //- Is mesh moving
00364             bool moving() const
00365             {
00366                 return moving_;
00367             }
00368 
00369             //- Set the mesh to be moving
00370             bool moving(const bool m)
00371             {
00372                 bool m0 = moving_;
00373                 moving_ = m;
00374                 changing_ = changing_ || moving_;
00375                 return m0;
00376             }
00377 
00378             //- Is mesh changing (topology changing and/or moving)
00379             bool changing() const
00380             {
00381                 return changing_;
00382             }
00383 
00384             //- Set the mesh to be changing
00385             bool changing(const bool c)
00386             {
00387                 bool c0 = changing_;
00388                 changing_ = c;
00389                 return c0;
00390             }
00391 
00392             //- Move points, returns volumes swept by faces in motion
00393             virtual tmp<scalarField> movePoints(const pointField&);
00394 
00395             //- Reset motion
00396             void resetMotion() const;
00397 
00398 
00399         // Topological change
00400 
00401             //- Return non-const access to the pointZones
00402             pointZoneMesh& pointZones()
00403             {
00404                 return pointZones_;
00405             }
00406 
00407             //- Return non-const access to the faceZones
00408             faceZoneMesh& faceZones()
00409             {
00410                 return faceZones_;
00411             }
00412 
00413             //- Return non-const access to the cellZones
00414             cellZoneMesh& cellZones()
00415             {
00416                 return cellZones_;
00417             }
00418 
00419             //- Add boundary patches
00420             void addPatches
00421             (
00422                 const List<polyPatch*>&,
00423                 const bool validBoundary = true
00424             );
00425 
00426             //- Add mesh zones
00427             void addZones
00428             (
00429                 const List<pointZone*>& pz,
00430                 const List<faceZone*>& fz,
00431                 const List<cellZone*>& cz
00432             );
00433 
00434             //- Update the mesh based on the mesh files saved in
00435             //  time directories
00436             virtual readUpdateState readUpdate();
00437 
00438             //- Update the mesh corresponding to given map
00439             virtual void updateMesh(const mapPolyMesh& mpm);
00440 
00441             //- Remove boundary patches
00442             void removeBoundary();
00443 
00444             //- Reset mesh primitive data. Assumes all patch info correct
00445             //  (so does e.g. parallel communication). If not use
00446             //  validBoundary=false
00447             //  (still assumes patchStarts[0] = nInternalFaces and last
00448             //  patch ends at nActiveFaces) and change patches with addPatches.
00449             void resetPrimitives
00450             (
00451                 const Xfer<pointField>& points,
00452                 const Xfer<faceList>& faces,
00453                 const Xfer<labelList>& owner,
00454                 const Xfer<labelList>& neighbour,
00455                 const labelList& patchSizes,
00456                 const labelList& patchStarts,
00457                 const bool validBoundary = true
00458             );
00459 
00460 
00461         //  Storage management
00462 
00463             //- Clear geometry
00464             void clearGeom();
00465 
00466             //- Clear addressing
00467             void clearAddressing();
00468 
00469             //- Clear all geometry and addressing unnecessary for CFD
00470             void clearOut();
00471 
00472             //- Clear primitive data (points, faces and cells)
00473             void clearPrimitives();
00474 
00475             //- Remove all files from mesh instance
00476             void removeFiles(const fileName& instanceDir) const;
00477 
00478             //- Remove all files from mesh instance()
00479             void removeFiles() const;
00480 };
00481 
00482 
00483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00484 
00485 } // End namespace Foam
00486 
00487 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00488 
00489 #endif
00490 
00491 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd