1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Mesh consisting of general polyhedral cells.
34 polyMeshFromShapeMesh.C
39 \*---------------------------------------------------------------------------*/
44 #include "objectRegistry.H"
45 #include "primitiveMesh.H"
46 #include "pointField.H"
49 #include "cellShapeList.H"
50 #include "pointIOField.H"
51 #include "faceIOList.H"
52 #include "labelIOList.H"
53 #include "polyBoundaryMesh.H"
55 #include "pointZoneMesh.H"
56 #include "faceZoneMesh.H"
57 #include "cellZoneMesh.H"
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 class polyMeshTetDecomposition;
68 /*---------------------------------------------------------------------------*\
69 Class polyMesh Declaration
70 \*---------------------------------------------------------------------------*/
74 public objectRegistry,
82 //- Enumeration defining the state of the mesh after a read update.
83 // Used for post-processing applications, where the mesh
84 // needs to update based on the files written in time
99 // Primitive mesh data
102 pointIOField points_;
105 faceCompactIOList faces_;
111 labelIOList neighbour_;
113 //- Have the primitives been cleared
114 bool clearedPrimitives_;
118 mutable polyBoundaryMesh boundary_;
120 //- Mesh bounding-box.
121 // Created from points on construction, updated when the mesh moves
124 //- vector of non-constrained directions in mesh
125 // defined according to the presence of empty and wedge patches
126 mutable Vector<label> geometricD_;
128 //- vector of valid directions in mesh
129 // defined according to the presence of empty patches
130 mutable Vector<label> solutionD_;
132 //- Base point for face decomposition into tets
133 mutable labelList* tetBasePtIsPtr_;
136 // Zoning information
139 pointZoneMesh pointZones_;
142 faceZoneMesh faceZones_;
145 cellZoneMesh cellZones_;
149 mutable globalMeshData* globalMeshDataPtr_;
152 // Mesh motion related data
154 //- Is the mesh moving
157 //- Is the mesh changing (moving and/or topology changing)
160 //- Current time index for mesh motion
161 mutable label curMotionTimeIndex_;
163 //- Old points (for the last mesh motion)
164 mutable pointField* oldPointsPtr_;
167 // Private Member Functions
169 //- Disallow construct as copy
170 polyMesh(const polyMesh&);
172 //- Disallow default bitwise assignment
173 void operator=(const polyMesh&);
175 //- Initialise the polyMesh from the primitive data
178 //- Initialise the polyMesh from the given set of cells
179 void initMesh(cellList& c);
181 //- Calculate the valid directions in the mesh from the boundaries
182 void calcDirections() const;
184 //- Calculate the cell shapes from the primitive
185 // polyhedral information
186 void calcCellShapes() const;
189 // Helper functions for constructor from cell shapes
191 labelListList cellShapePointCells(const cellShapeList&) const;
193 labelList facePatchFaceCells
195 const faceList& patchFaces,
196 const labelListList& pointCells,
197 const faceListList& cellsFaceShapes,
203 const cellShapeList& cellsAsShapes,
204 const faceListList& boundaryFaces,
205 const wordList& boundaryPatchNames,
206 labelList& patchSizes,
207 labelList& patchStarts,
208 label& defaultPatchStart,
219 typedef polyMesh Mesh;
220 typedef polyBoundaryMesh BoundaryMesh;
223 //- Runtime type information
224 TypeName("polyMesh");
226 //- Return the default region name
227 static word defaultRegion;
229 //- Return the mesh sub-directory name (usually "polyMesh")
230 static word meshSubDir;
235 //- Construct from IOobject
236 explicit polyMesh(const IOobject& io);
238 //- Construct without boundary from components.
239 // Boundary is added using addPatches() member function
243 const Xfer<pointField>& points,
244 const Xfer<faceList>& faces,
245 const Xfer<labelList>& owner,
246 const Xfer<labelList>& neighbour,
247 const bool syncPar = true
250 //- Construct without boundary with cells rather than owner/neighbour.
251 // Boundary is added using addPatches() member function
255 const Xfer<pointField>& points,
256 const Xfer<faceList>& faces,
257 const Xfer<cellList>& cells,
258 const bool syncPar = true
261 //- Construct from cell shapes
265 const Xfer<pointField>& points,
266 const cellShapeList& shapes,
267 const faceListList& boundaryFaces,
268 const wordList& boundaryPatchNames,
269 const wordList& boundaryPatchTypes,
270 const word& defaultBoundaryPatchName,
271 const word& defaultBoundaryPatchType,
272 const wordList& boundaryPatchPhysicalTypes,
273 const bool syncPar = true
276 //- Construct from cell shapes with patch information in dictionary
281 const Xfer<pointField>& points,
282 const cellShapeList& shapes,
283 const faceListList& boundaryFaces,
284 const wordList& boundaryPatchNames,
285 const PtrList<dictionary>& boundaryDicts,
286 const word& defaultBoundaryPatchName,
287 const word& defaultBoundaryPatchType,
288 const bool syncPar = true
300 //- Override the objectRegistry dbDir for a single-region case
301 virtual const fileName& dbDir() const;
303 //- Return the local mesh directory (dbDir()/meshSubDir)
304 fileName meshDir() const;
306 //- Return the current instance directory for points
307 // Used in the consruction of gemometric mesh data dependent
309 const fileName& pointsInstance() const;
311 //- Return the current instance directory for faces
312 const fileName& facesInstance() const;
314 //- Set the instance for mesh files
315 void setInstance(const fileName&);
320 //- Return raw points
321 virtual const pointField& points() const;
324 virtual const faceList& faces() const;
326 //- Return face owner
327 virtual const labelList& faceOwner() const;
329 //- Return face neighbour
330 virtual const labelList& faceNeighbour() const;
332 //- Return old points for mesh motion
333 virtual const pointField& oldPoints() const;
335 //- Return boundary mesh
336 const polyBoundaryMesh& boundaryMesh() const
341 //- Return mesh bounding box
342 const boundBox& bounds() const
347 //- Return the vector of geometric directions in mesh.
348 // Defined according to the presence of empty and wedge patches.
349 // 1 indicates unconstrained direction and -1 a constrained
351 const Vector<label>& geometricD() const;
353 //- Return the number of valid geometric dimensions in the mesh
354 label nGeometricD() const;
356 //- Return the vector of solved-for directions in mesh.
357 // Differs from geometricD in that it includes for wedge cases
358 // the circumferential direction in case of swirl.
359 // 1 indicates valid direction and -1 an invalid direction.
360 const Vector<label>& solutionD() const;
362 //- Return the number of valid solved-for dimensions in the mesh
363 label nSolutionD() const;
365 //- Return the tetBasePtIs
366 const labelList& tetBasePtIs() const;
368 //- Return point zone mesh
369 const pointZoneMesh& pointZones() const
374 //- Return face zone mesh
375 const faceZoneMesh& faceZones() const
380 //- Return cell zone mesh
381 const cellZoneMesh& cellZones() const
386 //- Return parallel info
387 const globalMeshData& globalData() const;
389 //- Return the object registry
390 const objectRegistry& thisDb() const
404 //- Set the mesh to be moving
405 bool moving(const bool m)
409 changing_ = changing_ || moving_;
413 //- Is mesh changing (topology changing and/or moving)
414 bool changing() const
419 //- Set the mesh to be changing
420 bool changing(const bool c)
427 //- Move points, returns volumes swept by faces in motion
428 virtual tmp<scalarField> movePoints(const pointField&);
431 void resetMotion() const;
434 // Topological change
436 //- Return non-const access to the pointZones
437 pointZoneMesh& pointZones()
442 //- Return non-const access to the faceZones
443 faceZoneMesh& faceZones()
448 //- Return non-const access to the cellZones
449 cellZoneMesh& cellZones()
454 //- Add boundary patches
457 const List<polyPatch*>&,
458 const bool validBoundary = true
464 const List<pointZone*>& pz,
465 const List<faceZone*>& fz,
466 const List<cellZone*>& cz
469 //- Update the mesh based on the mesh files saved in
471 virtual readUpdateState readUpdate();
473 //- Update the mesh corresponding to given map
474 virtual void updateMesh(const mapPolyMesh& mpm);
476 //- Remove boundary patches
477 void removeBoundary();
479 //- Reset mesh primitive data. Assumes all patch info correct
480 // (so does e.g. parallel communication). If not use
481 // validBoundary=false
484 const Xfer<pointField>& points,
485 const Xfer<faceList>& faces,
486 const Xfer<labelList>& owner,
487 const Xfer<labelList>& neighbour,
488 const labelList& patchSizes,
489 const labelList& patchStarts,
490 const bool validBoundary = true
494 // Storage management
500 void clearAddressing();
502 //- Clear all geometry and addressing unnecessary for CFD
505 //- Clear primitive data (points, faces and cells)
506 void clearPrimitives();
508 //- Remove all files from mesh instance
509 void removeFiles(const fileName& instanceDir) const;
511 //- Remove all files from mesh instance()
512 void removeFiles() const;
517 //- Find the cell, tetFaceI and tetPtI for the given position
526 //- Find the tetFaceI and tetPtI for the given position in
527 // the supplied cell, tetFaceI and tetPtI = -1 if not found
538 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
540 } // End namespace Foam
542 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
546 // ************************************************************************* //