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

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