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),
108 firstLayerThickness_(boundaryMesh.size(), -123),
109 finalLayerThickness_(boundaryMesh.size(), -123),
110 thickness_(boundaryMesh.size(), -123),
111 expansionRatio_(boundaryMesh.size(), -123),
139 maxFaceThicknessRatio_
143 nBufferCellsNoExtrude_
149 additionalReporting_(
dict.lookupOrDefault(
"additionalReporting", false)),
163 bool haveFirst =
dict.
found(
"firstLayerThickness");
173 bool haveFinal =
dict.
found(
"finalLayerThickness");
183 bool haveTotal =
dict.
found(
"thickness");
193 bool haveExp =
dict.
found(
"expansionRatio");
205 if (haveFirst && haveTotal)
208 Info<<
"Layer thickness specified as first layer and overall thickness."
211 else if (haveFirst && haveExp)
214 Info<<
"Layer thickness specified as first layer and expansion ratio."
217 else if (haveFinal && haveTotal)
220 Info<<
"Layer thickness specified as final layer and overall thickness."
223 else if (haveFinal && haveExp)
226 Info<<
"Layer thickness specified as final layer and expansion ratio."
229 else if (haveTotal && haveExp)
232 Info<<
"Layer thickness specified as overall thickness"
233 <<
" and expansion ratio." <<
endl;
237 if (layerSpec_ ==
ILLEGAL || nSpec != 2)
242 ) <<
"Over- or underspecified layer thickness."
243 <<
" Please specify" <<
nl
244 <<
" first layer thickness ('firstLayerThickness')"
245 <<
" and overall thickness ('thickness') or" <<
nl
246 <<
" first layer thickness ('firstLayerThickness')"
247 <<
" and expansion ratio ('expansionRatio') or" <<
nl
248 <<
" final layer thickness ('finalLayerThickness')"
249 <<
" and expansion ratio ('expansionRatio') or" <<
nl
250 <<
" final layer thickness ('finalLayerThickness')"
251 <<
" and overall thickness ('thickness') or" <<
nl
252 <<
" overall thickness ('thickness')"
253 <<
" and expansion ratio ('expansionRatio'"
260 if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
263 <<
"Layer iterations should be >= 0." <<
endl
264 <<
"nLayerIter:" << nLayerIter_
265 <<
" nRelaxedIter:" << nRelaxedIter_
276 const keyType& key = iter().keyword();
282 if (patchIDs.
size() == 0)
285 <<
"Layer specification for " << key
286 <<
" does not match any patch." <<
endl
287 <<
"Valid patches are " << boundaryMesh.
names() <<
endl;
305 "firstLayerThickness",
306 firstLayerThickness_[
patchi]
318 "firstLayerThickness",
319 firstLayerThickness_[
patchi]
331 "finalLayerThickness",
332 finalLayerThickness_[
patchi]
344 "finalLayerThickness",
345 finalLayerThickness_[
patchi]
381 if (layerDict.
found(
"mergeFaces"))
384 layerDict.
lookup<
bool>(
"mergeFaces")
400 const scalar firstLayerThickness,
401 const scalar finalLayerThickness,
402 const scalar totalThickness,
403 const scalar expansionRatio
408 case FIRST_AND_TOTAL:
409 case FINAL_AND_TOTAL:
410 case TOTAL_AND_EXPANSION:
412 return totalThickness;
416 case FIRST_AND_EXPANSION:
418 if (
mag(expansionRatio-1) < small)
420 return firstLayerThickness * nLayers;
424 return firstLayerThickness
425 *(1 -
pow(expansionRatio, nLayers))
426 /(1 - expansionRatio);
431 case FINAL_AND_EXPANSION:
433 if (
mag(expansionRatio-1) < small)
435 return finalLayerThickness * nLayers;
439 const scalar invExpansion = 1.0/expansionRatio;
441 return finalLayerThickness
442 *(1 -
pow(invExpansion, nLayers))
458 Foam::scalar Foam::layerParameters::layerExpansionRatio
461 const scalar firstLayerThickness,
462 const scalar finalLayerThickness,
463 const scalar totalThickness,
464 const scalar expansionRatio
469 case FIRST_AND_EXPANSION:
470 case FINAL_AND_EXPANSION:
471 case TOTAL_AND_EXPANSION:
473 return expansionRatio;
477 case FIRST_AND_TOTAL:
479 return layerExpansionRatio
482 totalThickness/firstLayerThickness
487 case FINAL_AND_TOTAL:
494 totalThickness/finalLayerThickness
512 const scalar firstLayerThickness,
513 const scalar finalLayerThickness,
514 const scalar totalThickness,
515 const scalar expansionRatio
520 case FIRST_AND_EXPANSION:
521 case FIRST_AND_TOTAL:
523 return firstLayerThickness;
526 case FINAL_AND_EXPANSION:
528 return finalLayerThickness*
pow(1.0/expansionRatio, nLayers-1);
532 case FINAL_AND_TOTAL:
534 const scalar r = layerExpansionRatio
543 return finalLayerThickness/
pow(r, nLayers-1);
547 case TOTAL_AND_EXPANSION:
549 const scalar r = finalLayerThicknessRatio
555 const scalar finalThickness = r*totalThickness;
557 return finalThickness/
pow(expansionRatio, nLayers-1);
574 const scalar expansionRatio
579 if (
mag(expansionRatio-1) < small)
586 pow(expansionRatio, nLayers - 1)
587 *(1 - expansionRatio)
588 /(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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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 patch set corresponding to the given names.
wordList names() const
Return the list of patch names.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
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.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
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.
tmp< DimensionedField< typename powProduct< Type, r >::type, GeoMesh, Field > > pow(const DimensionedField< Type, GeoMesh, PrimitiveField > &df, typename powProduct< Type, r >::type)
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
static const label labelMax