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 "meshSurfaceEdgeExtractorFUN.H"
30 #include "meshOctree.H"
32 #include "meshSurfaceEngine.H"
33 #include "meshSurfaceMapper.H"
34 #include "helperFunctions.H"
35 #include "createFundamentalSheetsJFS.H"
36 #include "meshSurfaceOptimizer.H"
37 #include "meshSurfaceCheckEdgeTypes.H"
38 #include "meshSurfaceEngine.H"
44 //#define DEBUGMapping
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 void meshSurfaceEdgeExtractorFUN::distributeBoundaryFaces()
55 meshSurfaceEngine mse(mesh_);
57 const faceList::subList& bFaces = mse.boundaryFaces();
58 const labelList& faceOwner = mse.faceOwners();
59 const pointFieldPMG& points = mse.points();
61 //- set size of patchNames, newBoundaryFaces_ and newBoundaryOwners_
62 const triSurf& surface = meshOctree_.surface();
63 const label nPatches = surface.patches().size();
65 wordList patchNames(nPatches);
66 VRWGraph newBoundaryFaces;
67 labelLongList newBoundaryOwners(bFaces.size());
68 labelLongList newBoundaryPatches(bFaces.size());
71 forAll(surface.patches(), patchI)
72 patchNames[patchI] = surface.patches()[patchI].name();
74 //- append boundary faces
77 newBoundaryFaces.appendList(bFaces[bfI]);
78 newBoundaryOwners[bfI] = faceOwner[bfI];
81 //- find the region for face by finding the patch nearest
82 //- to the face centre
84 # pragma omp parallel for if( bFaces.size() > 100 ) schedule(guided)
88 const point c = bFaces[bfI].centre(points);
94 meshOctree_.findNearestSurfacePoint(p, distSq, nt, facePatch, c);
96 if( (facePatch > -1) && (facePatch < nPatches) )
98 newBoundaryPatches[bfI] = facePatch;
104 "void meshSurfaceEdgeExtractorNonTopo::"
105 "distributeBoundaryFaces()"
106 ) << "Cannot distribute a face " << bFaces[bfI] << " into any "
107 << "surface patch!. Exiting.." << exit(FatalError);
111 polyMeshGenModifier(mesh_).replaceBoundary
120 void meshSurfaceEdgeExtractorFUN::reviseCorners()
125 void meshSurfaceEdgeExtractorFUN::reviseEdges()
130 void meshSurfaceEdgeExtractorFUN::remapBoundaryPoints()
132 meshSurfaceEngine& mse = surfaceEngine();
133 meshSurfaceMapper mapper(mse, meshOctree_);
135 mapper.mapVerticesOntoSurfacePatches();
138 void meshSurfaceEdgeExtractorFUN::createBasicFundamentalSheets()
140 createFundamentalSheetsJFS edgeSheets(mesh_, createWrapperSheet_);
145 void meshSurfaceEdgeExtractorFUN::smoothMeshSurface()
147 meshSurfaceEngine& mse = surfaceEngine();
149 meshSurfaceOptimizer mso(mse, meshOctree_);
150 mso.optimizeSurface();
153 void meshSurfaceEdgeExtractorFUN::improveQualityOfFundamentalSheets()
155 const meshSurfaceEngine& mse = surfaceEngine();
156 const edgeList& edges = mse.edges();
158 meshSurfaceCheckEdgeTypes edgeCheck(mse);
160 label id = mesh_.addPointSubset("convexEdges");
161 labelLongList helper;
162 edgeCheck.convexEdges(helper);
165 mesh_.addPointToSubset(id, edges[helper[i]].start());
166 mesh_.addPointToSubset(id, edges[helper[i]].end());
169 id = mesh_.addPointSubset("concaveEdges");
170 edgeCheck.concaveEdges(helper);
173 mesh_.addPointToSubset(id, edges[helper[i]].start());
174 mesh_.addPointToSubset(id, edges[helper[i]].end());
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 } // End namespace Foam
182 // ************************************************************************* //