1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
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.
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
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/>.
26 \*---------------------------------------------------------------------------*/
28 #include "triangulateNonPlanarBaseFaces.H"
29 #include "decomposeFaces.H"
30 #include "decomposeCells.H"
31 #include "helperFunctions.H"
32 #include "meshSurfacePartitioner.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 bool triangulateNonPlanarBaseFaces::findNonPlanarBoundaryFaces()
50 const pointFieldPMG& points = mesh_.points();
51 const label nInternalFaces = mesh_.nInternalFaces();
53 meshSurfacePartitioner mPart(mesh_);
54 const meshSurfaceEngine& mse = mPart.surfaceEngine();
55 const labelList& faceOwner = mse.faceOwners();
56 const faceList::subList& bFaces = mse.boundaryFaces();
58 bool hasInvalid(false);
61 # pragma omp parallel for schedule(dynamic, 50)
65 const face& bf = bFaces[bfI];
67 //- triangle shall not be decomposed, they are flat
71 //- calculate min face diagonal
72 scalar minDist(VGREAT);
73 const point c = bf.centre(points);
76 minDist = Foam::min(minDist, Foam::mag(c - points[bf[pI]]));
81 triangle<point, point> tri
84 points[bf.nextLabel(eI)],
88 const point triCentre = tri.centre();
89 vector n = tri.normal();
90 n /= (mag(n) + VSMALL);
94 const scalar d = (points[bf[pI]] - triCentre) & n;
96 if( d > tol_ * minDist )
98 invertedCell_[faceOwner[bfI]] = true;
100 decomposeFace_[nInternalFaces+bfI] = true;
107 reduce(hasInvalid, maxOp<bool>());
112 void triangulateNonPlanarBaseFaces::decomposeBoundaryFaces()
114 //- decompose base faces into triangles
115 decomposeFaces triangulator(mesh_);
116 triangulator.decomposeMeshFaces(decomposeFace_);
117 const VRWGraph& newFacesFromFace = triangulator.newFacesForFace();
119 //- update face subsets
120 mesh_.updateFaceSubsets(newFacesFromFace);
123 void triangulateNonPlanarBaseFaces::decomposeCellsIntoPyramids()
125 decomposeCells sc(mesh_);
126 sc.decomposeMesh(invertedCell_);
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 } // End namespace Foam
133 // ************************************************************************* //