35 const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
40 Foam::scalar Foam::layerParameters::layerExpansionRatio
43 const scalar totalOverFirst
53 const label maxIters = 10;
54 const scalar tol = 1
e-8;
57 if (
mag(n-totalOverFirst) < tol)
66 if (totalOverFirst < n)
69 maxR =
pow(totalOverFirst/n, 1/(n-1));
73 minR =
pow(totalOverFirst/n, 1/(n-1));
74 maxR = totalOverFirst/(n - 1);
80 scalar r = 0.5*(minR + maxR);
82 for (
label i = 0; i < maxIters; ++i)
84 const scalar prevr = r;
86 const scalar fx =
pow(r, n) - totalOverFirst*r - (1 - totalOverFirst);
87 const scalar dfx = n*
pow(r, n - 1) - totalOverFirst;
91 const scalar error =
mag(r - prevr);
107 Foam::layerParameters::layerParameters
114 numLayers_(boundaryMesh.
size(), -1),
115 relativeSizes_(dict.
lookup(
"relativeSizes")),
117 firstLayerThickness_(boundaryMesh.
size(), -123),
118 finalLayerThickness_(boundaryMesh.
size(), -123),
119 thickness_(boundaryMesh.
size(), -123),
120 expansionRatio_(boundaryMesh.
size(), -123),
132 maxFaceThicknessRatio_
136 nBufferCellsNoExtrude_
142 additionalReporting_(dict.
lookupOrDefault(
"additionalReporting",
false)),
148 medialAxisMeshMover::typeName
156 bool haveFirst = dict.
found(
"firstLayerThickness");
166 bool haveFinal = dict.
found(
"finalLayerThickness");
176 bool haveTotal = dict.
found(
"thickness");
186 bool haveExp = dict.
found(
"expansionRatio");
198 if (haveFirst && haveTotal)
201 Info<<
"Layer thickness specified as first layer and overall thickness." 204 else if (haveFirst && haveExp)
207 Info<<
"Layer thickness specified as first layer and expansion ratio." 210 else if (haveFinal && haveTotal)
213 Info<<
"Layer thickness specified as final layer and overall thickness." 216 else if (haveFinal && haveExp)
219 Info<<
"Layer thickness specified as final layer and expansion ratio." 222 else if (haveTotal && haveExp)
225 Info<<
"Layer thickness specified as overall thickness" 226 <<
" and expansion ratio." <<
endl;
230 if (layerSpec_ ==
ILLEGAL || nSpec != 2)
234 "layerParameters::layerParameters" 235 "(const dictionary&, const polyBoundaryMesh&)",
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)
279 IOWarningIn(
"layerParameters::layerParameters(..)", layersDict)
280 <<
"Layer specification for " << key
281 <<
" does not match any patch." <<
endl 282 <<
"Valid patches are " << boundaryMesh.
names() <<
endl;
290 label patchI = patchIter.key();
300 "firstLayerThickness",
301 firstLayerThickness_[patchI]
313 "firstLayerThickness",
314 firstLayerThickness_[patchI]
319 expansionRatio_[patchI]
326 "finalLayerThickness",
327 finalLayerThickness_[patchI]
339 "finalLayerThickness",
340 finalLayerThickness_[patchI]
345 expansionRatio_[patchI]
358 expansionRatio_[patchI]
365 "layerParameters::layerParameters(..)",
374 minThickness_[patchI]
388 const scalar firstLayerThickess,
389 const scalar finalLayerThickess,
390 const scalar totalThickness,
391 const scalar expansionRatio
400 return totalThickness;
406 if (
mag(expansionRatio-1) < SMALL)
408 return firstLayerThickess * nLayers;
412 return firstLayerThickess *
413 (1.0 -
pow(expansionRatio, nLayers))
414 / (1.0 - expansionRatio);
421 if (
mag(expansionRatio-1) < SMALL)
423 return finalLayerThickess * nLayers;
428 return finalLayerThickess *
429 (1.0 -
pow(invExpansion, nLayers))
430 / (1.0 - invExpansion);
438 <<
"Illegal thickness specification " << layerSpec_
446 Foam::scalar Foam::layerParameters::layerExpansionRatio
449 const scalar firstLayerThickess,
450 const scalar finalLayerThickess,
451 const scalar totalThickness,
452 const scalar expansionRatio
467 return layerExpansionRatio
470 totalThickness/firstLayerThickess
479 / layerExpansionRatio
482 totalThickness/finalLayerThickess
500 const scalar firstLayerThickess,
501 const scalar finalLayerThickess,
502 const scalar totalThickness,
503 const scalar expansionRatio
511 return firstLayerThickess;
516 return finalLayerThickess*
pow(1.0/expansionRatio, nLayers-1);
522 scalar r = layerExpansionRatio
530 return finalLayerThickess/
pow(r, nLayers-1);
541 scalar finalThickness = r*totalThickness;
542 return finalThickness/
pow(expansionRatio, nLayers-1);
559 const scalar expansionRatio
564 if (
mag(expansionRatio-1) < SMALL)
571 pow(expansionRatio, nLayers - 1)
573 / (1.0 -
pow(expansionRatio, nLayers));
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
label size() const
Return the number of elements in the PtrList.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< scalar > mag(const dimensioned< Type > &)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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 list of keyword definitions, which are a keyword followed by any number of values (e...
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
#define IOWarningIn(functionName, ios)
Report an IO warning using Foam::Warning.
const scalarField & expansionRatio() const
label readLabel(Istream &is)
A class for handling keywords in dictionaries.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
wordList names() const
Return a list of patch names.
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Unit conversion functions.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool usePatchGroups=true) const
Return the set of patch IDs corresponding to the given names.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
scalar finalLayerThicknessRatio(const label nLayers, const scalar expansionRatio) const
Determine ratio of final layer thickness to.
const scalarField & firstLayerThickness() const
Wanted thickness of the layer nearest to the wall.
A wordRe is a word, but can also have a regular expression for matching words.
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
static const label labelMax