1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Mesh consisting of general polyhedral cells.
35 polyMeshFromShapeMesh.C
39 \*---------------------------------------------------------------------------*/
44 #include <OpenFOAM/objectRegistry.H>
45 #include <OpenFOAM/primitiveMesh.H>
46 #include <OpenFOAM/pointField.H>
47 #include <OpenFOAM/faceList.H>
48 #include <OpenFOAM/cellList.H>
49 #include <OpenFOAM/cellShapeList.H>
50 #include <OpenFOAM/pointIOField.H>
51 #include <OpenFOAM/faceIOList.H>
52 #include <OpenFOAM/labelIOList.H>
53 #include <OpenFOAM/polyBoundaryMesh.H>
54 #include <OpenFOAM/boundBox.H>
55 #include <OpenFOAM/pointZoneMesh.H>
56 #include <OpenFOAM/faceZoneMesh.H>
57 #include <OpenFOAM/cellZoneMesh.H>
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
67 /*---------------------------------------------------------------------------*\
68 Class polyMesh Declaration
69 \*---------------------------------------------------------------------------*/
73 public objectRegistry,
81 //- Enumeration defining the state of the mesh after a read update.
82 // Used for post-processing applications, where the mesh
83 // needs to update based on the files written in time
98 // Primitive mesh data
101 pointIOField points_;
110 labelIOList neighbour_;
112 //- Have the primitives been cleared
113 bool clearedPrimitives_;
117 mutable polyBoundaryMesh boundary_;
119 //- Mesh bounding-box.
120 // Created from points on construction, updated when the mesh moves
123 //- vector of non-constrained directions in mesh
124 // defined according to the presence of empty and wedge patches
125 mutable Vector<label> geometricD_;
127 //- vector of valid directions in mesh
128 // defined according to the presence of empty patches
129 mutable Vector<label> solutionD_;
132 // Zoning information
135 pointZoneMesh pointZones_;
138 faceZoneMesh faceZones_;
141 cellZoneMesh cellZones_;
145 mutable globalMeshData* globalMeshDataPtr_;
148 // Mesh motion related data
150 //- Is the mesh moving
153 //- Is the mesh changing (moving and/or topology changing)
156 //- Current time index for mesh motion
157 mutable label curMotionTimeIndex_;
159 //- Old points (for the last mesh motion)
160 mutable pointField* oldPointsPtr_;
163 // Private member functions
165 //- Disallow construct as copy
166 polyMesh(const polyMesh&);
168 //- Disallow default bitwise assignment
169 void operator=(const polyMesh&);
171 //- Initialise the polyMesh from the primitive data
174 //- Initialise the polyMesh from the given set of cells
175 void initMesh(cellList& c);
177 //- Calculate the valid directions in the mesh from the boundaries
178 void calcDirections() const;
180 //- Calculate the cell shapes from the primitive
181 // polyhedral information
182 void calcCellShapes() const;
185 // Helper functions for constructor from cell shapes
187 labelListList cellShapePointCells(const cellShapeList&) const;
189 labelList facePatchFaceCells
191 const faceList& patchFaces,
192 const labelListList& pointCells,
193 const faceListList& cellsFaceShapes,
202 typedef polyMesh Mesh;
203 typedef polyBoundaryMesh BoundaryMesh;
206 //- Runtime type information
207 TypeName("polyMesh");
209 //- Return the default region name
210 static word defaultRegion;
212 //- Return the mesh sub-directory name (usually "polyMesh")
213 static word meshSubDir;
218 //- Construct from IOobject
219 explicit polyMesh(const IOobject& io);
221 //- Construct without boundary from components.
222 // Boundary is added using addPatches() member function
226 const Xfer<pointField>& points,
227 const Xfer<faceList>& faces,
228 const Xfer<labelList>& owner,
229 const Xfer<labelList>& neighbour,
230 const bool syncPar = true
233 //- Construct without boundary with cells rather than owner/neighbour.
234 // Boundary is added using addPatches() member function
238 const Xfer<pointField>& points,
239 const Xfer<faceList>& faces,
240 const Xfer<cellList>& cells,
241 const bool syncPar = true
244 //- Construct from cell shapes
248 const Xfer<pointField>& points,
249 const cellShapeList& shapes,
250 const faceListList& boundaryFaces,
251 const wordList& boundaryPatchNames,
252 const wordList& boundaryPatchTypes,
253 const word& defaultBoundaryPatchName,
254 const word& defaultBoundaryPatchType,
255 const wordList& boundaryPatchPhysicalTypes,
256 const bool syncPar = true
269 //- Override the objectRegistry dbDir for a single-region case
270 virtual const fileName& dbDir() const;
272 //- Return the local mesh directory (dbDir()/meshSubDir)
273 fileName meshDir() const;
275 //- Return the current instance directory for points
276 // Used in the consruction of gemometric mesh data dependent
278 const fileName& pointsInstance() const;
280 //- Return the current instance directory for faces
281 const fileName& facesInstance() const;
283 //- Set the instance for mesh files
284 void setInstance(const fileName&);
289 //- Return raw points
290 virtual const pointField& points() const;
293 virtual const faceList& faces() const;
295 //- Return face owner
296 virtual const labelList& faceOwner() const;
298 //- Return face neighbour
299 virtual const labelList& faceNeighbour() const;
301 //- Return old points for mesh motion
302 virtual const pointField& oldPoints() const;
304 //- Return boundary mesh
305 const polyBoundaryMesh& boundaryMesh() const
310 //- Return mesh bounding box
311 const boundBox& bounds() const
316 //- Return the vector of geometric directions in mesh.
317 // Defined according to the presence of empty and wedge patches.
318 // 1 indicates unconstrained direction and -1 a constrained
320 const Vector<label>& geometricD() const;
322 //- Return the number of valid geometric dimensions in the mesh
323 label nGeometricD() const;
325 //- Return the vector of solved-for directions in mesh.
326 // Differs from geometricD in that it includes for wedge cases
327 // the circumferential direction in case of swirl.
328 // 1 indicates valid direction and -1 an invalid direction.
329 const Vector<label>& solutionD() const;
331 //- Return the number of valid solved-for dimensions in the mesh
332 label nSolutionD() const;
334 //- Return point zone mesh
335 const pointZoneMesh& pointZones() const
340 //- Return face zone mesh
341 const faceZoneMesh& faceZones() const
346 //- Return cell zone mesh
347 const cellZoneMesh& cellZones() const
352 //- Return parallel info
353 const globalMeshData& globalData() const;
355 //- Return the object registry
356 const objectRegistry& thisDb() const
369 //- Set the mesh to be moving
370 bool moving(const bool m)
374 changing_ = changing_ || moving_;
378 //- Is mesh changing (topology changing and/or moving)
379 bool changing() const
384 //- Set the mesh to be changing
385 bool changing(const bool c)
392 //- Move points, returns volumes swept by faces in motion
393 virtual tmp<scalarField> movePoints(const pointField&);
396 void resetMotion() const;
399 // Topological change
401 //- Return non-const access to the pointZones
402 pointZoneMesh& pointZones()
407 //- Return non-const access to the faceZones
408 faceZoneMesh& faceZones()
413 //- Return non-const access to the cellZones
414 cellZoneMesh& cellZones()
419 //- Add boundary patches
422 const List<polyPatch*>&,
423 const bool validBoundary = true
429 const List<pointZone*>& pz,
430 const List<faceZone*>& fz,
431 const List<cellZone*>& cz
434 //- Update the mesh based on the mesh files saved in
436 virtual readUpdateState readUpdate();
438 //- Update the mesh corresponding to given map
439 virtual void updateMesh(const mapPolyMesh& mpm);
441 //- Remove boundary patches
442 void removeBoundary();
444 //- Reset mesh primitive data. Assumes all patch info correct
445 // (so does e.g. parallel communication). If not use
446 // validBoundary=false
447 // (still assumes patchStarts[0] = nInternalFaces and last
448 // patch ends at nActiveFaces) and change patches with addPatches.
451 const Xfer<pointField>& points,
452 const Xfer<faceList>& faces,
453 const Xfer<labelList>& owner,
454 const Xfer<labelList>& neighbour,
455 const labelList& patchSizes,
456 const labelList& patchStarts,
457 const bool validBoundary = true
461 // Storage management
467 void clearAddressing();
469 //- Clear all geometry and addressing unnecessary for CFD
472 //- Clear primitive data (points, faces and cells)
473 void clearPrimitives();
475 //- Remove all files from mesh instance
476 void removeFiles(const fileName& instanceDir) const;
478 //- Remove all files from mesh instance()
479 void removeFiles() const;
483 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
485 } // End namespace Foam
487 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
491 // ************************ vim: set sw=4 sts=4 et: ************************ //