cartesianMeshExtractor.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh 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 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "cartesianMeshExtractor.H"
29 #include "meshOctree.H"
30 
31 // #define DEBUGSearch
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
41 {
43 }
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 // Construct from octree and mesh data
49 (
50  meshOctree& octree,
51  const IOdictionary& meshDict,
53 )
54 :
55  octreeCheck_(octree, meshDict, false),
56  mesh_(mesh),
57  decomposeSplitHexes_(false),
58  leafCellLabelPtr_(new labelList(octree.numberOfLeaves(), -1))
59 {
60 }
61 
62 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
63 
65 {
66  clearOut();
67 }
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
72 {
73  decomposeSplitHexes_ = true;
74 }
75 
77 {
78  Info << "Extracting polyMesh" << endl;
79 
80  //- create points and pointLeaves addressing
82 
83  //- create the mesh
85 
86  //- decompose split-hex cells into tetrahedra and pyramids
88 
89  //- remove unused vertices
91 
92  Info << "Mesh has :" << nl
93  << mesh_.points().size() << " vertices " << nl
94  << mesh_.faces().size() << " faces" << nl
95  << mesh_.cells().size() << " cells" << endl;
96 
97  if( Pstream::parRun() )
98  {
99  label nCells = mesh_.cells().size();
100  reduce(nCells, sumOp<label>());
101  Info << "Total number of cells " << nCells << endl;
102  }
103  if( mesh_.cells().size() == 0 )
104  {
106  (
107  "void cartesianMeshExtractor::createMesh()"
108  ) << "There are no cells in the mesh!"
109  << nl << "The reasons for this can be fwofold:"
110  << nl << "1. Inadequate mesh resolution."
111  << nl << "2. You maxCellSize is a multiplier of the domain length."
112  << " This can be reolved by reducing the maxCellSize by a fraction."
113  << "i.e. 2.49999 instead of 2.5." << exit(FatalError);
114  }
115 
116  Info << "Finished extracting polyMesh" << endl;
117 }
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 } // End namespace Foam
122 
123 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids
void decomposeSplitHexesIntoTetsAndPyramids()
decompose split hexes into pyramids and tets
Definition: cartesianMeshExtractorDecomposeSplitHexes.C:43
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyMeshGenPoints::points
const pointFieldPMG & points() const
access to points
Definition: polyMeshGenPointsI.H:44
cartesianMeshExtractor.H
Foam::cartesianMeshExtractor::decomposeSplitHexes
void decomposeSplitHexes()
decompose split hexes into standard cells
Definition: cartesianMeshExtractor.C:71
meshOctree.H
Foam::polyMeshGenFaces::faces
const faceListPMG & faces() const
access to faces
Definition: polyMeshGenFacesI.H:43
Foam::cartesianMeshExtractor::createPolyMesh
void createPolyMesh()
create mesh data
Definition: cartesianMeshExtractorPolyMesh.C:51
Foam::meshOctree::numberOfLeaves
label numberOfLeaves() const
return leaves of the octree
Definition: meshOctreeI.H:48
Foam::cartesianMeshExtractor::cartesianMeshExtractor
cartesianMeshExtractor(const cartesianMeshExtractor &)
Disallow default bitwise copy construct.
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
Foam::cartesianMeshExtractor::clearOut
void clearOut()
delete all freestore data
Definition: cartesianMeshExtractor.C:40
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::cartesianMeshExtractor::decomposeSplitHexes_
bool decomposeSplitHexes_
decompose split hex cells
Definition: cartesianMeshExtractor.H:61
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::polyMeshGenCells::cells
const cellListPMG & cells() const
access to cells
Definition: polyMeshGenCellsI.H:39
Foam::pointFieldPMG::size
label size() const
return the number of used elements
Definition: pointFieldPMGI.H:71
Foam::cartesianMeshExtractor::leafCellLabelPtr_
labelList * leafCellLabelPtr_
cell label for a given leaf
Definition: cartesianMeshExtractor.H:64
Foam::polyMeshGenModifier::removeUnusedVertices
void removeUnusedVertices()
remove unused vertices
Definition: polyMeshGenModifierRemoveUnusedVertices.C:37
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::cartesianMeshExtractor::createPointsAndAddressing
void createPointsAndAddressing()
create vertices and pointLeaves addressing
Definition: cartesianMeshExtractorPointsAndAddressing.C:39
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::polyMeshGenModifier
Definition: polyMeshGenModifier.H:52
Foam::sumOp
Definition: ops.H:162
Foam::faceListPMG::size
label size() const
return the number of used elements
Definition: faceListPMGI.H:73
Foam::meshOctree
Definition: meshOctree.H:55
Foam::cartesianMeshExtractor::~cartesianMeshExtractor
~cartesianMeshExtractor()
Definition: cartesianMeshExtractor.C:64
Foam::cartesianMeshExtractor::mesh_
polyMeshGen & mesh_
reference to the mesh
Definition: cartesianMeshExtractor.H:58
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::cartesianMeshExtractor::createMesh
void createMesh()
create the mesh with the above options
Definition: cartesianMeshExtractor.C:76
Foam::cellListPMG::size
label size() const
return the number of used elements
Definition: cellListPMGI.H:56