boundaryLayerOptimisation.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 Class
25  bondaryLayerOptimisation
26 
27 Description
28  A class intended for improving quality of boundary layer cells. It is intended
29  to be used on meshes with one boundary layer which can later be refined.
30 
31 SourceFiles
32  boundaryLayerOptimisation.C
33  boundaryLayerOptimisationFunctions.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef boundaryLayerOptimisation_H
38 #define boundaryLayerOptimisation_H
39 
40 #include "DynList.H"
41 #include "polyMeshGenModifier.H"
42 #include "labelLongList.H"
43 #include "boolList.H"
44 #include "edgeLongList.H"
45 
46 #include <map>
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward declarations
54 class polyMeshGen;
55 class meshSurfaceEngine;
57 class dictionary;
58 
59 /*---------------------------------------------------------------------------*\
60  Class boundaryLayerOptimisation Declaration
61 \*---------------------------------------------------------------------------*/
62 
64 {
65  // Private data
66  //- reference to polyMeshGen
68 
69  //- const pointer to meshSurfaceEngine
71  const bool deleteMeshSurface_;
72 
73  //- mesh surface partitioner
75 
76  //- boundary layer hairs
78 
79  //- hair edges attached to a boundary point
81 
82  //- hair edge to other hair edges
84 
85  //- is boundary face a base for a prism in the bnd layer
87 
88  //- is boundary face part of a layer where a layer exits
90 
91  //- classification of hair edges
93 
94  //- stores information where boundary hairs are made thinner
96 
97  //- maximum number of iterations
99 
100  //- number of iterations for smoothing of hairs
102 
103  //- relative tolerance for thickness variation
104  scalar relThicknessTol_;
105 
106  //- feature size factor used for curvature-based optimisation
107  scalar featureSizeFactor_;
108 
109  //- activate calculation of normals
110  bool reCalculateNormals_;
111 
112  // Private member functions
113  //- access to mesh surface
114  const meshSurfaceEngine& meshSurface() const;
115 
116  //- access to meshSurfacePartitioner
118 
119  //- calculate normal vector for all patches at a point
120  //- points can be filtered by a type of hair edges
121  typedef std::map<label, std::pair<point, scalar> > patchNormalType;
122  typedef std::map<label, patchNormalType> pointNormalsType;
124  (
125  const direction eType,
127  ) const;
128 
129  //- calculate normal vectors
131  (
132  const direction eType,
134  );
135 
136  //- calculate hairEdges
137  void calculateHairEdges();
138 
139  //- calculate hair vectors at the boundary
141 
142  //- optimise hair normals at the boundary
143  //- these are the regions where boundary layers exit the domain
145 
146  //- optimise hair normals inside the mesh
148 
149  //- calculate hair edges at a boundary faces
150  void hairEdgesAtBndFace
151  (
152  const label cellI,
153  const label baseFaceI,
155  ) const;
156 
157  //- calculate the thickness of the layer for edge heI
158  //- respective to the height of edge heJ
159  scalar calculateThickness
160  (
161  const label heI,
162  const label heJ
163  ) const;
164 
165  //- calculate thickness of the layer by checking intersections
166  //- between the hair edge and the quad faces extruded from
167  //- nighbouring faces
169  (
170  const label heI,
171  const label cellI,
172  const label baseFaceI
173  ) const;
174 
175  //- optimise thickness variation
177  (
178  const direction edgeType = (INSIDE|BOUNDARY)
179  );
180 
181  //- optimise layers at exitting faces due to requests from the inside
183 
184  //- write vectors into a VTK file. Helper for debugging
185  static void writeVTK
186  (
187  const fileName& fName,
188  const pointField& origin,
189  const vectorField& vecs
190  );
191 
192  //- write vector correcposing to hair edges. Helper for debugging
193  void writeHairEdges
194  (
195  const fileName& fName,
196  const direction eType,
197  const vectorField& vecs
198  ) const;
199 
200  //- write selected hair edges into a file
201  void writeHairEdges(const fileName& fName, const direction eType) const;
202 
203  //- Disallow default bitwise copy construct
205 
206  //- Disallow default bitwise assignment
208 
209  // Private enumerators
210 
211  enum hairEdgeTypes_
212  {
213  NONE = 0,
214  ATEDGE = 1,
215  ATCORNER = 2,
216  BOUNDARY = 4,
217  INSIDE = 8,
218  FEATUREEDGE = 16
219  };
220 
221 public:
222 
223  // Constructors
224  //- construct from polyMeshGen
226 
227  //- Construct from polyMeshGen and meshSurfaceEngine
229  (
230  polyMeshGen& mesh,
231  const meshSurfaceEngine&
232  );
233 
234 
235  // Destructor
236 
238 
239  // Member Functions
240  //- set the maximum number of iterations
241  void setMaxNumIterations(const label maxNumIterations);
242 
243  //- set the number of normal smoothing iterations (default is 5)
244  void setNumNormalsSmoothingIterations(const label nSmoothNormal);
245 
246  //- shall normals be re-calculated (default true)
247  void recalculateNormals(const bool);
248 
249  //- set the relative thickness tolerance (default 0.15)
250  void setRelativeThicknessTolerance(const scalar);
251 
252  //- set the feature size factor (default 0.3)
253  void setFeatureSizeFactor(const scalar);
254 
255  //- return hair edges
256  const edgeLongList& hairEdges() const;
257 
258  //- hair edges attached to a boundary point
259  const VRWGraph& hairEdgesAtBndPoint() const;
260 
261  //- boundary faces which serve as base faces of a boundary layer
262  //- are set to true
263  const boolList& isBaseFace() const;
264 
265  //- boundary faces where the layers exit at the boundary
266  const boolList& isExitFace() const;
267 
268  //- performs boundary layer optimisation
269  void optimiseLayer();
270 
271  // Static member functions
272  //- read the settings from dictionary
273  static void readSettings
274  (
275  const dictionary&,
277  );
278 };
279 
280 
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 
283 } // End namespace Foam
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #endif
288 
289 // ************************************************************************* //
Foam::boundaryLayerOptimisation::featureSizeFactor_
scalar featureSizeFactor_
feature size factor used for curvature-based optimisation
Definition: boundaryLayerOptimisation.H:106
Foam::boundaryLayerOptimisation::ATEDGE
@ ATEDGE
Definition: boundaryLayerOptimisation.H:213
Foam::boundaryLayerOptimisation::ATCORNER
@ ATCORNER
Definition: boundaryLayerOptimisation.H:214
boolList.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
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::relThicknessTol_
scalar relThicknessTol_
relative tolerance for thickness variation
Definition: boundaryLayerOptimisation.H:103
Foam::boundaryLayerOptimisation::FEATUREEDGE
@ FEATUREEDGE
Definition: boundaryLayerOptimisation.H:217
meshSurfaceEngine
Calculates surface of the mesh.
Foam::boundaryLayerOptimisation::optimiseHairNormalsInside
void optimiseHairNormalsInside()
optimise hair normals inside the mesh
Definition: boundaryLayerOptimisationNormals.C:825
Foam::boundaryLayerOptimisation::nSmoothNormals_
label nSmoothNormals_
number of iterations for smoothing of hairs
Definition: boundaryLayerOptimisation.H:100
Foam::boundaryLayerOptimisation::optimiseHairNormalsAtTheBoundary
void optimiseHairNormalsAtTheBoundary()
Definition: boundaryLayerOptimisationNormals.C:552
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
polyMeshGenModifier.H
Foam::boundaryLayerOptimisation::calculateHairEdges
void calculateHairEdges()
calculate hairEdges
Definition: boundaryLayerOptimisationFunctions.C:226
Foam::boundaryLayerOptimisation::pointNormalsType
std::map< label, patchNormalType > pointNormalsType
Definition: boundaryLayerOptimisation.H:121
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::boundaryLayerOptimisation::BOUNDARY
@ BOUNDARY
Definition: boundaryLayerOptimisation.H:215
polyMeshGen
Mesh with selections.
Foam::boundaryLayerOptimisation::thinnedHairEdge_
boolList thinnedHairEdge_
stores information where boundary hairs are made thinner
Definition: boundaryLayerOptimisation.H:94
Foam::boundaryLayerOptimisation::hairEdgeTypes_
hairEdgeTypes_
Definition: boundaryLayerOptimisation.H:210
Foam::boundaryLayerOptimisation::calculateNormalVectorsSmother
void calculateNormalVectorsSmother(const direction eType, pointNormalsType &)
calculate normal vectors
Definition: boundaryLayerOptimisationNormals.C:196
Foam::boundaryLayerOptimisation::hairEdgesAtBndFace
void hairEdgesAtBndFace(const label cellI, const label baseFaceI, DynList< edge > &) const
calculate hair edges at a boundary faces
Definition: boundaryLayerOptimisationThickness.C:49
Foam::boundaryLayerOptimisation::calculateThickness
scalar calculateThickness(const label heI, const label heJ) const
Definition: boundaryLayerOptimisationThickness.C:138
Foam::LongList< edge >
Foam::boundaryLayerOptimisation::NONE
@ NONE
Definition: boundaryLayerOptimisation.H:212
Foam::boundaryLayerOptimisation::patchNormalType
std::map< label, std::pair< point, scalar > > patchNormalType
Definition: boundaryLayerOptimisation.H:120
Foam::boundaryLayerOptimisation::writeVTK
static void writeVTK(const fileName &fName, const pointField &origin, const vectorField &vecs)
write vectors into a VTK file. Helper for debugging
Definition: boundaryLayerOptimisationFunctions.C:58
Foam::boundaryLayerOptimisation::hairEdgesNearHairEdge_
VRWGraph hairEdgesNearHairEdge_
hair edge to other hair edges
Definition: boundaryLayerOptimisation.H:82
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::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
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
edgeLongList.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::boundaryLayerOptimisation::optimiseLayer
void optimiseLayer()
performs boundary layer optimisation
Definition: boundaryLayerOptimisationFunctions.C:533
meshSurfacePartitioner
Finds corners and edge points at the surface of the volume mesh.
Foam::boundaryLayerOptimisation::operator=
void operator=(const boundaryLayerOptimisation &)
Disallow default bitwise assignment.
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::boundaryLayerOptimisation::optimiseLayersAtExittingFaces
bool optimiseLayersAtExittingFaces()
optimise layers at exitting faces due to requests from the inside
Definition: boundaryLayerOptimisationFunctions.C:481
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::DynList
Definition: DynList.H:53
Foam::boundaryLayerOptimisation::meshSurface
const meshSurfaceEngine & meshSurface() const
access to mesh surface
Definition: boundaryLayerOptimisationFunctions.C:187
Foam::meshSurfacePartitioner
Definition: meshSurfacePartitioner.H:52
Foam::boundaryLayerOptimisation::mesh_
polyMeshGen & mesh_
reference to polyMeshGen
Definition: boundaryLayerOptimisation.H:66
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::optimiseThicknessVariation
void optimiseThicknessVariation(const direction edgeType=(INSIDE|BOUNDARY))
optimise thickness variation
Definition: boundaryLayerOptimisationThickness.C:287
Foam::boundaryLayerOptimisation::hairEdges_
edgeLongList hairEdges_
boundary layer hairs
Definition: boundaryLayerOptimisation.H:76
Foam::boundaryLayerOptimisation::calculateThicknessOverCell
scalar calculateThicknessOverCell(const label heI, const label cellI, const label baseFaceI) const
Definition: boundaryLayerOptimisationThickness.C:236
Foam::boundaryLayerOptimisation::hairEdges
const edgeLongList & hairEdges() const
return hair edges
Definition: boundaryLayerOptimisation.C:137
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
labelLongList.H
Foam::direction
unsigned char direction
Definition: direction.H:43
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::surfacePartitioner
const meshSurfacePartitioner & surfacePartitioner() const
access to meshSurfacePartitioner
Definition: boundaryLayerOptimisationFunctions.C:207
Foam::boundaryLayerOptimisation::INSIDE
@ INSIDE
Definition: boundaryLayerOptimisation.H:216
Foam::boundaryLayerOptimisation::hairEdgesAtBndPoint
const VRWGraph & hairEdgesAtBndPoint() const
hair edges attached to a boundary point
Definition: boundaryLayerOptimisation.C:142
Foam::boundaryLayerOptimisation::writeHairEdges
void writeHairEdges(const fileName &fName, const direction eType, const vectorField &vecs) const
write vector correcposing to hair edges. Helper for debugging
Definition: boundaryLayerOptimisationFunctions.C:104
Foam::boundaryLayerOptimisation::calculateHairVectorsAtTheBoundary
void calculateHairVectorsAtTheBoundary(vectorField &)
calculate hair vectors at the boundary
Definition: boundaryLayerOptimisationNormals.C:323
Foam::boundaryLayerOptimisation::hairEdgeType_
List< direction > hairEdgeType_
classification of hair edges
Definition: boundaryLayerOptimisation.H:91
Foam::boundaryLayerOptimisation::maxNumIterations_
label maxNumIterations_
maximum number of iterations
Definition: boundaryLayerOptimisation.H:97
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::meshSurfaceEngine
Definition: meshSurfaceEngine.H:54
DynList.H
Foam::boundaryLayerOptimisation::calculateNormalVectors
void calculateNormalVectors(const direction eType, pointNormalsType &) const
Definition: boundaryLayerOptimisationNormals.C:55