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 "boundaryLayerOptimisation.H"
29 #include "meshSurfacePartitioner.H"
31 // #define DEBUGSearch
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 boundaryLayerOptimisation::boundaryLayerOptimisation(polyMeshGen& mesh)
43 meshSurfacePtr_(new meshSurfaceEngine(mesh)),
44 deleteMeshSurface_(true),
45 partitionerPtr_(NULL),
47 hairEdgesAtBndPoint_(),
48 hairEdgesNearHairEdge_(),
55 relThicknessTol_(0.1),
56 featureSizeFactor_(0.3),
57 reCalculateNormals_(true)
62 boundaryLayerOptimisation::boundaryLayerOptimisation
65 const meshSurfaceEngine& mse
69 meshSurfacePtr_(&mse),
70 deleteMeshSurface_(false),
71 partitionerPtr_(NULL),
73 hairEdgesAtBndPoint_(),
74 hairEdgesNearHairEdge_(),
81 relThicknessTol_(0.15),
82 featureSizeFactor_(0.3),
83 reCalculateNormals_(true)
88 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
90 boundaryLayerOptimisation::~boundaryLayerOptimisation()
92 deleteDemandDrivenData(partitionerPtr_);
94 if( deleteMeshSurface_ )
95 deleteDemandDrivenData(meshSurfacePtr_);
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 void boundaryLayerOptimisation::setMaxNumIterations
102 const label maxNumIterations
105 maxNumIterations_ = maxNumIterations;
108 void boundaryLayerOptimisation::setNumNormalsSmoothingIterations
110 const label nSmoothNormals
113 nSmoothNormals_ = nSmoothNormals;
116 void boundaryLayerOptimisation::recalculateNormals(const bool shallRecalculate)
118 reCalculateNormals_ = shallRecalculate;
121 void boundaryLayerOptimisation::setRelativeThicknessTolerance
123 const scalar relThicknessTol
126 relThicknessTol_ = relThicknessTol;
129 void boundaryLayerOptimisation::setFeatureSizeFactor
131 const scalar featureSizeFactor
134 featureSizeFactor_ = featureSizeFactor;
137 const edgeLongList& boundaryLayerOptimisation::hairEdges() const
142 const VRWGraph& boundaryLayerOptimisation::hairEdgesAtBndPoint() const
144 return hairEdgesAtBndPoint_;
147 const boolList& boundaryLayerOptimisation::isBaseFace() const
149 return isBndLayerBase_;
152 const boolList& boundaryLayerOptimisation::isExitFace() const
157 void boundaryLayerOptimisation::readSettings
159 const dictionary& meshDict,
160 boundaryLayerOptimisation& blOptimisation
163 if( meshDict.found("boundaryLayers") )
165 const dictionary& layersDict = meshDict.subDict("boundaryLayers");
167 if( layersDict.found("optimiseLayer") )
169 const bool smoothLayers =
170 readBool(layersDict.lookup("optimiseLayer"));
176 if( layersDict.found("optimisationParameters") )
178 const dictionary& optParams =
179 layersDict.subDict("optimisationParameters");
181 if( optParams.found("recalculateNormals") )
183 const bool recalculateNormals =
184 readBool(optParams.lookup("recalculateNormals"));
186 blOptimisation.recalculateNormals(recalculateNormals);
189 if( optParams.found("nSmoothNormals") )
191 const label nSmoothNormals =
192 readLabel(optParams.lookup("nSmoothNormals"));
194 blOptimisation.setNumNormalsSmoothingIterations(nSmoothNormals);
197 if( optParams.found("featureSizeFactor") )
199 const scalar featureSizeFactor =
200 readScalar(optParams.lookup("featureSizeFactor"));
202 if( featureSizeFactor >= 1.0 || featureSizeFactor < 0.0 )
205 "void boundaryLayerOptimisation::optimiseLayer"
206 "(const dictionary&, boundaryLayerOptimisation&)"
207 ) << "Feature size factor is out"
208 << " of a valid range 0 to 1" << exit(FatalError);
210 blOptimisation.setFeatureSizeFactor(featureSizeFactor);
213 if( optParams.found("relThicknessTol") )
215 const scalar relThicknessTol =
216 readScalar(optParams.lookup("relThicknessTol"));
218 if( relThicknessTol >= 1.0 || relThicknessTol < 0.0 )
221 "void boundaryLayerOptimisation::optimiseLayer"
222 "(const dictionary&, boundaryLayerOptimisation&)"
223 ) << "Relative thickness tolerance is out"
224 << " of a valid range 0 to 1" << exit(FatalError);
226 blOptimisation.setRelativeThicknessTolerance(relThicknessTol);
229 if( optParams.found("maxNumIterations") )
231 const label maxNumIterations =
232 readLabel(optParams.lookup("maxNumIterations"));
234 blOptimisation.setMaxNumIterations(maxNumIterations);
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 // ************************************************************************* //