35 const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
40 Foam::scalar Foam::layerParameters::layerExpansionRatio
43 const scalar totalOverFirst
51 const label maxIters = 20;
52 const scalar tol = 1
e-8;
54 if (
mag(n-totalOverFirst) < tol)
63 if (totalOverFirst < n)
66 maxR =
pow(totalOverFirst/n, 1/(n-1));
70 minR =
pow(totalOverFirst/n, 1/(n-1));
71 maxR = totalOverFirst/(n - 1);
75 scalar r = 0.5*(minR + maxR);
77 for (
label i = 0; i < maxIters; ++i)
79 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;
85 if (
mag(r - prevr) < tol)
96 Foam::layerParameters::layerParameters
103 numLayers_(boundaryMesh.
size(), -1),
104 relativeSizes_(dict.
lookup(
"relativeSizes")),
106 firstLayerThickness_(boundaryMesh.
size(), -123),
107 finalLayerThickness_(boundaryMesh.
size(), -123),
108 thickness_(boundaryMesh.
size(), -123),
109 expansionRatio_(boundaryMesh.
size(), -123),
121 maxFaceThicknessRatio_
125 nBufferCellsNoExtrude_
131 additionalReporting_(dict.
lookupOrDefault(
"additionalReporting",
false)),
137 medialAxisMeshMover::typeName
145 bool haveFirst = dict.
found(
"firstLayerThickness");
155 bool haveFinal = dict.
found(
"finalLayerThickness");
165 bool haveTotal = dict.
found(
"thickness");
175 bool haveExp = dict.
found(
"expansionRatio");
187 if (haveFirst && haveTotal)
190 Info<<
"Layer thickness specified as first layer and overall thickness." 193 else if (haveFirst && haveExp)
196 Info<<
"Layer thickness specified as first layer and expansion ratio." 199 else if (haveFinal && haveTotal)
202 Info<<
"Layer thickness specified as final layer and overall thickness." 205 else if (haveFinal && haveExp)
208 Info<<
"Layer thickness specified as final layer and expansion ratio." 211 else if (haveTotal && haveExp)
214 Info<<
"Layer thickness specified as overall thickness" 215 <<
" and expansion ratio." <<
endl;
219 if (layerSpec_ ==
ILLEGAL || nSpec != 2)
224 ) <<
"Over- or underspecified layer thickness." 225 <<
" Please specify" <<
nl 226 <<
" first layer thickness ('firstLayerThickness')" 227 <<
" and overall thickness ('thickness') or" <<
nl 228 <<
" first layer thickness ('firstLayerThickness')" 229 <<
" and expansion ratio ('expansionRatio') or" <<
nl 230 <<
" final layer thickness ('finalLayerThickness')" 231 <<
" and expansion ratio ('expansionRatio') or" <<
nl 232 <<
" final layer thickness ('finalLayerThickness')" 233 <<
" and overall thickness ('thickness') or" <<
nl 234 <<
" overall thickness ('thickness')" 235 <<
" and expansion ratio ('expansionRatio'" 242 if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
245 <<
"Layer iterations should be >= 0." <<
endl 246 <<
"nLayerIter:" << nLayerIter_
247 <<
" nRelaxedIter:" << nRelaxedIter_
258 const keyType& key = iter().keyword();
264 if (patchIDs.size() == 0)
267 <<
"Layer specification for " << key
268 <<
" does not match any patch." <<
endl 269 <<
"Valid patches are " << boundaryMesh.
names() <<
endl;
287 "firstLayerThickness",
288 firstLayerThickness_[patchi]
300 "firstLayerThickness",
301 firstLayerThickness_[patchi]
306 expansionRatio_[patchi]
313 "finalLayerThickness",
314 finalLayerThickness_[patchi]
326 "finalLayerThickness",
327 finalLayerThickness_[patchi]
332 expansionRatio_[patchi]
345 expansionRatio_[patchi]
360 minThickness_[patchi]
374 const scalar firstLayerThickess,
375 const scalar finalLayerThickess,
376 const scalar totalThickness,
377 const scalar expansionRatio
386 return totalThickness;
392 if (
mag(expansionRatio-1) < SMALL)
394 return firstLayerThickess * nLayers;
398 return firstLayerThickess
399 *(1.0 -
pow(expansionRatio, nLayers))
400 /(1.0 - expansionRatio);
407 if (
mag(expansionRatio-1) < SMALL)
409 return finalLayerThickess * nLayers;
414 return finalLayerThickess
415 *(1.0 -
pow(invExpansion, nLayers))
416 /(1.0 - invExpansion);
431 Foam::scalar Foam::layerParameters::layerExpansionRatio
434 const scalar firstLayerThickess,
435 const scalar finalLayerThickess,
436 const scalar totalThickness,
437 const scalar expansionRatio
452 return layerExpansionRatio
455 totalThickness/firstLayerThickess
467 totalThickness/finalLayerThickess
485 const scalar firstLayerThickess,
486 const scalar finalLayerThickess,
487 const scalar totalThickness,
488 const scalar expansionRatio
496 return firstLayerThickess;
501 return finalLayerThickess*
pow(1.0/expansionRatio, nLayers-1);
507 scalar r = layerExpansionRatio
515 return finalLayerThickess/
pow(r, nLayers-1);
526 scalar finalThickness = r*totalThickness;
527 return finalThickness/
pow(expansionRatio, nLayers-1);
544 const scalar expansionRatio
549 if (
mag(expansionRatio-1) < SMALL)
556 pow(expansionRatio, nLayers - 1)
558 /(1.0 -
pow(expansionRatio, nLayers));
A class for handling keywords in dictionaries.
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)
wordList names() const
Return a list of patch names.
const double e
Elementary charge.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Unit conversion functions.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const scalarField & expansionRatio() const
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.
const scalarField & firstLayerThickness() const
Wanted thickness of the layer nearest to the wall.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
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.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
static const label labelMax
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
label readLabel(Istream &is)
A wordRe is a word, but can also have a regular expression for matching words.
scalar finalLayerThicknessRatio(const label nLayers, const scalar expansionRatio) const
Determine ratio of final layer thickness to.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
dimensioned< scalar > mag(const dimensioned< Type > &)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
label size() const
Return the number of elements in the UPtrList.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.