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/>.
28 Refine existing boundary layers
31 refineBoundaryLayers.C
32 refineBoundaryLayersFunctions.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef refineBoundaryLayers_H
37 #define refineBoundaryLayers_H
39 #include "objectRegistry.H"
41 #include "polyMeshGenModifier.H"
42 #include "meshSurfaceEngine.H"
44 #include "labelLongList.H"
45 #include "labelPair.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // Forward declarations
56 class meshSurfaceEngine;
58 /*---------------------------------------------------------------------------*\
59 Class refineBoundaryLayers Declaration
60 \*---------------------------------------------------------------------------*/
62 class refineBoundaryLayers
64 //- Reference to the mesh
67 //- pointer to mesh surface engine
68 mutable meshSurfaceEngine* msePtr_;
70 //- global number of boundary layers
71 label globalNumLayers_;
73 //- global thickness ratio
74 scalar globalThicknessRatio_;
76 //- global maximum thickness of the first layer
77 scalar globalMaxThicknessFirstLayer_;
79 //- number of boundary layers for user-selected patches
80 std::map<word, label> numLayersForPatch_;
82 //- local thickness ratio for selected patches
83 std::map<word, scalar> thicknessRatioForPatch_;
85 //- local maximum layer thickness for selected patches
86 std::map<word, scalar> maxThicknessForPatch_;
88 //- allow discontinuous layers for patch
89 std::set<word> discontinuousLayersForPatch_;
91 //- the name of a subset which shall contain the indices
92 //- of the cells in the boundary layer
95 //- check whether the refinement is already executed
98 //- a flag whether a 2D mesh generation is active or not
101 //- shall the layer be refined into two layers with the first one
102 //- matching the thickness of the n-1 ones
105 //- information about existing boundary layers at patches
106 //- only available layers
107 List<DynList<label> > layerAtPatch_;
109 //- which patches are part of a single layer
110 List<DynList<word> > patchesInLayer_;
112 //- a containing the number of layers which shall be generated above
114 labelList nLayersAtBndFace_;
116 //- a list of edges which shall be refined
117 LongList<edge> splitEdges_;
119 //- split edges at point
120 VRWGraph splitEdgesAtPoint_;
122 //- new vertices for on edges which shall be refined
123 VRWGraph newVerticesForSplitEdge_;
125 //- a graph containing information which new faces were generated
126 //- from an existing face
127 VRWGraph facesFromFace_;
129 //- a graph containing faces after layer refinement
132 // Private member functions
133 //- Return reference to meshSurfaceEngine
134 const meshSurfaceEngine& surfaceEngine() const;
136 //- analyse layers to check their topology
137 bool analyseLayers();
139 //- generate new points on edges, faces and in cells
140 void generateNewVertices();
142 //- refine a given face and return the new faces
143 //- generates new points at cross-split faces
147 const FixedList<label, 2>& nLayersInDirection,
148 DynList<DynList<label, 4>, 128>& newFaces
151 //- generate a matrix of points generated by splitting a face
152 //- and return them in the local i, j system of the face
156 DynList<DynList<label> >& facePoints,
157 const label transpose = false
160 //- generate a matrix of faces generated by splitting a face
161 //- and return them in the local i, j, system of the face
165 DynList<DynList<label> >& faceFaces,
166 const label transpose = false
169 //- map split edges onto a cell
170 void generateNewFaces();
172 //- generate new cells for a prism with one boundary face
173 void generateNewCellsPrism
176 DynList<DynList<DynList<label, 8>, 10>, 64>& cellsFromCell
179 //- a helper function which stores faces generated from
180 //- an existing face into new cells
181 void storeFacesIntoCells
184 const bool reverseOrientation,
185 const label normalDirection,
186 const bool maxCoordinate,
187 const label nLayersI,
188 const label nLayersJ,
189 const label nLayersK,
190 DynList<DynList<DynList<label, 4>, 6>, 256>& cellsFromCell
193 //- generate new cells and add them to the mesh
194 void generateNewCells();
197 class refineEdgeHexCell
203 //- number of cells in local direction i
206 //- number of cells in locatiol direction j
209 //- container for new cells
210 DynList<DynList<DynList<label, 4>, 6>, 256> cellsFromCell_;
212 //- const reference to the boundary layer class
213 const refineBoundaryLayers& bndLayers_;
215 //- faces sorted into directions of a hex shape
216 FixedList<label, 6> faceInDirection_;
218 //- information about orientation of faces
219 //- false means the orientation as expected
220 //- true means wrong orientation
221 FixedList<bool, 6> faceOrientation_;
223 //- points on cross-split faces
224 FixedList<DynList<DynList<label> >, 2> cellPoints_;
226 // Private member functions
227 //- populate faceInDirection_nad wrongFaceOrientation_
228 void determineFacesInDirections();
230 //- populate new cells with new faces generated from already
232 void populateExistingFaces();
234 //- generate new internal faces and tore them to new cells
235 void generateMissingFaces();
240 //- construct from cell label and the refineBoundaryLayers
244 const refineBoundaryLayers& ref
247 // Public member functions
248 inline const DynList<DynList<DynList<label, 4>, 6>, 256>&
251 return cellsFromCell_;
255 class refineCornerHexCell
261 //- number of cells in local direction i
264 //- number of cells in local direction j
267 //- number of cells in local direction k
270 //- split edge in directions
271 FixedList<label, 3> splitEdgeInDirection_;
273 //- container for new cells
274 DynList<DynList<DynList<label, 4>, 6>, 256> cellsFromCell_;
276 //- reference to the boundary layer class
277 const refineBoundaryLayers& bndLayers_;
279 //- faces sorted into directions of a hex shape
280 FixedList<label, 6> faceInDirection_;
282 //- information about orientation of faces
283 //- false means the orientation as expected
284 //- true means wrong orientation
285 FixedList<bool, 6> faceOrientation_;
287 //- points on cross-split faces
288 FixedList<DynList<DynList<label> >, 6> facePoints_;
290 //- points inside the cell
291 DynList<DynList<DynList<label> > > cellPoints_;
293 // Private member functions
294 //- populate faceInDirection_nad wrongFaceOrientation_
295 void determineFacesInDirections();
297 //- populate new cells with new faces generated from already
299 void populateExistingFaces();
301 //- generate missing points inside the cell
302 void generateNewPoints();
304 //- generate new internal faces and tore them to new cells
305 void generateMissingFaces();
310 //- construct from cell label and the refineBoundaryLayers
314 const refineBoundaryLayers& ref
317 // Public member functions
318 inline const DynList<DynList<DynList<label, 4>, 6>, 256>&
321 return cellsFromCell_;
325 // Private member functions
327 //- Disallow bitwise copy construct
328 refineBoundaryLayers(const refineBoundaryLayers&);
330 //- Disallow bitwise assignment
331 void operator=(const refineBoundaryLayers&);
337 //- Construct from mesh reference
338 refineBoundaryLayers(polyMeshGen& mesh);
341 ~refineBoundaryLayers();
343 // Public member functions
346 //- set no refinement flag
347 void avoidRefinement();
349 //- activate 2D layer refinement
350 void activate2DMode();
352 //- set the global number of boundary layers
353 void setGlobalNumberOfLayers(const label nLayers);
355 //- set the global thickness ratio (default is 1)
356 void setGlobalThicknessRatio(const scalar thicknessRatio);
358 //- set the maximum thickness of the first boundary layer
359 void setGlobalMaxThicknessOfFirstLayer(const scalar maxThickness);
361 //- set the number of layers for a patch
362 //- the settings override the global settings
363 void setNumberOfLayersForPatch
365 const word& patchName,
369 //- set the thickness ratio for a patch
370 //- it overrides the global settings
371 void setThicknessRatioForPatch
373 const word& patchName,
374 const scalar thicknessRatio
377 //- set the maximum thickness of the first layer for a patch
378 void setMaxThicknessOfFirstLayerForPatch
380 const word& patchName,
381 const scalar maxThickness
384 //- set whether the settings for a given patch are valid for the
385 //- patch only, or whether they extend over th whole sheet
386 //- the selected patch belongs to
387 //- the default behaviour is to apply the patch settings to the whole
389 void setInteruptForPatch(const word& patchName);
391 //- set the flag to store the boundary layer cells in a subset
392 void setCellSubset(const word subsetName = "layerCells");
394 //- this flag refinement of a layer into a single one matching
395 //- the thickness of the n layers. This functionality is intended to
396 //- create additional layer that shall be improved by the boundary
397 //- layer smoother in order to leave the inside points intact
398 void activateSpecialMode();
401 //- performs refinement based on the given settings
405 //- provide the list of points in the boundary layer
406 void pointsInBndLayer(labelLongList&);
408 //- create a subset containing points in the boundary layer
409 void pointsInBndLayer(const word subsetName="pointsInBndLayer");
411 // Static member functions
412 //- read the settings from dictionary
413 static void readSettings(const dictionary&, refineBoundaryLayers&);
416 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
418 } // End namespace Foam
420 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
424 // ************************************************************************* //