meshSurfaceOptimizer.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"
29 #include "meshSurfaceOptimizer.H"
30 #include "meshSurfaceEngine.H"
31 #include "meshSurfacePartitioner.H"
32 #include "meshSurfaceMapper.H"
33 #include "polyMeshGenChecks.H"
34 
35 #include <map>
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
45 {
46  const labelHashSet& corners = partitionerPtr_->corners();
47  const labelHashSet& edgePoints = partitionerPtr_->edgePoints();
48 
49  //- set all vertices to partition
51 
52  //- set corners
53  forAllConstIter(labelHashSet, corners, it)
54  vertexType_[it.key()] = CORNER;
55 
56  //- set edges
57  forAllConstIter(labelHashSet, edgePoints, it)
58  vertexType_[it.key()] = EDGE;
59 
60  if( Pstream::parRun() )
61  {
62  //- mark nodes at parallel boundaries
63  const Map<label>& globalToLocal =
65 
66  forAllConstIter(Map<label>, globalToLocal, iter)
67  {
68  const label bpI = iter();
69 
70  vertexType_[bpI] |= PROCBND;
71  }
72  }
73 }
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
78 :
79  surfaceEngine_(surface),
80  vertexType_(surface.boundaryPoints().size()),
81  partitionerPtr_(new meshSurfacePartitioner(surface)),
82  deletePartitioner_(true),
83  octreePtr_(NULL),
84  triMeshPtr_(NULL),
85  enforceConstraints_(false),
86  badPointsSubsetName_("invertedBoundaryPoints")
87 {
89 }
90 
92 :
93  surfaceEngine_(mPart.surfaceEngine()),
94  vertexType_(surfaceEngine_.boundaryPoints().size()),
95  partitionerPtr_(&mPart),
96  deletePartitioner_(true),
97  octreePtr_(NULL),
98  triMeshPtr_(NULL),
99  enforceConstraints_(false),
100  badPointsSubsetName_("invertedBoundaryPoints")
101 {
103 }
104 
106 (
107  const meshSurfaceEngine& surface,
108  const meshOctree& octree
109 )
110 :
111  surfaceEngine_(surface),
112  vertexType_(surface.boundaryPoints().size()),
113  partitionerPtr_(new meshSurfacePartitioner(surface)),
114  deletePartitioner_(true),
115  octreePtr_(&octree),
116  triMeshPtr_(NULL),
117  enforceConstraints_(false),
118  badPointsSubsetName_("invertedBoundaryPoints")
119 {
120  classifySurfaceVertices();
121 }
122 
124 (
125  const meshSurfacePartitioner& partitioner,
126  const meshOctree& octree
127 )
128 :
129  surfaceEngine_(partitioner.surfaceEngine()),
130  vertexType_(surfaceEngine_.boundaryPoints().size()),
131  partitionerPtr_(&partitioner),
132  deletePartitioner_(false),
133  octreePtr_(&octree),
134  triMeshPtr_(NULL),
135  enforceConstraints_(false),
136  badPointsSubsetName_("invertedBoundaryPoints")
137 {
138  classifySurfaceVertices();
139 }
140 
141 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
142 
144 {
146 
147  if( deletePartitioner_ )
149 }
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
154 {
155  # ifdef USE_OMP
156  # pragma omp parallel for schedule(dynamic, 100)
157  # endif
158  forAll(vertexType_, bpI)
159  if( vertexType_[bpI] & LOCKED )
160  vertexType_[bpI] ^= LOCKED;
161 }
162 
164 {
165  enforceConstraints_ = true;
166 
167  badPointsSubsetName_ = subsetName;
168 }
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // ************************************************************************* //
Foam::meshSurfaceOptimizer::~meshSurfaceOptimizer
~meshSurfaceOptimizer()
Definition: meshSurfaceOptimizer.C:143
Foam::meshSurfaceOptimizer::deletePartitioner_
const bool deletePartitioner_
Definition: meshSurfaceOptimizer.H:77
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::meshSurfaceOptimizer::meshSurfaceOptimizer
meshSurfaceOptimizer(const meshSurfaceOptimizer &)
Disallow default bitwise copy construct.
meshSurfaceMapper.H
Foam::meshSurfaceOptimizer::classifySurfaceVertices
void classifySurfaceVertices()
classify surface vertices as PARTITION, EDGE, CORNER
Definition: meshSurfaceOptimizer.C:44
Foam::meshSurfaceOptimizer::triMeshPtr_
partTriMesh * triMeshPtr_
mesh of surface triangles needed for some smoothers
Definition: meshSurfaceOptimizer.H:83
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::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::meshSurfaceOptimizer::LOCKED
@ LOCKED
Definition: meshSurfaceOptimizer.H:248
Foam::Map< label >
Foam::meshSurfaceOptimizer::PROCBND
@ PROCBND
Definition: meshSurfaceOptimizer.H:247
Foam::meshSurfaceOptimizer::badPointsSubsetName_
word badPointsSubsetName_
name of the subset contaning tangled points
Definition: meshSurfaceOptimizer.H:89
Foam::HashSet< label, Hash< label > >
Foam::meshSurfacePartitioner::surfaceEngine
const meshSurfaceEngine & surfaceEngine() const
return const reference to meshSurfaceEngine
Definition: meshSurfacePartitioner.H:109
polyMeshGenChecks.H
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::meshSurfaceOptimizer::PARTITION
@ PARTITION
Definition: meshSurfaceOptimizer.H:244
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
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::meshSurfaceOptimizer::vertexType_
List< direction > vertexType_
type of surface vertex
Definition: meshSurfaceOptimizer.H:70
Foam::meshSurfaceOptimizer::CORNER
@ CORNER
Definition: meshSurfaceOptimizer.H:246
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
meshSurfaceEngine.H
Foam::meshSurfaceOptimizer::surfaceEngine_
const meshSurfaceEngine & surfaceEngine_
const reference to the mesh surface
Definition: meshSurfaceOptimizer.H:67
Foam::meshSurfacePartitioner
Definition: meshSurfacePartitioner.H:52
Foam::meshSurfaceOptimizer::enforceConstraints
void enforceConstraints(const word subsetName="badPoints")
Definition: meshSurfaceOptimizer.C:163
Foam::meshSurfacePartitioner::edgePoints
const labelHashSet & edgePoints() const
return labels of edge points (from the list of boundary points)
Definition: meshSurfacePartitioner.H:135
Foam::meshOctree
Definition: meshOctree.H:55
Foam::meshSurfaceOptimizer::enforceConstraints_
bool enforceConstraints_
enforce constraints
Definition: meshSurfaceOptimizer.H:86
Foam::meshSurfaceOptimizer::removeUserConstraints
void removeUserConstraints()
reset to default constraints
Definition: meshSurfaceOptimizer.C:153
Foam::surface
Definition: surface.H:55
Foam::meshSurfaceEngine::globalToLocalBndPointAddressing
const Map< label > & globalToLocalBndPointAddressing() const
global point label to local label. Only for processors points
Definition: meshSurfaceEngineI.H:431
Foam::meshSurfacePartitioner::corners
const labelHashSet & corners() const
return labels of corner points (from the list of boundary points)
Definition: meshSurfacePartitioner.H:129
meshSurfaceOptimizer.H
Foam::meshSurfaceEngine
Definition: meshSurfaceEngine.H:54
Foam::meshSurfaceOptimizer::EDGE
@ EDGE
Definition: meshSurfaceOptimizer.H:245
meshSurfacePartitioner.H
Foam::meshSurfaceOptimizer::partitionerPtr_
const meshSurfacePartitioner * partitionerPtr_
surface partitioner
Definition: meshSurfaceOptimizer.H:76