boundaryLayerOptimisation.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 
29 #include "meshSurfacePartitioner.H"
30 
31 // #define DEBUGSearch
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
42  mesh_(mesh),
43  meshSurfacePtr_(new meshSurfaceEngine(mesh)),
44  deleteMeshSurface_(true),
45  partitionerPtr_(NULL),
46  hairEdges_(),
47  hairEdgesAtBndPoint_(),
48  hairEdgesNearHairEdge_(),
49  isBndLayerBase_(),
50  isExitFace_(),
51  hairEdgeType_(),
52  thinnedHairEdge_(),
53  maxNumIterations_(5),
54  nSmoothNormals_(5),
55  relThicknessTol_(0.1),
56  featureSizeFactor_(0.3),
57  reCalculateNormals_(true)
58 {
60 }
61 
63 (
65  const meshSurfaceEngine& mse
66 )
67 :
68  mesh_(mesh),
69  meshSurfacePtr_(&mse),
70  deleteMeshSurface_(false),
71  partitionerPtr_(NULL),
72  hairEdges_(),
73  hairEdgesAtBndPoint_(),
74  hairEdgesNearHairEdge_(),
75  isBndLayerBase_(),
76  isExitFace_(),
77  hairEdgeType_(),
78  thinnedHairEdge_(),
79  maxNumIterations_(5),
80  nSmoothNormals_(5),
81  relThicknessTol_(0.15),
82  featureSizeFactor_(0.3),
83  reCalculateNormals_(true)
84 {
85  calculateHairEdges();
86 }
87 
88 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89 
91 {
93 
94  if( deleteMeshSurface_ )
96 }
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
101 (
102  const label maxNumIterations
103 )
104 {
105  maxNumIterations_ = maxNumIterations;
106 }
107 
109 (
110  const label nSmoothNormals
111 )
112 {
113  nSmoothNormals_ = nSmoothNormals;
114 }
115 
116 void boundaryLayerOptimisation::recalculateNormals(const bool shallRecalculate)
117 {
118  reCalculateNormals_ = shallRecalculate;
119 }
120 
122 (
123  const scalar relThicknessTol
124 )
125 {
126  relThicknessTol_ = relThicknessTol;
127 }
128 
130 (
131  const scalar featureSizeFactor
132 )
133 {
134  featureSizeFactor_ = featureSizeFactor;
135 }
136 
138 {
139  return hairEdges_;
140 }
141 
143 {
144  return hairEdgesAtBndPoint_;
145 }
146 
148 {
149  return isBndLayerBase_;
150 }
151 
153 {
154  return isExitFace_;
155 }
156 
158 (
159  const dictionary& meshDict,
160  boundaryLayerOptimisation& blOptimisation
161 )
162 {
163  if( meshDict.found("boundaryLayers") )
164  {
165  const dictionary& layersDict = meshDict.subDict("boundaryLayers");
166 
167  if( layersDict.found("optimiseLayer") )
168  {
169  const bool smoothLayers =
170  readBool(layersDict.lookup("optimiseLayer"));
171 
172  if( !smoothLayers )
173  return;
174  }
175 
176  if( layersDict.found("optimisationParameters") )
177  {
178  const dictionary& optParams =
179  layersDict.subDict("optimisationParameters");
180 
181  if( optParams.found("recalculateNormals") )
182  {
183  const bool recalculateNormals =
184  readBool(optParams.lookup("recalculateNormals"));
185 
186  blOptimisation.recalculateNormals(recalculateNormals);
187  }
188 
189  if( optParams.found("nSmoothNormals") )
190  {
191  const label nSmoothNormals =
192  readLabel(optParams.lookup("nSmoothNormals"));
193 
194  blOptimisation.setNumNormalsSmoothingIterations(nSmoothNormals);
195  }
196 
197  if( optParams.found("featureSizeFactor") )
198  {
199  const scalar featureSizeFactor =
200  readScalar(optParams.lookup("featureSizeFactor"));
201 
202  if( featureSizeFactor >= 1.0 || featureSizeFactor < 0.0 )
204  (
205  "void boundaryLayerOptimisation::optimiseLayer"
206  "(const dictionary&, boundaryLayerOptimisation&)"
207  ) << "Feature size factor is out"
208  << " of a valid range 0 to 1" << exit(FatalError);
209 
210  blOptimisation.setFeatureSizeFactor(featureSizeFactor);
211  }
212 
213  if( optParams.found("relThicknessTol") )
214  {
215  const scalar relThicknessTol =
216  readScalar(optParams.lookup("relThicknessTol"));
217 
218  if( relThicknessTol >= 1.0 || relThicknessTol < 0.0 )
220  (
221  "void boundaryLayerOptimisation::optimiseLayer"
222  "(const dictionary&, boundaryLayerOptimisation&)"
223  ) << "Relative thickness tolerance is out"
224  << " of a valid range 0 to 1" << exit(FatalError);
225 
226  blOptimisation.setRelativeThicknessTolerance(relThicknessTol);
227  }
228 
229  if( optParams.found("maxNumIterations") )
230  {
231  const label maxNumIterations =
232  readLabel(optParams.lookup("maxNumIterations"));
233 
234  blOptimisation.setMaxNumIterations(maxNumIterations);
235  }
236  }
237  }
238 }
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 } // End namespace Foam
243 
244 // ************************************************************************* //
Foam::boundaryLayerOptimisation::reCalculateNormals_
bool reCalculateNormals_
activate calculation of normals
Definition: boundaryLayerOptimisation.H:109
Foam::boundaryLayerOptimisation::isExitFace_
boolList isExitFace_
is boundary face part of a layer where a layer exits
Definition: boundaryLayerOptimisation.H:88
Foam::boundaryLayerOptimisation::recalculateNormals
void recalculateNormals(const bool)
shall normals be re-calculated (default true)
Definition: boundaryLayerOptimisation.C:116
Foam::boundaryLayerOptimisation::setFeatureSizeFactor
void setFeatureSizeFactor(const scalar)
set the feature size factor (default 0.3)
Definition: boundaryLayerOptimisation.C:130
Foam::boundaryLayerOptimisation::deleteMeshSurface_
const bool deleteMeshSurface_
Definition: boundaryLayerOptimisation.H:70
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::boundaryLayerOptimisation::calculateHairEdges
void calculateHairEdges()
calculate hairEdges
Definition: boundaryLayerOptimisationFunctions.C:226
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::LongList< edge >
Foam::deleteDemandDrivenData
void deleteDemandDrivenData(DataPtr &dataPtr)
Definition: demandDrivenData.H:40
Foam::boundaryLayerOptimisation::hairEdgesAtBndPoint_
VRWGraph hairEdgesAtBndPoint_
hair edges attached to a boundary point
Definition: boundaryLayerOptimisation.H:79
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::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::boundaryLayerOptimisation::meshSurfacePtr_
const meshSurfaceEngine * meshSurfacePtr_
const pointer to meshSurfaceEngine
Definition: boundaryLayerOptimisation.H:69
Foam::boundaryLayerOptimisation::setRelativeThicknessTolerance
void setRelativeThicknessTolerance(const scalar)
set the relative thickness tolerance (default 0.15)
Definition: boundaryLayerOptimisation.C:122
boundaryLayerOptimisation.H
Foam::boundaryLayerOptimisation::isBaseFace
const boolList & isBaseFace() const
Definition: boundaryLayerOptimisation.C:147
Foam::boundaryLayerOptimisation
Definition: boundaryLayerOptimisation.H:62
Foam::boundaryLayerOptimisation::boundaryLayerOptimisation
boundaryLayerOptimisation(const boundaryLayerOptimisation &)
Disallow default bitwise copy construct.
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::boundaryLayerOptimisation::setNumNormalsSmoothingIterations
void setNumNormalsSmoothingIterations(const label nSmoothNormal)
set the number of normal smoothing iterations (default is 5)
Definition: boundaryLayerOptimisation.C:109
Foam::boundaryLayerOptimisation::~boundaryLayerOptimisation
~boundaryLayerOptimisation()
Definition: boundaryLayerOptimisation.C:90
Foam::boundaryLayerOptimisation::hairEdges_
edgeLongList hairEdges_
boundary layer hairs
Definition: boundaryLayerOptimisation.H:76
Foam::boundaryLayerOptimisation::hairEdges
const edgeLongList & hairEdges() const
return hair edges
Definition: boundaryLayerOptimisation.C:137
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
Foam::boundaryLayerOptimisation::isExitFace
const boolList & isExitFace() const
boundary faces where the layers exit at the boundary
Definition: boundaryLayerOptimisation.C:152
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::boundaryLayerOptimisation::partitionerPtr_
const meshSurfacePartitioner * partitionerPtr_
mesh surface partitioner
Definition: boundaryLayerOptimisation.H:73
Foam::boundaryLayerOptimisation::isBndLayerBase_
boolList isBndLayerBase_
is boundary face a base for a prism in the bnd layer
Definition: boundaryLayerOptimisation.H:85
Foam::readLabel
label readLabel(Istream &is)
Definition: label.H:64
Foam::boundaryLayerOptimisation::setMaxNumIterations
void setMaxNumIterations(const label maxNumIterations)
set the maximum number of iterations
Definition: boundaryLayerOptimisation.C:101
Foam::boundaryLayerOptimisation::readSettings
static void readSettings(const dictionary &, boundaryLayerOptimisation &)
read the settings from dictionary
Definition: boundaryLayerOptimisation.C:158
Foam::boundaryLayerOptimisation::hairEdgesAtBndPoint
const VRWGraph & hairEdgesAtBndPoint() const
hair edges attached to a boundary point
Definition: boundaryLayerOptimisation.C:142
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::readBool
bool readBool(Istream &)
Definition: boolIO.C:60
Foam::dictionary::subDict
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:631
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::meshSurfaceEngine
Definition: meshSurfaceEngine.H:54
meshSurfacePartitioner.H