triangulateNonPlanarBaseFacesFunctions.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 
29 #include "decomposeFaces.H"
30 #include "decomposeCells.H"
31 #include "helperFunctions.H"
32 #include "meshSurfacePartitioner.H"
33 #include "triangle.H"
34 
35 # ifdef USE_OMP
36 #include <omp.h>
37 # endif
38 
39 //#define DEBUGLayer
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
49 {
50  const pointFieldPMG& points = mesh_.points();
51  const label nInternalFaces = mesh_.nInternalFaces();
52 
54  const meshSurfaceEngine& mse = mPart.surfaceEngine();
55  const labelList& faceOwner = mse.faceOwners();
56  const faceList::subList& bFaces = mse.boundaryFaces();
57 
58  bool hasInvalid(false);
59 
60  # ifdef USE_OMP
61  # pragma omp parallel for schedule(dynamic, 50)
62  # endif
63  forAll(bFaces, bfI)
64  {
65  const face& bf = bFaces[bfI];
66 
67  //- triangle shall not be decomposed, they are flat
68  if( bf.size() == 3 )
69  continue;
70 
71  //- calculate min face diagonal
72  scalar minDist(VGREAT);
73  const point c = bf.centre(points);
74  forAll(bf, pI)
75  {
76  minDist = Foam::min(minDist, Foam::mag(c - points[bf[pI]]));
77  }
78 
79  forAll(bf, eI)
80  {
82  (
83  points[bf[eI]],
84  points[bf.nextLabel(eI)],
85  c
86  );
87 
88  const point triCentre = tri.centre();
89  vector n = tri.normal();
90  n /= (mag(n) + VSMALL);
91 
92  forAll(bf, pI)
93  {
94  const scalar d = (points[bf[pI]] - triCentre) & n;
95 
96  if( d > tol_ * minDist )
97  {
98  invertedCell_[faceOwner[bfI]] = true;
99 
100  decomposeFace_[nInternalFaces+bfI] = true;
101  hasInvalid = true;
102  }
103  }
104  }
105  }
106 
107  reduce(hasInvalid, maxOp<bool>());
108 
109  return hasInvalid;
110 }
111 
113 {
114  //- decompose base faces into triangles
115  decomposeFaces triangulator(mesh_);
116  triangulator.decomposeMeshFaces(decomposeFace_);
117  const VRWGraph& newFacesFromFace = triangulator.newFacesForFace();
118 
119  //- update face subsets
120  mesh_.updateFaceSubsets(newFacesFromFace);
121 }
122 
124 {
125  decomposeCells sc(mesh_);
127 }
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace Foam
132 
133 // ************************************************************************* //
Foam::maxOp
Definition: ops.H:172
Foam::triangulateNonPlanarBaseFaces::mesh_
polyMeshGen & mesh_
Reference to the mesh.
Definition: triangulateNonPlanarBaseFaces.H:56
Foam::decomposeFaces
Definition: decomposeFaces.H:47
Foam::triangulateNonPlanarBaseFaces::invertedCell_
boolList invertedCell_
boolean list containing information about inverted cells
Definition: triangulateNonPlanarBaseFaces.H:59
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
triangle.H
Foam::decomposeFaces::newFacesForFace
const VRWGraph & newFacesForFace() const
Definition: decomposeFaces.C:521
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
decomposeCells.H
Foam::face::centre
point centre(const pointField &) const
Centre point of face.
Definition: face.C:488
decomposeFaces.H
Foam::polyMeshGenPoints::points
const pointFieldPMG & points() const
access to points
Definition: polyMeshGenPointsI.H:44
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::meshSurfacePartitioner::surfaceEngine
const meshSurfaceEngine & surfaceEngine() const
return const reference to meshSurfaceEngine
Definition: meshSurfacePartitioner.H:109
Foam::polyMeshGenFaces::updateFaceSubsets
void updateFaceSubsets(const ListType &)
Definition: polyMeshGenFacesI.H:194
Foam::polyMeshGenFaces::nInternalFaces
label nInternalFaces() const
return number of internal faces
Definition: polyMeshGenFacesI.H:48
Foam::triangle::centre
Point centre() const
Return centre (centroid)
Definition: triangleI.H:102
Foam::triangle
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:59
n
label n
Definition: TABSMDCalcMethod2.H:31
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::meshSurfaceEngine::boundaryFaces
const faceList::subList & boundaryFaces() const
Definition: meshSurfaceEngineI.H:103
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::triangulateNonPlanarBaseFaces::tol_
scalar tol_
relative deviation compared to the layer thickness
Definition: triangulateNonPlanarBaseFaces.H:65
Foam::triangle::normal
vector normal() const
Return vector normal.
Definition: triangleI.H:116
Foam::triangulateNonPlanarBaseFaces::decomposeFace_
boolList decomposeFace_
classification of faces in the mesh
Definition: triangulateNonPlanarBaseFaces.H:62
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::triangulateNonPlanarBaseFaces::decomposeCellsIntoPyramids
void decomposeCellsIntoPyramids()
decompose adjacent cells into pyramids
Definition: triangulateNonPlanarBaseFacesFunctions.C:123
Foam::decomposeFaces::decomposeMeshFaces
void decomposeMeshFaces(const boolList &decomposeFace)
decompose selected faces into triangles using midnode subdivision
Definition: decomposeFaces.C:62
Foam::meshSurfacePartitioner
Definition: meshSurfacePartitioner.H:52
Foam::face::nextLabel
label nextLabel(const label i) const
Next vertex on face.
Definition: faceI.H:117
Foam::decomposeCells
Definition: decomposeCells.H:48
helperFunctions.H
Foam::Vector< scalar >
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::triangulateNonPlanarBaseFaces::findNonPlanarBoundaryFaces
bool findNonPlanarBoundaryFaces()
Definition: triangulateNonPlanarBaseFacesFunctions.C:48
triangulateNonPlanarBaseFaces.H
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::triangulateNonPlanarBaseFaces::decomposeBoundaryFaces
void decomposeBoundaryFaces()
decompose existing faces
Definition: triangulateNonPlanarBaseFacesFunctions.C:112
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::pointFieldPMG
Definition: pointFieldPMG.H:50
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::meshSurfaceEngine
Definition: meshSurfaceEngine.H:54
meshSurfacePartitioner.H
Foam::meshSurfaceEngine::faceOwners
const labelList & faceOwners() const
Definition: meshSurfaceEngineI.H:143