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 "meshSurfaceEdgeExtractor2D.H"
30 #include "meshOctree.H"
32 #include "meshSurfaceEngine.H"
33 #include "meshSurfaceMapper2D.H"
34 #include "polyMeshGen2DEngine.H"
35 #include "helperFunctions.H"
41 //#define DEBUGMapping
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 void meshSurfaceEdgeExtractor2D::distributeBoundaryFaces()
52 polyMeshGen2DEngine mesh2DEngine(mesh_);
53 const boolList& activeFace = mesh2DEngine.activeFace();
54 const boolList& zMinPoint = mesh2DEngine.zMinPoints();
55 const boolList& zMaxPoint = mesh2DEngine.zMaxPoints();
57 const pointFieldPMG& points = mesh_.points();
58 const faceListPMG& faces = mesh_.faces();
59 const labelList& owner = mesh_.owner();
60 const PtrList<boundaryPatch>& boundaries = mesh_.boundaries();
62 const triSurf& surf = meshOctree_.surface();
63 const geometricSurfacePatchList& surfPatches = surf.patches();
65 //- copy boundary faces and their owner face
67 labelLongList origFaceLabel;
69 forAll(boundaries, patchI)
71 const label start = boundaries[patchI].patchStart();
72 const label size = boundaries[patchI].patchSize();
74 for(label fI=0;fI<size;++fI)
76 const label faceI = start + fI;
77 const face& bf = faces[faceI];
79 bndFaces.appendList(bf);
80 origFaceLabel.append(faceI);
84 //- project face centres onto their nearest location on the surface mesh
85 wordList patchNames(surfPatches.size()+2);
86 wordList patchTypes(surfPatches.size()+2);
87 forAll(surfPatches, ptchI)
89 patchNames[ptchI] = surfPatches[ptchI].name();
90 patchTypes[ptchI] = surfPatches[ptchI].geometricType();
93 const label bottomEmptyId = patchNames.size() - 2;
94 const label topEmptyId = patchNames.size() - 1;
96 patchNames[bottomEmptyId] = "bottomEmptyFaces";
97 patchTypes[bottomEmptyId] = "empty";
98 patchNames[topEmptyId] = "topEmptyFaces";
99 patchTypes[topEmptyId] = "empty";
101 labelLongList bndFaceOwner(bndFaces.size());
102 labelLongList bndFacePatch(bndFaces.size());
105 # pragma omp parallel for schedule(dynamic, 50)
107 forAll(bndFaces, bfI)
109 const label faceI = origFaceLabel[bfI];
110 const face& f = faces[faceI];
112 bndFaceOwner[bfI] = owner[faceI];
114 if( !activeFace[faceI] )
116 if( zMinPoint[f[0]] )
118 bndFacePatch[bfI] = bottomEmptyId;
120 else if( zMaxPoint[f[0]] )
122 bndFacePatch[bfI] = topEmptyId;
127 //- this face is active
128 const point c = f.centre(points);
130 //- find the patch index of the nearest location on the surface mesh
134 meshOctree_.findNearestSurfacePoint(mapPoint, distSq, nt, patchI, c);
136 bndFacePatch[bfI] = patchI;
140 //- replace the boundary
141 polyMeshGenModifier meshModifier(mesh_);
143 meshModifier.replaceBoundary
151 //- set correct patch types
152 PtrList<boundaryPatch>& modBnd = meshModifier.boundariesAccess();
153 forAll(patchTypes, patchI)
154 modBnd[patchI].patchType() = patchTypes[patchI];
157 void meshSurfaceEdgeExtractor2D::remapBoundaryPoints()
159 meshSurfaceEngine mse(mesh_);
160 meshSurfaceMapper2D mapper(mse, meshOctree_);
162 mapper.adjustZCoordinates();
164 mapper.mapVerticesOntoSurfacePatches();
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // ************************************************************************* //