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 "demandDrivenData.H"
29 #include "meshSurfacePartitioner.H"
30 #include "partTriMesh.H"
31 #include "meshSurfaceEngine.H"
32 #include "triSurfModifier.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 void partTriMesh::createPointsAndTrias
45 const List<direction>& useFace
48 const labelList& facePatch = mPart_.boundaryFacePatches();
49 const meshSurfaceEngine& meshSurface = mPart_.surfaceEngine();
50 const pointFieldPMG& points = meshSurface.points();
51 const vectorField& faceCentres = meshSurface.faceCentres();
52 const labelList& bPoints = meshSurface.boundaryPoints();
53 const labelList& bp = meshSurface.bp();
54 const faceList::subList& bFaces = meshSurface.boundaryFaces();
56 meshSurfacePointLabelInTriMesh_.setSize(bPoints.size());
57 meshSurfacePointLabelInTriMesh_ = -1;
58 labelList nodeLabelForFace(bFaces.size(), -1);
65 const face& bf = bFaces[bfI];
67 //- create a point in the face centre
69 nodeLabelForFace[bfI] = nTriPoints++;
71 //- create points at face points
74 const label bpI = bp[bf[pI]];
76 if( meshSurfacePointLabelInTriMesh_[bpI] == -1 )
77 meshSurfacePointLabelInTriMesh_[bpI] = nTriPoints++;
85 //- add a triangle connected to face centre
88 meshSurfacePointLabelInTriMesh_[bp[bf[eI]]],
89 meshSurfacePointLabelInTriMesh_[bp[bf.nextLabel(eI)]],
90 nodeLabelForFace[bfI],
94 surf_.appendTriangle(tri);
96 //- add a triangle for shape
99 meshSurfacePointLabelInTriMesh_[bp[bf[eI]]],
100 meshSurfacePointLabelInTriMesh_[bp[bf.nextLabel(eI)]],
101 meshSurfacePointLabelInTriMesh_[bp[bf.prevLabel(eI)]],
105 surf_.appendTriangle(secondTri);
110 //- face is a triangle
113 meshSurfacePointLabelInTriMesh_[bp[bf[0]]],
114 meshSurfacePointLabelInTriMesh_[bp[bf[1]]],
115 meshSurfacePointLabelInTriMesh_[bp[bf[2]]],
119 surf_.appendTriangle(tri);
121 //- add a triangle for shape
124 labelledTri secondTri
126 meshSurfacePointLabelInTriMesh_[bp[bf[eI]]],
127 meshSurfacePointLabelInTriMesh_[bp[bf.nextLabel(eI)]],
128 meshSurfacePointLabelInTriMesh_[bp[bf.prevLabel(eI)]],
132 surf_.appendTriangle(secondTri);
139 triSurfModifier sMod(surf_);
140 pointField& pts = sMod.pointsAccess();
141 pts.setSize(nTriPoints);
143 pointType_.setSize(nTriPoints);
146 pointLabelInMeshSurface_.setSize(pts.size());
147 pointLabelInMeshSurface_ = -1;
149 forAll(meshSurfacePointLabelInTriMesh_, bpI)
150 if( meshSurfacePointLabelInTriMesh_[bpI] != -1 )
152 const label npI = meshSurfacePointLabelInTriMesh_[bpI];
153 pointLabelInMeshSurface_[npI] = bpI;
154 pts[npI] = points[bPoints[bpI]];
155 pointType_[npI] |= SMOOTH;
158 forAll(nodeLabelForFace, bfI)
159 if( nodeLabelForFace[bfI] != -1 )
161 const label npI = nodeLabelForFace[bfI];
162 pts[npI] = faceCentres[bfI];
163 pointType_[npI] = FACECENTRE;
166 //- set CORNER and FEATUREEDGE flags to surface points
167 forAllConstIter(labelHashSet, mPart_.corners(), it)
168 if( meshSurfacePointLabelInTriMesh_[it.key()] != -1 )
169 pointType_[meshSurfacePointLabelInTriMesh_[it.key()]] |= CORNER;
171 forAllConstIter(labelHashSet, mPart_.edgePoints(), it)
173 const label pI = meshSurfacePointLabelInTriMesh_[it.key()];
175 pointType_[pI] |= FEATUREEDGE;
178 //- create addressing for parallel runs
179 if( Pstream::parRun() )
181 createParallelAddressing
183 meshSurfacePointLabelInTriMesh_,
187 createBufferLayers();
190 //- calculate point facets addressing
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 } // End namespace Foam
198 // ************************************************************************* //