Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / surfaceTools / meshSurfaceEdgeExtractorFUN / meshSurfaceEdgeExtractorFUNDistributeFaces.C
blob462a62edd02978a648ba92cbf2fd8b9cbb3fbe67
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.
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
19     for more details.
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/>.
24 Description
26 \*---------------------------------------------------------------------------*/
28 #include "demandDrivenData.H"
29 #include "meshSurfaceEdgeExtractorFUN.H"
30 #include "meshOctree.H"
31 #include "triSurf.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"
40 # ifdef USE_OMP
41 #include <omp.h>
42 # endif
44 //#define DEBUGMapping
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
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());
70     //- set patchNames
71     forAll(surface.patches(), patchI)
72         patchNames[patchI] = surface.patches()[patchI].name();
74     //- append boundary faces
75     forAll(bFaces, bfI)
76     {
77         newBoundaryFaces.appendList(bFaces[bfI]);
78         newBoundaryOwners[bfI] = faceOwner[bfI];
79     }
81     //- find the region for face by finding the patch nearest
82     //- to the face centre
83     # ifdef USE_OMP
84     # pragma omp parallel for if( bFaces.size() > 100 ) schedule(guided)
85     # endif
86     forAll(bFaces, bfI)
87     {
88         const point c = bFaces[bfI].centre(points);
90         label facePatch, nt;
91         point p;
92         scalar distSq;
94         meshOctree_.findNearestSurfacePoint(p, distSq, nt, facePatch, c);
96         if( (facePatch > -1) && (facePatch < nPatches) )
97         {
98             newBoundaryPatches[bfI] = facePatch;
99         }
100         else
101         {
102             FatalErrorIn
103             (
104                 "void meshSurfaceEdgeExtractorNonTopo::"
105                 "distributeBoundaryFaces()"
106             ) << "Cannot distribute a face " << bFaces[bfI] << " into any "
107                 << "surface patch!. Exiting.." << exit(FatalError);
108         }
109     }
111     polyMeshGenModifier(mesh_).replaceBoundary
112     (
113         patchNames,
114         newBoundaryFaces,
115         newBoundaryOwners,
116         newBoundaryPatches
117     );
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_);
142     clearOut();
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);
163     forAll(helper, i)
164     {
165         mesh_.addPointToSubset(id, edges[helper[i]].start());
166         mesh_.addPointToSubset(id, edges[helper[i]].end());
167     }
169     id = mesh_.addPointSubset("concaveEdges");
170     edgeCheck.concaveEdges(helper);
171     forAll(helper, i)
172     {
173         mesh_.addPointToSubset(id, edges[helper[i]].start());
174         mesh_.addPointToSubset(id, edges[helper[i]].end());
175     }
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 } // End namespace Foam
182 // ************************************************************************* //