edgeExtractor.H
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 Namespace
25  edgeExtractor
26 
27 Description
28  A class with a functions used to detect feature edges in the surface
29  of the volume mesh and to detect the patches to which the boundary
30  faces belong to
31 
32 SourceFiles
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef edgeExtractor_H
37 #define edgeExtractor_H
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 #include "labelList.H"
42 #include "labelLongList.H"
43 #include "VRWGraph.H"
44 #include "boolList.H"
45 #include "labelledPoint.H"
46 #include "DynList.H"
47 #include "Map.H"
48 
49 namespace Foam
50 {
51 
52 // Forward declarations
53 class polyMeshGen;
54 class meshSurfaceEngine;
56 class meshOctree;
57 class triSurf;
60 
61 /*---------------------------------------------------------------------------*\
62  Class edgeExtractor Declaration
63 \*---------------------------------------------------------------------------*/
64 
66 {
67  // Private data
68  //- reference to the mesh
70 
71  //- surface engine
73 
74  //- reference to the octree
76 
77  //- surface mesh partitioner
79 
80  //- classification of edges in the surface mesh
82 
83  //- valence of surface points
85 
86  //- patch to which a boundary point is mapped to
88 
89  //- boundary face patch
91 
92  //- number of cells attached to a boundary edge
94 
95  //- edge classification
97 
98  //- patches in the vicinity of a face on the surface of the volume mesh
100 
101  //- feature edges in the surface mesh
102  //- which are candindates for an edge at the surface of the volume mesh
104 
105  // Private member functions
106  //- calculate point valence
107  void calculateValence();
108 
109  //- calculate the number of boundary faces for each cell
111 
112  //- search for surface patches in the vicinity of a face
113  //- at the surface of the volume mesh
115 
116  //- search for feature edges in the surface mesh which are
117  //- in the vicinity of an edge at the surface of the volume mesh
119 
120  //- calculate a list of booleans with the following properties:
121  //- true if all faces at a surface vertex are in the same patch
122  //- false otherwise
123  void markPatchPoints(boolList&);
124 
125  //- get the surface engine
126  const meshSurfaceEngine& surfaceEngine() const;
127 
128  //- get the surface partitioner
129  const triSurfacePartitioner& partitioner() const;
130 
131  //- get the edge classifier
133 
134  //- find faces which have faces assigned to other patches
135  //- as their neighbours
136  void findFaceCandidates
137  (
138  labelLongList& faceCandidates,
139  const labelList* facePatchPtr = NULL,
140  const Map<label>* otherFacePatchPtr = NULL
141  ) const;
142 
143  //- find patches over edges
145  (
146  Map<label>& otherFacePatch,
147  const labelList* facePatchPtr = NULL
148  ) const;
149 
150  //- find neighbour patches over edges for a boundary face
151  void findNeiPatches
152  (
153  const label,
154  const Map<label>&,
156  ) const;
157 
158  //- calculate alignment between the boundary edge and a feature edge
159  //- between the specified patches
161  (
162  const label beI,
163  const label patch0,
164  const label patch1
165  ) const;
166 
167  //- calculates the deformation energy metric for the boundary edge
168  //- when it would be constrained to a feature edge between
169  //- the specified patches
171  (
172  const label beI,
173  const label patch0,
174  const label patch1
175  ) const;
176 
177  //- calculates deformation energy metric for a face
179  (
180  const label bfI,
181  const DynList<label>& neiPatches,
182  const label facePatch = -1
183  ) const;
184 
185  //- project face centres on the nearest location at the surface mesh
186  //- and assign the patch to the patch of the surface element
188 
189  //- move faces into the patch with the best alignment
191 
192  //- go through the boundary faces which have at least one neighour
193  //- assigned to a different patch and check which of its edges
194  //- are best candidates to be used as feature edges
195  void findEdgeCandidates();
196 
197  //- Disallow default bitwise copy construct
199 
200  //- Disallow default bitwise assignment
201  void operator=(const edgeExtractor&);
202 
203  // Private nested classes
204 
206  {
207  // Private data
208  //- const reference to the parent class
210 
211  //- calculated patches of faces over inter-processor boundaries
213 
214  //- new status of face patches after re-assigning of patches
216 
217  //- calculated patches of faces over inter-processor boundaries
218  //- after re-assigning of patches
220 
221  // Private member functions
222  //- calculate patches of faces over inter-processor boundaries
225 
226  //- find neighbour faces over edges
227  void neiFacesOverEdges(const label, DynList<label>&) const;
228 
229  //- find processors of faces over edges
230  void neiFacesProcs(const label, DynList<label>&) const;
231 
232  //- calculate neighbour patches over edges of a boundary face
234  (
235  const label bfI,
236  const labelList& fPatches,
237  const Map<label>& otherFacePatch,
238  DynList<label> &neiPatches
239  ) const;
240 
241  //- evaluate new patch for a face based on the number of
242  //- common edges shared between faces in other patches
244  (
245  const DynList<label>& neiPatches,
246  const label currentPatch
247  );
248 
249  public:
250 
251  // Constructors
252  //- Construct from edgeExtractor
254 
255  // Destructor
256  ~faceEvaluator();
257 
258  // Public member functions
259  //- set the values for new boundary patches
260  void setNewBoundaryPatches(const labelList& newBoudaryPatches);
261 
262  //- calculate neighbour patches over edges of a face
264  (
265  const label bfI,
266  DynList<label>& neiPatches
267  ) const;
268 
269  //- return the patch that the face shall be moved to such that
270  //- the number of feature edges between the two patches
271  //- is minimised
272  label bestPatchTopological(const label bfI) const;
273 
274  //- return the best patch for a face by comparing the patch
275  //- before and after modifications to face patches
276  //- have been made
277  //- this function checks whether the changes of face patches
278  //- cause oscillations in the procedure
279  label bestPatchAfterModification(const label bfI) const;
280  };
281 
283  {
284  // Private data
285  //- const reference to the parent class
287 
288  //- const reference to meshSurfacePartitioner
290 
291  //- faces attached to points at inter-processor boundaries
292  std::map<label, DynList<DynList<labelledPoint, 6> > > faceMap_;
293  std::map<label, DynList<label> > facePatches_;
294  std::map<label, DynList<label> > faceAtProc_;
295 
296  // Private member functions
297  //- create addressing at inter-processor boundaries
299 
300  //- sort faces attached to a boundary point
301  void sortedFacesAtPoint(const label, DynList<label>&) const;
302 
303  public:
304 
305  // Constructors
306  //- construct from edgeExtractor and meshSurfacePartitioner
308  (
309  const edgeExtractor&,
311  );
312 
313  // Destructor
315 
316  // Public member functions
317 
318  //- check patches of the faces attached to corners
319  //- and re-assign the patches such that the mesh undergoes
320  //- minimum rotation during the projection stage
321  void improveCorners(labelList& newBoundaryPatches);
322  };
323 
324  // Private enumerators
325 
327  {
328  NONE = 0,
334  };
335 
336 public:
337 
338  // Constructors
339 
340  //- Construct from mesh surface and octree
342  (
343  polyMeshGen& mesh,
344  const meshOctree& octree
345  );
346 
347 
348  // Destructor
349 
350  ~edgeExtractor();
351 
352  // Member Functions
353 
354 
355  //- move vertices in the vicinity of discontinuities towards the
356  //- the surface mesh by reducing the deviation of the mesh from the
357  //- input geometry
358  void moveVerticesTowardsDiscontinuities(const label nIterations = 2);
359 
360  //- check if there exist cells at concave feature edges which have more
361  //- than one face at the boundary and the faces are
362  //- distributed into patches at the concave edge
363  bool checkConcaveEdgeCells();
364 
365  //- check and improve the distribution of mesh faces into patches
366  //- in order to minimize the number of decomposed faces
368 
369  //- checks whether there exist corners which do not exist in the surface
370  //- mesh, and checks whether the locations of corners in the volume mesh
371  //- are near the existing counterparts in the surface mesh
372  bool checkCorners();
373 
374  //- optimise distribution of mesh faces into patches
375  //- in order to get better geometric quality of the mesh
377 
378  //- find the nearest points on the surface of the volume mesh
379  //- to the corners on the surface mesh
380  bool findCornerCandidates();
381 
382  //- project the estimated corners and edges onto the surface mesh
384 
385  //- check and untangle the surface of the volume mesh
386  bool untangleSurface();
387 
388  //- assemble the above functionality into a workflow
389  void extractEdges();
390 
391  //- generate a surface mesh and store the created patches
392  //- this is mainly intended for debugging purposes
393  const triSurf* surfaceWithPatches() const;
394 
395  //- generate a surface mesh constin of facets adjacent to the requested
396  //- surface point
397  const triSurf* surfaceWithPatches(const label bpI) const;
398 
399  //- update mesh with selected patches
400  void updateMeshPatches();
401 };
402 
403 
404 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
405 
406 } // End namespace Foam
407 
408 #endif
409 
410 // ************************************************************************* //
Foam::edgeExtractor::patchesNearFace_
VRWGraph patchesNearFace_
patches in the vicinity of a face on the surface of the volume mesh
Definition: edgeExtractor.H:99
Foam::edgeExtractor::featureEdgesNearEdge_
VRWGraph featureEdgesNearEdge_
Definition: edgeExtractor.H:103
Foam::triSurfacePartitioner
Definition: triSurfacePartitioner.H:53
Foam::edgeExtractor::checkCorners
bool checkCorners()
Definition: edgeExtractorCorners.C:953
Foam::edgeExtractor::operator=
void operator=(const edgeExtractor &)
Disallow default bitwise assignment.
Foam::edgeExtractor::checkConcaveEdgeCells
bool checkConcaveEdgeCells()
Definition: edgeExtractor.C:1423
Foam::edgeExtractor::partitioner
const triSurfacePartitioner & partitioner() const
get the surface partitioner
Definition: edgeExtractor.C:480
boolList.H
Foam::edgeExtractor::faceEvaluator::faceEvaluator
faceEvaluator(const edgeExtractor &)
Construct from edgeExtractor.
Definition: edgeExtractorCorners.C:332
Foam::edgeExtractor::ATTACHEDTOCORNER
@ ATTACHEDTOCORNER
Definition: edgeExtractor.H:332
Foam::edgeExtractor::surfaceWithPatches
const triSurf * surfaceWithPatches() const
Definition: edgeExtractor.C:2445
meshSurfaceEngine
Calculates surface of the mesh.
Foam::edgeExtractor::cornerEvaluator::faceAtProc_
std::map< label, DynList< label > > faceAtProc_
Definition: edgeExtractor.H:294
Foam::edgeExtractor::pointPatch_
labelLongList pointPatch_
patch to which a boundary point is mapped to
Definition: edgeExtractor.H:87
Foam::edgeExtractor::edgeClassifier
const triSurfaceClassifyEdges & edgeClassifier() const
get the edge classifier
Definition: edgeExtractor.C:499
Foam::edgeExtractor::cornerEvaluator::facePatches_
std::map< label, DynList< label > > facePatches_
Definition: edgeExtractor.H:293
VRWGraph.H
Foam::edgeExtractor::nCellsAtEdge_
labelLongList nCellsAtEdge_
number of cells attached to a boundary edge
Definition: edgeExtractor.H:93
Foam::edgeExtractor::faceEvaluator::newBoundaryPatchesPtr_
const labelList * newBoundaryPatchesPtr_
new status of face patches after re-assigning of patches
Definition: edgeExtractor.H:215
Foam::edgeExtractor::edgeClassifier_
edgeClassifier_
Definition: edgeExtractor.H:326
Foam::edgeExtractor::NONE
@ NONE
Definition: edgeExtractor.H:328
Foam::Map< label >
Foam::edgeExtractor::findFeatureEdgesNearEdge
void findFeatureEdgesNearEdge()
Definition: edgeExtractor.C:268
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::edgeExtractor::cornerEvaluator::improveCorners
void improveCorners(labelList &newBoundaryPatches)
Definition: edgeExtractorCorners.C:676
Foam::edgeExtractor::surfaceEnginePtr_
meshSurfaceEngine * surfaceEnginePtr_
surface engine
Definition: edgeExtractor.H:72
polyMeshGen
Mesh with selections.
Foam::edgeExtractor::surfaceEngine
const meshSurfaceEngine & surfaceEngine() const
get the surface engine
Definition: edgeExtractor.C:462
Foam::edgeExtractor::pointValence_
labelLongList pointValence_
valence of surface points
Definition: edgeExtractor.H:84
Foam::LongList< label >
Foam::edgeExtractor::cornerEvaluator
Definition: edgeExtractor.H:282
Map.H
Foam::edgeExtractor::faceEvaluator::extractor_
const edgeExtractor & extractor_
const reference to the parent class
Definition: edgeExtractor.H:209
Foam::edgeExtractor::moveVerticesTowardsDiscontinuities
void moveVerticesTowardsDiscontinuities(const label nIterations=2)
Definition: edgeExtractor.C:694
Foam::edgeExtractor::mesh_
polyMeshGen & mesh_
reference to the mesh
Definition: edgeExtractor.H:69
Foam::edgeExtractor::CANDIDATE
@ CANDIDATE
Definition: edgeExtractor.H:333
Foam::edgeExtractor::calculateDeformationMetricForFace
scalar calculateDeformationMetricForFace(const label bfI, const DynList< label > &neiPatches, const label facePatch=-1) const
calculates deformation energy metric for a face
Definition: edgeExtractor.C:1388
triSurfacePartitioner
Provides information regarding surface partitions on the surface triangulation, and connectivity betw...
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
labelList.H
Foam::edgeExtractor::calculateSingleCellEdge
void calculateSingleCellEdge()
calculate the number of boundary faces for each cell
Definition: edgeExtractor.C:123
Foam::edgeExtractor::checkFacePatchesTopology
bool checkFacePatchesTopology()
Definition: edgeExtractor.C:1632
Foam::edgeExtractor::calculateAlignmentForEdge
scalar calculateAlignmentForEdge(const label beI, const label patch0, const label patch1) const
Definition: edgeExtractor.C:1307
Foam::edgeExtractor::markPatchPoints
void markPatchPoints(boolList &)
Definition: edgeExtractor.C:336
Foam::edgeExtractor::untangleSurface
bool untangleSurface()
check and untangle the surface of the volume mesh
Definition: edgeExtractor.C:2386
Foam::edgeExtractor::faceEvaluator::bestPatchTopological
static label bestPatchTopological(const DynList< label > &neiPatches, const label currentPatch)
Definition: edgeExtractorCorners.C:267
meshSurfacePartitioner
Finds corners and edge points at the surface of the volume mesh.
labelledPoint.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::edgeExtractor::distributeBoundaryFaces
void distributeBoundaryFaces()
Definition: edgeExtractor.C:843
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::edgeExtractor::~edgeExtractor
~edgeExtractor()
Definition: edgeExtractor.C:685
Foam::edgeExtractor::cornerEvaluator::cornerEvaluator
cornerEvaluator(const edgeExtractor &, const meshSurfacePartitioner &)
construct from edgeExtractor and meshSurfacePartitioner
Definition: edgeExtractorCorners.C:653
Foam::edgeExtractor::faceEvaluator::newOtherFacePatchPtr_
Map< label > * newOtherFacePatchPtr_
Definition: edgeExtractor.H:219
Foam::edgeExtractor::FITSATCONCAVEEDGE
@ FITSATCONCAVEEDGE
Definition: edgeExtractor.H:331
Foam::DynList< label >
Foam::edgeExtractor::updateMeshPatches
void updateMeshPatches()
update mesh with selected patches
Definition: edgeExtractor.C:2544
Foam::meshSurfacePartitioner
Definition: meshSurfacePartitioner.H:52
Foam::edgeExtractor::faceEvaluator::~faceEvaluator
~faceEvaluator()
Definition: edgeExtractorCorners.C:345
Foam::edgeExtractor::cornerEvaluator::partitioner_
const meshSurfacePartitioner & partitioner_
const reference to meshSurfacePartitioner
Definition: edgeExtractor.H:289
Foam::edgeExtractor::faceEvaluator::neiPatchesOverEdges
void neiPatchesOverEdges(const label bfI, const labelList &fPatches, const Map< label > &otherFacePatch, DynList< label > &neiPatches) const
calculate neighbour patches over edges of a boundary face
Definition: edgeExtractorCorners.C:233
Foam::triSurfaceClassifyEdges
Definition: triSurfaceClassifyEdges.H:55
Foam::edgeExtractor::SINGLECELLEDGE
@ SINGLECELLEDGE
Definition: edgeExtractor.H:329
Foam::edgeExtractor::calculateDeformationMetricForEdge
scalar calculateDeformationMetricForEdge(const label beI, const label patch0, const label patch1) const
Definition: edgeExtractor.C:1347
Foam::edgeExtractor::meshOctree_
const meshOctree & meshOctree_
reference to the octree
Definition: edgeExtractor.H:75
Foam::edgeExtractor::cornerEvaluator::sortedFacesAtPoint
void sortedFacesAtPoint(const label, DynList< label > &) const
sort faces attached to a boundary point
Definition: edgeExtractorCorners.C:619
Foam::edgeExtractor::findNeiPatches
void findNeiPatches(const label, const Map< label > &, DynList< label > &) const
find neighbour patches over edges for a boundary face
Definition: edgeExtractor.C:1274
Foam::edgeExtractor::projectDeterminedFeatureVertices
void projectDeterminedFeatureVertices()
project the estimated corners and edges onto the surface mesh
Definition: edgeExtractor.C:2245
Foam::edgeExtractor::calculateValence
void calculateValence()
calculate point valence
Definition: edgeExtractor.C:62
Foam::edgeExtractor::faceEvaluator::neiFacesProcs
void neiFacesProcs(const label, DynList< label > &) const
find processors of faces over edges
Definition: edgeExtractorCorners.C:204
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::edgeExtractor::cornerEvaluator::faceMap_
std::map< label, DynList< DynList< labelledPoint, 6 > > > faceMap_
faces attached to points at inter-processor boundaries
Definition: edgeExtractor.H:292
Foam::meshOctree
Definition: meshOctree.H:55
Foam::edgeExtractor::cornerEvaluator::createParallelAddressing
void createParallelAddressing()
create addressing at inter-processor boundaries
Definition: edgeExtractorCorners.C:448
triSurf
A class for triangulated surface used in the meshing process. It is derived from points and facets wi...
Foam::edgeExtractor::surfEdgeClassificationPtr_
const triSurfaceClassifyEdges * surfEdgeClassificationPtr_
classification of edges in the surface mesh
Definition: edgeExtractor.H:81
Foam::edgeExtractor::FITSATCONVEXEDGE
@ FITSATCONVEXEDGE
Definition: edgeExtractor.H:330
labelLongList.H
Foam::edgeExtractor::cornerEvaluator::~cornerEvaluator
~cornerEvaluator()
Definition: edgeExtractorCorners.C:670
edgeExtractor
A class with a functions used to detect feature edges in the surface of the volume mesh and to detect...
Foam::edgeExtractor::facePatch_
labelList facePatch_
boundary face patch
Definition: edgeExtractor.H:90
meshOctree
Octree for mesh generation.
Foam::edgeExtractor::distributeBoundaryFacesNormalAlignment
bool distributeBoundaryFacesNormalAlignment()
move faces into the patch with the best alignment
Definition: edgeExtractor.C:929
Foam::edgeExtractor::faceEvaluator::calculateNeiPatchesParallel
void calculateNeiPatchesParallel()
calculate patches of faces over inter-processor boundaries
Definition: edgeExtractorCorners.C:58
Foam::edgeExtractor::findFaceCandidates
void findFaceCandidates(labelLongList &faceCandidates, const labelList *facePatchPtr=NULL, const Map< label > *otherFacePatchPtr=NULL) const
Definition: edgeExtractor.C:511
Foam::edgeExtractor::faceEvaluator::otherFacePatch_
Map< label > otherFacePatch_
calculated patches of faces over inter-processor boundaries
Definition: edgeExtractor.H:212
Foam::edgeExtractor::checkFacePatchesGeometry
bool checkFacePatchesGeometry()
Definition: edgeExtractor.C:2054
Foam::edgeExtractor::faceEvaluator::calculateNeiPatchesParallelNewPatches
void calculateNeiPatchesParallelNewPatches()
Definition: edgeExtractorCorners.C:110
Foam::edgeExtractor::findEdgeCandidates
void findEdgeCandidates()
Definition: edgeExtractor.C:1082
Foam::edgeExtractor::edgeExtractor
edgeExtractor(const edgeExtractor &)
Disallow default bitwise copy construct.
Foam::edgeExtractor::findOtherFacePatchesParallel
void findOtherFacePatchesParallel(Map< label > &otherFacePatch, const labelList *facePatchPtr=NULL) const
find patches over edges
Definition: edgeExtractor.C:594
Foam::edgeExtractor::faceEvaluator::bestPatchAfterModification
label bestPatchAfterModification(const label bfI) const
Definition: edgeExtractorCorners.C:394
Foam::edgeExtractor::faceEvaluator
Definition: edgeExtractor.H:205
Foam::edgeExtractor::faceEvaluator::setNewBoundaryPatches
void setNewBoundaryPatches(const labelList &newBoudaryPatches)
set the values for new boundary patches
Definition: edgeExtractorCorners.C:353
Foam::edgeExtractor::faceEvaluator::neiFacesOverEdges
void neiFacesOverEdges(const label, DynList< label > &) const
find neighbour faces over edges
Definition: edgeExtractorCorners.C:174
Foam::edgeExtractor::surfPartitionerPtr_
const triSurfacePartitioner * surfPartitionerPtr_
surface mesh partitioner
Definition: edgeExtractor.H:78
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::triSurf
Definition: triSurf.H:59
triSurfaceClassifyEdges
Divides the surface mesh into regions bounded by feature edges.
Foam::edgeExtractor::extractEdges
void extractEdges()
assemble the above functionality into a workflow
Definition: edgeExtractor.C:2398
Foam::meshSurfaceEngine
Definition: meshSurfaceEngine.H:54
Foam::edgeExtractor::edgeType_
LongList< direction > edgeType_
edge classification
Definition: edgeExtractor.H:96
DynList.H
Foam::edgeExtractor::findPatchesNearSurfaceFace
void findPatchesNearSurfaceFace()
Definition: edgeExtractor.C:197
Foam::edgeExtractor::findCornerCandidates
bool findCornerCandidates()
Definition: edgeExtractorCorners.C:817
Foam::edgeExtractor::cornerEvaluator::extractor_
const edgeExtractor & extractor_
const reference to the parent class
Definition: edgeExtractor.H:286