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 "meshSurfaceOptimizer.H"
30 #include "meshSurfaceEngine.H"
31 #include "meshSurfacePartitioner.H"
32 #include "meshSurfaceMapper.H"
33 #include "polyMeshGenChecks.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 void meshSurfaceOptimizer::classifySurfaceVertices()
46 const labelHashSet& corners = partitionerPtr_->corners();
47 const labelHashSet& edgePoints = partitionerPtr_->edgePoints();
49 //- set all vertices to partition
50 vertexType_ = PARTITION;
53 forAllConstIter(labelHashSet, corners, it)
54 vertexType_[it.key()] = CORNER;
57 forAllConstIter(labelHashSet, edgePoints, it)
58 vertexType_[it.key()] = EDGE;
60 if( Pstream::parRun() )
62 //- mark nodes at parallel boundaries
63 const Map<label>& globalToLocal =
64 surfaceEngine_.globalToLocalBndPointAddressing();
66 forAllConstIter(Map<label>, globalToLocal, iter)
68 const label bpI = iter();
70 vertexType_[bpI] |= PROCBND;
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
77 meshSurfaceOptimizer::meshSurfaceOptimizer(const meshSurfaceEngine& surface)
79 surfaceEngine_(surface),
80 vertexType_(surface.boundaryPoints().size()),
81 partitionerPtr_(new meshSurfacePartitioner(surface)),
82 deletePartitioner_(true),
85 enforceConstraints_(false),
86 badPointsSubsetName_("invertedBoundaryPoints")
88 classifySurfaceVertices();
91 meshSurfaceOptimizer::meshSurfaceOptimizer(const meshSurfacePartitioner& mPart)
93 surfaceEngine_(mPart.surfaceEngine()),
94 vertexType_(surfaceEngine_.boundaryPoints().size()),
95 partitionerPtr_(&mPart),
96 deletePartitioner_(true),
99 enforceConstraints_(false),
100 badPointsSubsetName_("invertedBoundaryPoints")
102 classifySurfaceVertices();
105 meshSurfaceOptimizer::meshSurfaceOptimizer
107 const meshSurfaceEngine& surface,
108 const meshOctree& octree
111 surfaceEngine_(surface),
112 vertexType_(surface.boundaryPoints().size()),
113 partitionerPtr_(new meshSurfacePartitioner(surface)),
114 deletePartitioner_(true),
117 enforceConstraints_(false),
118 badPointsSubsetName_("invertedBoundaryPoints")
120 classifySurfaceVertices();
123 meshSurfaceOptimizer::meshSurfaceOptimizer
125 const meshSurfacePartitioner& partitioner,
126 const meshOctree& octree
129 surfaceEngine_(partitioner.surfaceEngine()),
130 vertexType_(surfaceEngine_.boundaryPoints().size()),
131 partitionerPtr_(&partitioner),
132 deletePartitioner_(false),
135 enforceConstraints_(false),
136 badPointsSubsetName_("invertedBoundaryPoints")
138 classifySurfaceVertices();
141 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
143 meshSurfaceOptimizer::~meshSurfaceOptimizer()
145 deleteDemandDrivenData(triMeshPtr_);
147 if( deletePartitioner_ )
148 deleteDemandDrivenData(partitionerPtr_);
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 void meshSurfaceOptimizer::removeUserConstraints()
156 # pragma omp parallel for schedule(dynamic, 100)
158 forAll(vertexType_, bpI)
159 if( vertexType_[bpI] & LOCKED )
160 vertexType_[bpI] ^= LOCKED;
163 void meshSurfaceOptimizer::enforceConstraints(const word subsetName)
165 enforceConstraints_ = true;
167 badPointsSubsetName_ = subsetName;
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // ************************************************************************* //