meshSurfaceEdgeExtractorFUNDistributeFaces.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "demandDrivenData.H"
30 #include "meshOctree.H"
31 #include "triSurf.H"
32 #include "meshSurfaceEngine.H"
33 #include "meshSurfaceMapper.H"
34 #include "helperFunctions.H"
36 #include "meshSurfaceOptimizer.H"
38 #include "meshSurfaceEngine.H"
39 
40 # ifdef USE_OMP
41 #include <omp.h>
42 # endif
43 
44 //#define DEBUGMapping
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
54 {
56 
57  const faceList::subList& bFaces = mse.boundaryFaces();
58  const labelList& faceOwner = mse.faceOwners();
59  const pointFieldPMG& points = mse.points();
60 
61  //- set size of patchNames, newBoundaryFaces_ and newBoundaryOwners_
63  const label nPatches = surface.patches().size();
64 
66  VRWGraph newBoundaryFaces;
67  labelLongList newBoundaryOwners(bFaces.size());
68  labelLongList newBoundaryPatches(bFaces.size());
69 
70  //- set patchNames
71  forAll(surface.patches(), patchI)
72  patchNames[patchI] = surface.patches()[patchI].name();
73 
74  //- append boundary faces
75  forAll(bFaces, bfI)
76  {
77  newBoundaryFaces.appendList(bFaces[bfI]);
78  newBoundaryOwners[bfI] = faceOwner[bfI];
79  }
80 
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);
89 
90  label facePatch, nt;
91  point p;
92  scalar distSq;
93 
94  meshOctree_.findNearestSurfacePoint(p, distSq, nt, facePatch, c);
95 
96  if( (facePatch > -1) && (facePatch < nPatches) )
97  {
98  newBoundaryPatches[bfI] = facePatch;
99  }
100  else
101  {
103  (
104  "void meshSurfaceEdgeExtractorNonTopo::"
105  "distributeBoundaryFaces()"
106  ) << "Cannot distribute a face " << bFaces[bfI] << " into any "
107  << "surface patch!. Exiting.." << exit(FatalError);
108  }
109  }
110 
112  (
113  patchNames,
114  newBoundaryFaces,
115  newBoundaryOwners,
116  newBoundaryPatches
117  );
118 }
119 
121 {
122 
123 }
124 
126 {
127 
128 }
129 
131 {
133  meshSurfaceMapper mapper(mse, meshOctree_);
134 
136 }
137 
139 {
141 
142  clearOut();
143 }
144 
146 {
148 
150  mso.optimizeSurface();
151 }
152 
154 {
155  const meshSurfaceEngine& mse = surfaceEngine();
156  const edgeList& edges = mse.edges();
157 
158  meshSurfaceCheckEdgeTypes edgeCheck(mse);
159 
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  }
168 
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  }
176 }
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 } // End namespace Foam
181 
182 // ************************************************************************* //
meshSurfaceEdgeExtractorFUN.H
Foam::meshSurfaceEdgeExtractorFUN::reviseEdges
void reviseEdges()
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:125
triSurf.H
p
p
Definition: pEqn.H:62
meshSurfaceMapper.H
Foam::meshSurfaceEdgeExtractorFUN::distributeBoundaryFaces
void distributeBoundaryFaces()
distribute boundary faces into patches
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:53
nPatches
label nPatches
Definition: readKivaGrid.H:402
meshSurfaceCheckEdgeTypes.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::meshOctree::findNearestSurfacePoint
void findNearestSurfacePoint(point &nearest, scalar &distSq, label &nearestTriangle, label &region, const point &p) const
find nearest surface point for vertex and its region
Definition: meshOctreeFindNearestSurfacePoint.C:44
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
createFundamentalSheetsJFS.H
Foam::polyMeshGenModifier::replaceBoundary
void replaceBoundary(const wordList &patchNames, const VRWGraph &boundaryFaces, const labelLongList &faceOwners, const labelLongList &facePatches)
replace the boundary with new boundary faces
Definition: polyMeshGenModifierReplaceBoundary.C:42
Foam::meshSurfaceEdgeExtractorFUN::clearOut
void clearOut()
clear mesh suirface engine
Definition: meshSurfaceEdgeExtractorFUN.C:62
meshOctree.H
Foam::LongList< label >
Foam::meshSurfaceCheckEdgeTypes::convexEdges
void convexEdges(labelLongList &convexEdges) const
return indices of convex edges
Definition: meshSurfaceCheckEdgeTypes.C:330
Foam::meshSurfaceEngine::boundaryFaces
const faceList::subList & boundaryFaces() const
Definition: meshSurfaceEngineI.H:103
Foam::meshSurfaceEdgeExtractorFUN::mesh_
polyMeshGen & mesh_
mesh
Definition: meshSurfaceEdgeExtractorFUN.H:58
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::meshSurfaceEdgeExtractorFUN::improveQualityOfFundamentalSheets
void improveQualityOfFundamentalSheets()
modify fundamental sheets
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:153
Foam::meshSurfaceEdgeExtractorFUN::remapBoundaryPoints
void remapBoundaryPoints()
re-map points after edges have been extracted
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:130
patchNames
wordList patchNames(nPatches)
Foam::meshSurfaceEngine::points
const pointFieldPMG & points() const
Definition: meshSurfaceEngineI.H:49
Foam::meshSurfaceEdgeExtractorFUN::reviseCorners
void reviseCorners()
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:120
Foam::meshSurfaceEdgeExtractorFUN::surfaceEngine
meshSurfaceEngine & surfaceEngine()
return reference to surface engine
Definition: meshSurfaceEdgeExtractorFUN.C:45
Foam::meshSurfaceCheckEdgeTypes
Definition: meshSurfaceCheckEdgeTypes.H:53
Foam::FatalError
error FatalError
Foam::polyMeshGenPoints::addPointToSubset
void addPointToSubset(const label, const label)
Definition: polyMeshGenPointsI.H:60
Foam::geometryBase::name
const word & name() const
Return the name.
Definition: geometryBase.C:124
Foam::meshSurfaceMapper::mapVerticesOntoSurfacePatches
void mapVerticesOntoSurfacePatches()
Definition: meshSurfaceMapperMapVertices.C:285
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
meshSurfaceEngine.H
Foam::meshSurfaceEngine::edges
const edgeList & edges() const
Definition: meshSurfaceEngineI.H:296
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::meshSurfaceOptimizer::optimizeSurface
void optimizeSurface(const label nIterations=5)
optimize boundary nodes after boundary regions are created
Definition: meshSurfaceOptimizerOptimizeSurface.C:581
Foam::polyMeshGenModifier
Definition: polyMeshGenModifier.H:52
Foam::meshSurfaceEdgeExtractorFUN::createWrapperSheet_
const bool createWrapperSheet_
shall the procedure generate an initial wrapper sheet
Definition: meshSurfaceEdgeExtractorFUN.H:67
helperFunctions.H
Foam::meshSurfaceEdgeExtractorFUN::createBasicFundamentalSheets
void createBasicFundamentalSheets()
create fundamental sheets
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:138
Foam::createFundamentalSheetsJFS
Definition: createFundamentalSheetsJFS.H:54
Foam::VRWGraph::appendList
void appendList(const ListType &l)
Append a list as a row at the end of the graph.
Definition: VRWGraphI.H:286
Foam::Vector< scalar >
Foam::meshSurfaceOptimizer
Definition: meshSurfaceOptimizer.H:63
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::meshSurfaceMapper
Definition: meshSurfaceMapper.H:59
Foam::meshSurfaceCheckEdgeTypes::concaveEdges
void concaveEdges(labelLongList &concaveEdges) const
return indices of concave edges
Definition: meshSurfaceCheckEdgeTypes.C:341
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::surface
Definition: surface.H:55
Foam::meshSurfaceEdgeExtractorFUN::meshOctree_
const meshOctree & meshOctree_
octree
Definition: meshSurfaceEdgeExtractorFUN.H:61
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::meshSurfaceEdgeExtractorFUN::smoothMeshSurface
void smoothMeshSurface()
smooth the surface
Definition: meshSurfaceEdgeExtractorFUNDistributeFaces.C:145
Foam::meshOctree::surface
const triSurf & surface() const
return a reference to the surface
Definition: meshOctreeI.H:130
Foam::UList::size
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
Foam::pointFieldPMG
Definition: pointFieldPMG.H:50
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::triSurf
Definition: triSurf.H:59
Foam::polyMeshGenPoints::addPointSubset
label addPointSubset(const word &)
point subsets
Definition: polyMeshGenPoints.C:88
meshSurfaceOptimizer.H
Foam::meshSurfaceEngine
Definition: meshSurfaceEngine.H:54
Foam::meshSurfaceEngine::faceOwners
const labelList & faceOwners() const
Definition: meshSurfaceEngineI.H:143