34 const Foam::scalar Foam::layerParameters::defaultConcaveAngle =
40 Foam::scalar Foam::layerParameters::layerExpansionRatio
43 const scalar totalOverFirst
51 const scalar tol = 1
e-8;
53 if (
mag(
n - totalOverFirst) < tol)
58 const label maxIters = 100;
64 if (totalOverFirst <
n)
67 maxR =
pow(totalOverFirst/
n, 1/(
n-1));
71 minR =
pow(totalOverFirst/
n, 1/(
n-1));
72 maxR = totalOverFirst/(
n - 1);
76 scalar r = 0.5*(minR + maxR);
78 for (
label i = 0; i < maxIters; ++i)
80 const scalar prevr = r;
81 const scalar fx =
pow(r,
n) - totalOverFirst*r - (1 - totalOverFirst);
82 const scalar dfx =
n*
pow(r,
n - 1) - totalOverFirst;
86 if (
mag(r - prevr) < tol)
105 numLayers_(boundaryMesh.size(), -1),
106 relativeSizes_(
dict.lookup(
"relativeSizes")),
108 firstLayerThickness_(boundaryMesh.size(), -123),
109 finalLayerThickness_(boundaryMesh.size(), -123),
110 thickness_(boundaryMesh.size(), -123),
111 expansionRatio_(boundaryMesh.size(), -123),
115 dict.lookup<scalar>(
"minThickness")
122 dict.lookup<bool>(
"mergeFaces")
134 maxFaceThicknessRatio_
136 dict.lookup<scalar>(
"maxFaceThicknessRatio")
138 nBufferCellsNoExtrude_
140 dict.lookup<
label>(
"nBufferCellsNoExtrude")
142 nLayerIter_(
dict.lookup<
label>(
"nLayerIter")),
144 additionalReporting_(
dict.lookupOrDefault(
"additionalReporting", false)),
158 bool haveFirst =
dict.
found(
"firstLayerThickness");
168 bool haveFinal =
dict.
found(
"finalLayerThickness");
178 bool haveTotal =
dict.
found(
"thickness");
188 bool haveExp =
dict.
found(
"expansionRatio");
200 if (haveFirst && haveTotal)
203 Info<<
"Layer thickness specified as first layer and overall thickness."
206 else if (haveFirst && haveExp)
209 Info<<
"Layer thickness specified as first layer and expansion ratio."
212 else if (haveFinal && haveTotal)
215 Info<<
"Layer thickness specified as final layer and overall thickness."
218 else if (haveFinal && haveExp)
221 Info<<
"Layer thickness specified as final layer and expansion ratio."
224 else if (haveTotal && haveExp)
227 Info<<
"Layer thickness specified as overall thickness"
228 <<
" and expansion ratio." <<
endl;
232 if (layerSpec_ ==
ILLEGAL || nSpec != 2)
237 ) <<
"Over- or underspecified layer thickness."
238 <<
" Please specify" <<
nl
239 <<
" first layer thickness ('firstLayerThickness')"
240 <<
" and overall thickness ('thickness') or" <<
nl
241 <<
" first layer thickness ('firstLayerThickness')"
242 <<
" and expansion ratio ('expansionRatio') or" <<
nl
243 <<
" final layer thickness ('finalLayerThickness')"
244 <<
" and expansion ratio ('expansionRatio') or" <<
nl
245 <<
" final layer thickness ('finalLayerThickness')"
246 <<
" and overall thickness ('thickness') or" <<
nl
247 <<
" overall thickness ('thickness')"
248 <<
" and expansion ratio ('expansionRatio'"
255 if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
258 <<
"Layer iterations should be >= 0." <<
endl
259 <<
"nLayerIter:" << nLayerIter_
260 <<
" nRelaxedIter:" << nRelaxedIter_
271 const keyType& key = iter().keyword();
277 if (patchIDs.
size() == 0)
280 <<
"Layer specification for " << key
281 <<
" does not match any patch." <<
endl
282 <<
"Valid patches are " << boundaryMesh.
names() <<
endl;
300 "firstLayerThickness",
301 firstLayerThickness_[
patchi]
313 "firstLayerThickness",
314 firstLayerThickness_[
patchi]
326 "finalLayerThickness",
327 finalLayerThickness_[
patchi]
339 "finalLayerThickness",
340 finalLayerThickness_[
patchi]
376 if (layerDict.
found(
"mergeFaces"))
379 layerDict.
lookup<
bool>(
"mergeFaces")
395 const scalar firstLayerThickness,
396 const scalar finalLayerThickness,
397 const scalar totalThickness,
398 const scalar expansionRatio
403 case FIRST_AND_TOTAL:
404 case FINAL_AND_TOTAL:
405 case TOTAL_AND_EXPANSION:
407 return totalThickness;
411 case FIRST_AND_EXPANSION:
413 if (
mag(expansionRatio-1) < small)
415 return firstLayerThickness * nLayers;
419 return firstLayerThickness
420 *(1 -
pow(expansionRatio, nLayers))
421 /(1 - expansionRatio);
426 case FINAL_AND_EXPANSION:
428 if (
mag(expansionRatio-1) < small)
430 return finalLayerThickness * nLayers;
434 const scalar invExpansion = 1.0/expansionRatio;
436 return finalLayerThickness
437 *(1 -
pow(invExpansion, nLayers))
453 Foam::scalar Foam::layerParameters::layerExpansionRatio
456 const scalar firstLayerThickness,
457 const scalar finalLayerThickness,
458 const scalar totalThickness,
459 const scalar expansionRatio
464 case FIRST_AND_EXPANSION:
465 case FINAL_AND_EXPANSION:
466 case TOTAL_AND_EXPANSION:
468 return expansionRatio;
472 case FIRST_AND_TOTAL:
474 return layerExpansionRatio
477 totalThickness/firstLayerThickness
482 case FINAL_AND_TOTAL:
489 totalThickness/finalLayerThickness
507 const scalar firstLayerThickness,
508 const scalar finalLayerThickness,
509 const scalar totalThickness,
510 const scalar expansionRatio
515 case FIRST_AND_EXPANSION:
516 case FIRST_AND_TOTAL:
518 return firstLayerThickness;
521 case FINAL_AND_EXPANSION:
523 return finalLayerThickness*
pow(1.0/expansionRatio, nLayers-1);
527 case FINAL_AND_TOTAL:
529 const scalar r = layerExpansionRatio
538 return finalLayerThickness/
pow(r, nLayers-1);
542 case TOTAL_AND_EXPANSION:
544 const scalar r = finalLayerThicknessRatio
550 const scalar finalThickness = r*totalThickness;
552 return finalThickness/
pow(expansionRatio, nLayers-1);
569 const scalar expansionRatio
574 if (
mag(expansionRatio-1) < small)
581 pow(expansionRatio, nLayers - 1)
582 *(1 - expansionRatio)
583 /(1 -
pow(expansionRatio, nLayers));
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
label size() const
Return number of elements in table.
label size() const
Return the number of elements in the UPtrList.
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
A class for handling keywords in dictionaries.
layerParameters(const dictionary &dict, const polyBoundaryMesh &)
Construct from dictionary.
scalar finalLayerThicknessRatio(const label nLayers, const scalar expansionRatio) const
Determine ratio of final layer thickness to.
const dictionary & dict() const
mergeFace
Enumeration defining whether to merge faces on a given patch. Read.
const scalarField & firstLayerThickness() const
Wanted thickness of the layer nearest to the wall.
scalar layerThickness(const label nLayers, const scalar firstLayerThickness, const scalar finalLayerThickness, const scalar totalThickness, const scalar expansionRatio) const
Determine overall thickness. Uses two of the four parameters.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch indices corresponding to the given names.
wordList names() const
Return the list of patch names.
A wordRe is a word, but can also have a regular expression for matching words.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
errorManipArg< error, int > exit(error &err, const int errNo=1)
scalar degToRad(const scalar deg)
Convert degrees to radians.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< scalar > mag(const dimensioned< Type > &)
static const label labelMax
const unitConversion unitDegrees