layerParameters.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::layerParameters
26 
27 Description
28  Simple container to keep together layer specific information.
29 
30 SourceFiles
31  layerParameters.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef layerParameters_H
36 #define layerParameters_H
37 
38 #include "dictionary.H"
39 #include "scalarField.H"
40 #include "labelList.H"
41 #include "Switch.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Class forward declarations
49 class polyBoundaryMesh;
50 class refinementSurfaces;
51 
52 /*---------------------------------------------------------------------------*\
53  Class layerParameters Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class layerParameters
57 {
58 public:
59 
60  // Public data types
61 
62  //- Enumeration defining the layer specification:
63  //
64  // - first and total thickness specified
65  // - first and expansion ratio specified
66  // - final and total thickness specified
67  // - final and expansion ratio specified
68  // - total thickness and expansion ratio specified
70  {
77  };
78 
79  //- Enumeration defining whether to merge faces on a given patch. Read
80  // as a boolean (no/yes). Defaults to merging only on patches which
81  // were meshed/snapped to (ifOnMeshedPatch).
82  enum class mergeFace
83  {
84  no,
86  yes
87  };
88 
89 
90 private:
91 
92  // Static Data Members
93 
94  //- Default angle for faces to be convcave
95  static const scalar defaultConcaveAngle;
96 
97 
98  // Private Data
99 
100  const dictionary dict_;
101 
102 
103  // Per patch (not region!) information
104 
105  //- How many layers to add.
106  labelList numLayers_;
107 
108  //- Are sizes relative to local cell size
109  Switch relativeSizes_;
110 
111  //- How thickness is specified.
112  layerSpecification layerSpec_;
113 
114  scalarField firstLayerThickness_;
115 
116  scalarField finalLayerThickness_;
117 
118  scalarField thickness_;
119 
120  scalarField expansionRatio_;
121 
122  //- Minimum total thickness
123  scalarField minThickness_;
124 
125  //- Whether to merge boundary faces of the same layer cell
126  List<mergeFace> mergeFaces_;
127 
128 
129  scalar featureAngle_;
130 
131  scalar concaveAngle_;
132 
133  label nGrow_;
134 
135  scalar maxFaceThicknessRatio_;
136 
137  label nBufferCellsNoExtrude_;
138 
139  label nLayerIter_;
140 
141  label nRelaxedIter_;
142 
143  Switch additionalReporting_;
144 
145  word meshShrinker_;
146 
147 
148  // Private Member Functions
149 
150  //- Calculate expansion ratio from overall size v.s. thickness of
151  // first layer.
152  scalar layerExpansionRatio
153  (
154  const label n,
155  const scalar totalOverFirst
156  ) const;
157 
158 
159 public:
160 
161  // Constructors
162 
163  //- Construct from dictionary
165 
166  //- Disallow default bitwise copy construction
167  layerParameters(const layerParameters&) = delete;
168 
169 
170  // Member Functions
172  const dictionary& dict() const
173  {
174  return dict_;
175  }
176 
177 
178  // Per patch information
179 
180  //- How many layers to add:
181  //
182  // - -1 : no specification. Assume 0 layers but allow sliding
183  // to make layers
184  // - 0 : specified to have 0 layers. No sliding allowed.
185  // - >0 : number of layers
186  const labelList& numLayers() const
187  {
188  return numLayers_;
189  }
190 
191  //- Are size parameters relative to inner cell size or
192  // absolute distances.
193  bool relativeSizes() const
194  {
195  return relativeSizes_;
196  }
197 
198  // Expansion factor for layer mesh
199  const scalarField& expansionRatio() const
200  {
201  return expansionRatio_;
202  }
203 
204  //- Wanted thickness of the layer furthest away
205  // from the wall (i.e. nearest the original mesh).
206  // If relativeSize() this number is relative to undistorted
207  // size of the cell outside layer.
208  const scalarField& finalLayerThickness() const
209  {
210  return finalLayerThickness_;
211  }
212 
213  //- Wanted thickness of the layer nearest to the wall.
214  // If relativeSize() this number is relative to undistorted
215  // size of the cell outside layer.
216  const scalarField& firstLayerThickness() const
217  {
218  return firstLayerThickness_;
219  }
220 
221  //- Wanted overall thickness of all layers.
222  // If relativeSize() this number is relative to undistorted
223  // size of the cell outside layer.
224  const scalarField& thickness() const
225  {
226  return thickness_;
227  }
228 
229  //- Minimum overall thickness of cell layer. If for any reason layer
230  // cannot be above minThickness do not add layer.
231  // If relativeSize() this number is relative to undistorted
232  // size of the cell outside layer.
233  const scalarField& minThickness() const
234  {
235  return minThickness_;
236  }
237 
238  //- Whether to merge boundary faces of the same layer cell
239  const List<mergeFace>& mergeFaces() const
240  {
241  return mergeFaces_;
242  }
243 
244 
245  // Control
246 
247  //- Number of overall layer addition iterations
248  label nLayerIter() const
249  {
250  return nLayerIter_;
251  }
252 
253  //- Number of iterations after which relaxed motion rules
254  // are to be used.
255  label nRelaxedIter() const
256  {
257  return nRelaxedIter_;
258  }
259 
260 
261  // Control
263  scalar featureAngle() const
264  {
265  return featureAngle_;
266  }
268  scalar concaveAngle() const
269  {
270  return concaveAngle_;
271  }
272 
273  //- If points get not extruded do nGrow layers of connected faces
274  // that are not grown. Is used to not do layers at all close to
275  // features.
276  label nGrow() const
277  {
278  return nGrow_;
279  }
280 
281  //- Stop layer growth on highly warped cells
282  scalar maxFaceThicknessRatio() const
283  {
284  return maxFaceThicknessRatio_;
285  }
286 
287  //- Create buffer region for new layer terminations
289  {
290  return nBufferCellsNoExtrude_;
291  }
293  const Switch& additionalReporting() const
294  {
295  return additionalReporting_;
296  }
297 
298  //- Type of mesh shrinker
299  const word& meshShrinker() const
300  {
301  return meshShrinker_;
302  }
303 
304 
305  // Helper
306 
307  //- Determine overall thickness. Uses two of the four parameters
308  // according to the layerSpecification
309  scalar layerThickness
310  (
311  const label nLayers,
312  const scalar firstLayerThickess,
313  const scalar finalLayerThickess,
314  const scalar totalThickness,
315  const scalar expansionRatio
316  ) const;
317 
318  //- Determine expansion ratio. Uses two of the four parameters
319  // according to the layerSpecification
320  scalar layerExpansionRatio
321  (
322  const label nLayers,
323  const scalar firstLayerThickess,
324  const scalar finalLayerThickess,
325  const scalar totalThickness,
326  const scalar expansionRatio
327  ) const;
328 
329  //- Determine first layer (near-wall) thickness. Uses two of the
330  // four parameters according to the layerSpecification
331  scalar firstLayerThickness
332  (
333  const label nLayers,
334  const scalar firstLayerThickess,
335  const scalar finalLayerThickess,
336  const scalar totalThickness,
337  const scalar expansionRatio
338  ) const;
339 
340  //- Determine ratio of final layer thickness to
341  // overall layer thickness
343  (
344  const label nLayers,
345  const scalar expansionRatio
346  ) const;
347 
348 
349  // Member Operators
350 
351  //- Disallow default bitwise assignment
352  void operator=(const layerParameters&) = delete;
353 };
354 
355 
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 
358 } // End namespace Foam
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 #endif
363 
364 // ************************************************************************* //
layerSpecification
Enumeration defining the layer specification:
Simple container to keep together layer specific information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
scalar concaveAngle() const
const List< mergeFace > & mergeFaces() const
Whether to merge boundary faces of the same layer cell.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
label nBufferCellsNoExtrude() const
Create buffer region for new layer terminations.
const dictionary & dict() const
const labelList & numLayers() const
How many layers to add:
label nRelaxedIter() const
Number of iterations after which relaxed motion rules.
mergeFace
Enumeration defining whether to merge faces on a given patch. Read.
scalar maxFaceThicknessRatio() const
Stop layer growth on highly warped cells.
scalar finalLayerThicknessRatio(const label nLayers, const scalar expansionRatio) const
Determine ratio of final layer thickness to.
void operator=(const layerParameters &)=delete
Disallow default bitwise assignment.
scalar layerThickness(const label nLayers, const scalar firstLayerThickess, const scalar finalLayerThickess, const scalar totalThickness, const scalar expansionRatio) const
Determine overall thickness. Uses two of the four parameters.
A class for handling words, derived from string.
Definition: word.H:59
const scalarField & firstLayerThickness() const
Wanted thickness of the layer nearest to the wall.
const scalarField & minThickness() const
Minimum overall thickness of cell layer. If for any reason layer.
layerParameters(const dictionary &dict, const polyBoundaryMesh &)
Construct from dictionary.
scalar featureAngle() const
label nLayerIter() const
Number of overall layer addition iterations.
Foam::polyBoundaryMesh.
const scalarField & expansionRatio() const
const scalarField & thickness() const
Wanted overall thickness of all layers.
bool relativeSizes() const
Are size parameters relative to inner cell size or.
label nGrow() const
If points get not extruded do nGrow layers of connected faces.
const scalarField & finalLayerThickness() const
Wanted thickness of the layer furthest away.
const word & meshShrinker() const
Type of mesh shrinker.
const Switch & additionalReporting() const
label n
Namespace for OpenFOAM.