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/>.
25 bondaryLayerOptimisation
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.
32 boundaryLayerOptimisation.C
33 boundaryLayerOptimisationFunctions.C
35 \*---------------------------------------------------------------------------*/
37 #ifndef boundaryLayerOptimisation_H
38 #define boundaryLayerOptimisation_H
41 #include "polyMeshGenModifier.H"
42 #include "labelLongList.H"
44 #include "edgeLongList.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 // Forward declarations
55 class meshSurfaceEngine;
56 class meshSurfacePartitioner;
59 /*---------------------------------------------------------------------------*\
60 Class boundaryLayerOptimisation Declaration
61 \*---------------------------------------------------------------------------*/
63 class boundaryLayerOptimisation
66 //- reference to polyMeshGen
69 //- const pointer to meshSurfaceEngine
70 mutable const meshSurfaceEngine* meshSurfacePtr_;
71 const bool deleteMeshSurface_;
73 //- mesh surface partitioner
74 mutable const meshSurfacePartitioner* partitionerPtr_;
76 //- boundary layer hairs
77 edgeLongList hairEdges_;
79 //- hair edges attached to a boundary point
80 VRWGraph hairEdgesAtBndPoint_;
82 //- hair edge to other hair edges
83 VRWGraph hairEdgesNearHairEdge_;
85 //- is boundary face a base for a prism in the bnd layer
86 boolList isBndLayerBase_;
88 //- is boundary face part of a layer where a layer exits
91 //- classification of hair edges
92 List<direction> hairEdgeType_;
94 //- stores information where boundary hairs are made thinner
95 boolList thinnedHairEdge_;
97 //- maximum number of iterations
98 label maxNumIterations_;
100 //- number of iterations for smoothing of hairs
101 label nSmoothNormals_;
103 //- relative tolerance for thickness variation
104 scalar relThicknessTol_;
106 //- feature size factor used for curvature-based optimisation
107 scalar featureSizeFactor_;
109 //- activate calculation of normals
110 bool reCalculateNormals_;
112 // Private member functions
113 //- access to mesh surface
114 const meshSurfaceEngine& meshSurface() const;
116 //- access to meshSurfacePartitioner
117 const meshSurfacePartitioner& surfacePartitioner() const;
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;
123 void calculateNormalVectors
125 const direction eType,
129 //- calculate normal vectors
130 void calculateNormalVectorsSmother
132 const direction eType,
136 //- calculate hairEdges
137 void calculateHairEdges();
139 //- calculate hair vectors at the boundary
140 void calculateHairVectorsAtTheBoundary(vectorField&);
142 //- optimise hair normals at the boundary
143 //- these are the regions where boundary layers exit the domain
144 void optimiseHairNormalsAtTheBoundary();
146 //- optimise hair normals inside the mesh
147 void optimiseHairNormalsInside();
149 //- calculate hair edges at a boundary faces
150 void hairEdgesAtBndFace
153 const label baseFaceI,
157 //- calculate the thickness of the layer for edge heI
158 //- respective to the height of edge heJ
159 scalar calculateThickness
165 //- calculate thickness of the layer by checking intersections
166 //- between the hair edge and the quad faces extruded from
167 //- nighbouring faces
168 scalar calculateThicknessOverCell
172 const label baseFaceI
175 //- optimise thickness variation
176 void optimiseThicknessVariation
178 const direction edgeType = (INSIDE|BOUNDARY)
181 //- optimise layers at exitting faces due to requests from the inside
182 bool optimiseLayersAtExittingFaces();
184 //- write vectors into a VTK file. Helper for debugging
187 const fileName& fName,
188 const pointField& origin,
189 const vectorField& vecs
192 //- write vector correcposing to hair edges. Helper for debugging
195 const fileName& fName,
196 const direction eType,
197 const vectorField& vecs
200 //- write selected hair edges into a file
201 void writeHairEdges(const fileName& fName, const direction eType) const;
203 //- Disallow default bitwise copy construct
204 boundaryLayerOptimisation(const boundaryLayerOptimisation&);
206 //- Disallow default bitwise assignment
207 void operator=(const boundaryLayerOptimisation&);
209 // Private enumerators
224 //- construct from polyMeshGen
225 boundaryLayerOptimisation(polyMeshGen& mesh);
227 //- Construct from polyMeshGen and meshSurfaceEngine
228 boundaryLayerOptimisation
231 const meshSurfaceEngine&
237 ~boundaryLayerOptimisation();
240 //- set the maximum number of iterations
241 void setMaxNumIterations(const label maxNumIterations);
243 //- set the number of normal smoothing iterations (default is 5)
244 void setNumNormalsSmoothingIterations(const label nSmoothNormal);
246 //- shall normals be re-calculated (default true)
247 void recalculateNormals(const bool);
249 //- set the relative thickness tolerance (default 0.15)
250 void setRelativeThicknessTolerance(const scalar);
252 //- set the feature size factor (default 0.3)
253 void setFeatureSizeFactor(const scalar);
255 //- return hair edges
256 const edgeLongList& hairEdges() const;
258 //- hair edges attached to a boundary point
259 const VRWGraph& hairEdgesAtBndPoint() const;
261 //- boundary faces which serve as base faces of a boundary layer
263 const boolList& isBaseFace() const;
265 //- boundary faces where the layers exit at the boundary
266 const boolList& isExitFace() const;
268 //- performs boundary layer optimisation
269 void optimiseLayer();
271 // Static member functions
272 //- read the settings from dictionary
273 static void readSettings
276 boundaryLayerOptimisation&
281 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 } // End namespace Foam
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 // ************************************************************************* //