cartesianMeshExtractorDecomposeSplitHexes.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 "demandDrivenData.H"
30 #include "decomposeFaces.H"
31 #include "decomposeCells.H"
32 #include "hexMatcher.H"
33 
34 //#define DEBUGMesh
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
44 {
45  if( !decomposeSplitHexes_ ) return;
46 
47  Info << "Decomposing split-hex cells" << endl;
48 
49  const faceListPMG& faces = mesh_.faces();
50 
51  //- decompose faces which have more than 4 vertices
52  boolList decompose(faces.size(), false);
53 
54  label nDecomposed(0);
55  forAll(faces, faceI)
56  {
57  if( faces[faceI].size() > 4 )
58  {
59  ++nDecomposed;
60 
61  decompose[faceI] = true;
62  }
63  }
64 
65  reduce(nDecomposed, sumOp<label>());
66 
67  Info << "Decomposing " << nDecomposed
68  << " faces with more than 4 vertices" << endl;
69 
70  if( nDecomposed != 0 )
71  {
72  //- decompose marked faces into triangles
74  }
75 
76  //- decompose cells with 24 faces
77  const cellListPMG& cells = mesh_.cells();
78  decompose.setSize(cells.size());
79  decompose = false;
80 
82  forAll(cells, cellI)
83  {
84  if( !hex.matchShape(true, faces, mesh_.owner(), cellI, cells[cellI]) )
85  {
86  ++nDecomposed;
87  decompose[cellI] = true;
88  }
89  }
90 
91  reduce(nDecomposed, sumOp<label>());
92 
93  Info << "Decomposing " << nDecomposed
94  << " cells into tetrahedra and pyramids" << endl;
95 
96  if( nDecomposed )
97  {
98  //- decompose marked cells into tets and pyramids
100  dc.decomposeMesh(decompose);
101  }
102 
103  Info << "Finished decomposing split-hex cells" << endl;
104 }
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 } // End namespace Foam
109 
110 // ************************************************************************* //
Foam::polyMeshGenFaces::owner
const labelList & owner() const
owner and neighbour cells for faces
Definition: polyMeshGenFacesI.H:67
Foam::cartesianMeshExtractor::decomposeSplitHexesIntoTetsAndPyramids
void decomposeSplitHexesIntoTetsAndPyramids()
decompose split hexes into pyramids and tets
Definition: cartesianMeshExtractorDecomposeSplitHexes.C:43
Foam::decomposeFaces
Definition: decomposeFaces.H:47
Foam::decomposeCells::decomposeMesh
void decomposeMesh(const boolList &)
perform decomposition of selected cell into pyramids
Definition: decomposeCellsDecomposition.C:42
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
decomposeCells.H
hexMatcher.H
decomposeFaces.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::cellListPMG
Definition: cellListPMG.H:49
cartesianMeshExtractor.H
Foam::polyMeshGenFaces::faces
const faceListPMG & faces() const
access to faces
Definition: polyMeshGenFacesI.H:43
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::hexMatcher
A cellMatcher for hex cells.
Definition: hexMatcher.H:51
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::Info
messageStream Info
Foam::polyMeshGenCells::cells
const cellListPMG & cells() const
access to cells
Definition: polyMeshGenCellsI.H:39
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::decomposeFaces::decomposeMeshFaces
void decomposeMeshFaces(const boolList &decomposeFace)
decompose selected faces into triangles using midnode subdivision
Definition: decomposeFaces.C:62
Foam::hex
IOstream & hex(IOstream &io)
Definition: IOstream.H:564
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::decomposeCells
Definition: decomposeCells.H:48
Foam::sumOp
Definition: ops.H:162
Foam::faceListPMG::size
label size() const
return the number of used elements
Definition: faceListPMGI.H:73
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::cartesianMeshExtractor::mesh_
polyMeshGen & mesh_
reference to the mesh
Definition: cartesianMeshExtractor.H:58
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::faceListPMG
Definition: faceListPMG.H:50