layerParameters.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::layerParameters
28 
29 Description
30  Simple container to keep together layer specific information.
31 
32 SourceFiles
33  layerParameters.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef layerParameters_H
38 #define layerParameters_H
39 
40 #include "dictionary.H"
41 #include "scalarField.H"
42 #include "labelList.H"
43 #include "Switch.H"
44 #include "Enum.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Class forward declarations
52 class polyBoundaryMesh;
53 class refinementSurfaces;
54 
55 /*---------------------------------------------------------------------------*\
56  Class layerParameters Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class layerParameters
60 {
61 public:
62 
63  // Public data types
64 
65  //- Enumeration defining the layer specification:
66  // - first and total thickness specified
67  // - first and expansion ratio specified
68  // - final and total thickness specified
69  // - final and expansion ratio specified
70  // - total thickness and expansion ratio specified
72  {
79  };
80 
81 
82 private:
83 
84  // Static data members
85 
86  //- Default angle for faces to be concave
87  static const scalar defaultConcaveAngle;
88 
89  //- thicknessModelType names
90  static const Enum<thicknessModelType> thicknessModelTypeNames_;
91 
92 
93  // Private Data
94 
95  const dictionary dict_;
96 
97  //- In dry-run mode?
98  const bool dryRun_;
99 
100 
101  // Per patch (not region!) information
102 
103  //- How many layers to add.
104  labelList numLayers_;
105 
106  //- Are sizes relative to local cell size
107  boolList relativeSizes_;
108 
109  //- How thickness is specified.
110  List<thicknessModelType> layerModels_;
111 
112  scalarField firstLayerThickness_;
113 
114  scalarField finalLayerThickness_;
115 
116  scalarField thickness_;
117 
118  scalarField expansionRatio_;
119 
120  //- Minimum total thickness
121  scalarField minThickness_;
122 
123 
124  scalar featureAngle_;
125 
126  scalar mergePatchFacesAngle_;
127 
128  scalar concaveAngle_;
129 
130  label nGrow_;
131 
132  scalar maxFaceThicknessRatio_;
133 
134  label nBufferCellsNoExtrude_;
135 
136  label nLayerIter_;
137 
138  label nRelaxedIter_;
139 
140  //- Any additional reporting
141  bool additionalReporting_;
142 
143  word meshShrinker_;
144 
145 
146  // Private Member Functions
147 
148  //- Calculate expansion ratio from overall size v.s. thickness of
149  // first layer.
150  static scalar layerExpansionRatio
151  (
152  const label n,
153  const scalar totalOverFirst
154  );
155 
156  //- Read parameters according to thickness model
157  static void readLayerParameters
158  (
159  const bool verbose,
160  const dictionary&,
161  const thicknessModelType& spec,
162  scalar& firstLayerThickness,
163  scalar& finalLayerThickness,
164  scalar& thickness,
165  scalar& expansionRatio
166  );
167 
168  void calculateLayerParameters
169  (
170  const thicknessModelType& spec,
171  const label nLayers,
172  scalar& firstLayerThickness,
173  scalar& finalLayerThickness,
174  scalar& thickness,
175  scalar& expansionRatio
176  );
177 
178  //- No copy construct
179  layerParameters(const layerParameters&) = delete;
180 
181  //- No copy assignment
182  void operator=(const layerParameters&) = delete;
183 
184 
185 public:
186 
187  // Constructors
188 
189  //- Construct from dictionary
191  (
192  const dictionary& dict,
193  const polyBoundaryMesh&,
194  const bool dryRun = false
195  );
196 
197 
198  // Member Functions
199 
200  const dictionary& dict() const
201  {
202  return dict_;
203  }
204 
205 
206  // Per patch information
207 
208  //- How many layers to add.
209  // -1 : no specification. Assume 0 layers but allow sliding
210  // to make layers
211  // 0 : specified to have 0 layers. No sliding allowed.
212  // >0 : number of layers
213  const labelList& numLayers() const
214  {
215  return numLayers_;
216  }
217 
218  //- Are size parameters relative to inner cell size or
219  // absolute distances.
220  const boolList& relativeSizes() const
221  {
222  return relativeSizes_;
223  }
224 
225  //- Specification of layer thickness
227  {
228  return layerModels_;
229  }
230 
231  // Expansion factor for layer mesh
232  const scalarField& expansionRatio() const
233  {
234  return expansionRatio_;
235  }
236 
237  //- Wanted thickness of the layer furthest away
238  // from the wall (i.e. nearest the original mesh).
239  // If relativeSize() this number is relative to undistorted
240  // size of the cell outside layer.
241  const scalarField& finalLayerThickness() const
242  {
243  return finalLayerThickness_;
244  }
245 
246  //- Wanted thickness of the layer nearest to the wall.
247  // If relativeSize() this number is relative to undistorted
248  // size of the cell outside layer.
249  const scalarField& firstLayerThickness() const
250  {
251  return firstLayerThickness_;
252  }
253 
254  //- Wanted overall thickness of all layers.
255  // If relativeSize() this number is relative to undistorted
256  // size of the cell outside layer.
257  const scalarField& thickness() const
258  {
259  return thickness_;
260  }
261 
262  //- Minimum overall thickness of cell layer. If for any reason layer
263  // cannot be above minThickness do not add layer.
264  // If relativeSize() this number is relative to undistorted
265  // size of the cell outside layer.
266  const scalarField& minThickness() const
267  {
268  return minThickness_;
269  }
270 
271 
272  // Control
273 
274  //- Number of overall layer addition iterations
275  label nLayerIter() const
276  {
277  return nLayerIter_;
278  }
279 
280  //- Number of iterations after which relaxed motion rules
281  // are to be used.
282  label nRelaxedIter() const
283  {
284  return nRelaxedIter_;
285  }
286 
287 
288  // Control
289 
290  scalar featureAngle() const
291  {
292  return featureAngle_;
293  }
294 
295  scalar mergePatchFacesAngle() const
296  {
297  return mergePatchFacesAngle_;
298  }
299 
300  scalar concaveAngle() const
301  {
302  return concaveAngle_;
303  }
304 
305  //- If points get not extruded do nGrow layers of connected faces
306  // that are not grown. Is used to not do layers at all close to
307  // features.
308  label nGrow() const
309  {
310  return nGrow_;
311  }
312 
313  //- Stop layer growth on highly warped cells
314  scalar maxFaceThicknessRatio() const
315  {
316  return maxFaceThicknessRatio_;
317  }
318 
319  //- Create buffer region for new layer terminations
320  label nBufferCellsNoExtrude() const
321  {
322  return nBufferCellsNoExtrude_;
323  }
324 
325  //- Any additional reporting requested?
326  bool additionalReporting() const
327  {
328  return additionalReporting_;
329  }
330 
331  //- Type of mesh shrinker
332  const word& meshShrinker() const
333  {
334  return meshShrinker_;
335  }
336 
337 
338  // Helper
339 
340  //- Determine overall thickness. Uses two of the four parameters
341  // according to the thicknessModel
342  static scalar layerThickness
343  (
344  const thicknessModelType,
345  const label nLayers,
346  const scalar firstLayerThickness,
347  const scalar finalLayerThickness,
348  const scalar totalThickness,
349  const scalar expansionRatio
350  );
351 
352  //- Determine expansion ratio. Uses two of the four parameters
353  // according to the thicknessModel
354  static scalar layerExpansionRatio
355  (
356  const thicknessModelType,
357  const label nLayers,
358  const scalar firstLayerThickness,
359  const scalar finalLayerThickness,
360  const scalar totalThickness,
361  const scalar expansionRatio
362  );
363 
364  //- Determine first layer (near-wall) thickness. Uses two of the
365  // four parameters according to the thicknessModel
366  static scalar firstLayerThickness
367  (
368  const thicknessModelType,
369  const label nLayers,
370  const scalar firstLayerThickness,
371  const scalar finalLayerThickness,
372  const scalar totalThickness,
373  const scalar expansionRatio
374  );
375 
376  //- Determine ratio of final layer thickness to
377  // overall layer thickness
378  static scalar finalLayerThicknessRatio
379  (
380  const label nLayers,
381  const scalar expansionRatio
382  );
383 };
384 
385 
386 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 
388 } // End namespace Foam
389 
390 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
391 
392 #endif
393 
394 // ************************************************************************* //
Foam::layerParameters::FINAL_AND_EXPANSION
Definition: layerParameters.H:75
Foam::layerParameters::nGrow
label nGrow() const
If points get not extruded do nGrow layers of connected faces.
Definition: layerParameters.H:307
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
Foam::Enum< thicknessModelType >
Foam::layerParameters::layerThickness
static scalar layerThickness(const thicknessModelType, const label nLayers, const scalar firstLayerThickness, const scalar finalLayerThickness, const scalar totalThickness, const scalar expansionRatio)
Determine overall thickness. Uses two of the four parameters.
Definition: layerParameters.C:697
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::layerParameters::dict
const dictionary & dict() const
Definition: layerParameters.H:199
scalarField.H
Foam::layerParameters::FINAL_AND_TOTAL
Definition: layerParameters.H:74
Foam::layerParameters::maxFaceThicknessRatio
scalar maxFaceThicknessRatio() const
Stop layer growth on highly warped cells.
Definition: layerParameters.H:313
Foam::layerParameters::additionalReporting
bool additionalReporting() const
Any additional reporting requested?
Definition: layerParameters.H:325
Foam::layerParameters::nRelaxedIter
label nRelaxedIter() const
Number of iterations after which relaxed motion rules.
Definition: layerParameters.H:281
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:65
Foam::layerParameters::nLayerIter
label nLayerIter() const
Number of overall layer addition iterations.
Definition: layerParameters.H:274
Foam::layerParameters::finalLayerThicknessRatio
static scalar finalLayerThicknessRatio(const label nLayers, const scalar expansionRatio)
Determine ratio of final layer thickness to.
Definition: layerParameters.C:947
Foam::layerParameters::FIRST_AND_EXPANSION
Definition: layerParameters.H:73
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::layerParameters::minThickness
const scalarField & minThickness() const
Minimum overall thickness of cell layer. If for any reason layer.
Definition: layerParameters.H:265
Foam::layerParameters::nBufferCellsNoExtrude
label nBufferCellsNoExtrude() const
Create buffer region for new layer terminations.
Definition: layerParameters.H:319
labelList.H
Foam::Field< scalar >
Foam::layerParameters::FIRST_AND_TOTAL
Definition: layerParameters.H:72
Foam::layerParameters::mergePatchFacesAngle
scalar mergePatchFacesAngle() const
Definition: layerParameters.H:294
Foam::layerParameters::relativeSizes
const boolList & relativeSizes() const
Are size parameters relative to inner cell size or.
Definition: layerParameters.H:219
Switch.H
Foam::layerParameters::FIRST_AND_RELATIVE_FINAL
Definition: layerParameters.H:77
Foam::layerParameters
Simple container to keep together layer specific information.
Definition: layerParameters.H:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::layerParameters::numLayers
const labelList & numLayers() const
How many layers to add.
Definition: layerParameters.H:212
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::layerParameters::layerModels
const List< thicknessModelType > & layerModels() const
Specification of layer thickness.
Definition: layerParameters.H:225
Foam::layerParameters::featureAngle
scalar featureAngle() const
Definition: layerParameters.H:289
Foam::List< label >
Foam::layerParameters::firstLayerThickness
const scalarField & firstLayerThickness() const
Wanted thickness of the layer nearest to the wall.
Definition: layerParameters.H:248
dictionary.H
Foam::layerParameters::expansionRatio
const scalarField & expansionRatio() const
Definition: layerParameters.H:231
Foam::layerParameters::thickness
const scalarField & thickness() const
Wanted overall thickness of all layers.
Definition: layerParameters.H:256
Foam::layerParameters::TOTAL_AND_EXPANSION
Definition: layerParameters.H:76
Foam::layerParameters::thicknessModelType
thicknessModelType
Enumeration defining the layer specification:
Definition: layerParameters.H:70
Foam::layerParameters::finalLayerThickness
const scalarField & finalLayerThickness() const
Wanted thickness of the layer furthest away.
Definition: layerParameters.H:240
Foam::layerParameters::meshShrinker
const word & meshShrinker() const
Type of mesh shrinker.
Definition: layerParameters.H:331
Foam::layerParameters::concaveAngle
scalar concaveAngle() const
Definition: layerParameters.H:299
Enum.H