42 Foam::layerParameters::thicknessModelTypeNames_
44 { thicknessModelType::FIRST_AND_TOTAL,
"firstAndOverall" },
45 { thicknessModelType::FIRST_AND_EXPANSION,
"firstAndExpansion" },
46 { thicknessModelType::FINAL_AND_TOTAL,
"finalAndOverall" },
47 { thicknessModelType::FINAL_AND_EXPANSION,
"finalAndExpansion" },
48 { thicknessModelType::TOTAL_AND_EXPANSION,
"overallAndExpansion" },
49 { thicknessModelType::FIRST_AND_RELATIVE_FINAL,
"firstAndRelativeFinal" },
52 const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
57 Foam::scalar Foam::layerParameters::layerExpansionRatio
60 const scalar totalOverFirst
69 const scalar tol = 1
e-8;
71 if (
mag(
n-totalOverFirst) < tol)
80 if (totalOverFirst <
n)
83 maxR =
pow(totalOverFirst/
n, scalar(1)/(
n-1));
87 minR =
pow(totalOverFirst/
n, scalar(1)/(
n-1));
88 maxR = totalOverFirst/(
n - 1);
92 scalar r = 0.5*(minR + maxR);
96 const scalar prevr = r;
98 const scalar fx =
pow(r,
n) - totalOverFirst*r - (1 - totalOverFirst);
99 const scalar dfx =
n*
pow(r,
n - 1) - totalOverFirst;
102 if (
mag(r - prevr) < tol)
111 void Foam::layerParameters::readLayerParameters
114 const dictionary&
dict,
115 const thicknessModelType& spec,
116 scalar& firstLayerThickness,
117 scalar& finalLayerThickness,
119 scalar& expansionRatio
125 case FIRST_AND_TOTAL:
128 Info<<
"Layer specification as" <<
nl
129 <<
"- first layer thickness ('firstLayerThickness')" <<
nl
130 <<
"- overall thickness ('thickness')" <<
endl;
132 firstLayerThickness = readScalar
136 thickness = readScalar(
dict.
lookup(
"thickness"));
139 case FIRST_AND_EXPANSION:
142 Info<<
"Layer specification as" <<
nl
143 <<
"- first layer thickness ('firstLayerThickness')" <<
nl
144 <<
"- expansion ratio ('expansionRatio')" <<
endl;
146 firstLayerThickness = readScalar
150 expansionRatio = readScalar(
dict.
lookup(
"expansionRatio"));
153 case FINAL_AND_TOTAL:
156 Info<<
"Layer specification as" <<
nl
157 <<
"- final layer thickness ('finalLayerThickness')" <<
nl
158 <<
"- overall thickness ('thickness')" <<
endl;
160 finalLayerThickness = readScalar
164 thickness = readScalar(
dict.
lookup(
"thickness"));
167 case FINAL_AND_EXPANSION:
170 Info<<
"Layer specification as" <<
nl
171 <<
"- final layer thickness ('finalLayerThickness')" <<
nl
172 <<
"- expansion ratio ('expansionRatio')" <<
endl;
174 finalLayerThickness = readScalar
178 expansionRatio = readScalar(
dict.
lookup(
"expansionRatio"));
181 case TOTAL_AND_EXPANSION:
184 Info<<
"Layer specification as" <<
nl
185 <<
"- overall thickness ('thickness')" <<
nl
186 <<
"- expansion ratio ('expansionRatio')" <<
endl;
188 thickness = readScalar(
dict.
lookup(
"thickness"));
189 expansionRatio = readScalar(
dict.
lookup(
"expansionRatio"));
192 case FIRST_AND_RELATIVE_FINAL:
195 Info<<
"Layer specification as" <<
nl
196 <<
"- absolute first layer thickness"
197 <<
" ('firstLayerThickness')"
199 <<
"- and final layer thickness"
200 <<
" ('finalLayerThickness')" <<
nl
203 firstLayerThickness = readScalar
207 finalLayerThickness = readScalar
216 "layerParameters::layerParameters(..)",
224 void Foam::layerParameters::calculateLayerParameters
226 const thicknessModelType& spec,
228 scalar& firstThickness,
229 scalar& finalThickness,
231 scalar& expansionRatio
237 case FIRST_AND_TOTAL:
238 expansionRatio = layerExpansionRatio
249 *finalLayerThicknessRatio(nLayers, expansionRatio);
253 case FIRST_AND_EXPANSION:
254 thickness = layerThickness
265 *finalLayerThicknessRatio(nLayers, expansionRatio);
269 case FINAL_AND_TOTAL:
270 firstThickness = firstLayerThickness
279 expansionRatio = layerExpansionRatio
291 case FINAL_AND_EXPANSION:
292 firstThickness = firstLayerThickness
301 thickness = layerThickness
312 case TOTAL_AND_EXPANSION:
313 firstThickness = firstLayerThickness
324 *finalLayerThicknessRatio(nLayers, expansionRatio);
328 case FIRST_AND_RELATIVE_FINAL:
329 thickness = layerThickness
338 expansionRatio = layerExpansionRatio
360 Foam::layerParameters::layerParameters
373 meshRefinement::get<bool>(
dict,
"relativeSizes", dryRun)
383 meshRefinement::get<scalar>(
dict,
"minThickness", dryRun)
385 featureAngle_(meshRefinement::get<scalar>(
dict,
"featureAngle", dryRun)),
386 mergePatchFacesAngle_
390 "mergePatchFacesAngle",
398 nGrow_(meshRefinement::get<label>(
dict,
"nGrow", dryRun)),
399 maxFaceThicknessRatio_
401 meshRefinement::get<scalar>(
dict,
"maxFaceThicknessRatio", dryRun)
403 nBufferCellsNoExtrude_
405 meshRefinement::get<label>(
dict,
"nBufferCellsNoExtrude", dryRun)
407 nLayerIter_(meshRefinement::get<label>(
dict,
"nLayerIter", dryRun)),
415 medialAxisMeshMover::typeName
424 layerModels_ = thicknessModelTypeNames_[spec];
431 bool haveFirst =
dict.
found(
"firstLayerThickness");
436 bool haveFinal =
dict.
found(
"finalLayerThickness");
441 bool haveTotal =
dict.
found(
"thickness");
446 bool haveExp =
dict.
found(
"expansionRatio");
452 if (nSpec == 2 && haveFirst && haveTotal)
454 layerModels_ = FIRST_AND_TOTAL;
458 else if (nSpec == 2 && haveFirst && haveExp)
460 layerModels_ = FIRST_AND_EXPANSION;
464 else if (nSpec == 2 && haveFinal && haveTotal)
466 layerModels_ = FINAL_AND_TOTAL;
470 else if (nSpec == 2 && haveFinal && haveExp)
472 layerModels_ = FINAL_AND_EXPANSION;
476 else if (nSpec == 2 && haveTotal && haveExp)
478 layerModels_ = TOTAL_AND_EXPANSION;
482 else if (nSpec == 2 && haveFirst && haveFinal)
484 layerModels_ = FIRST_AND_RELATIVE_FINAL;
491 <<
"Over- or underspecified layer thickness."
492 <<
" Please specify" <<
nl
493 <<
" first layer thickness ('firstLayerThickness')"
494 <<
" and overall thickness ('thickness') or" <<
nl
495 <<
" first layer thickness ('firstLayerThickness')"
496 <<
" and expansion ratio ('expansionRatio') or" <<
nl
497 <<
" final layer thickness ('finalLayerThickness')"
498 <<
" and expansion ratio ('expansionRatio') or" <<
nl
499 <<
" final layer thickness ('finalLayerThickness')"
500 <<
" and overall thickness ('thickness') or" <<
nl
501 <<
" overall thickness ('thickness')"
502 <<
" and expansion ratio ('expansionRatio'"
509 scalar firstThickness;
510 scalar finalThickness;
512 scalar expansionRatio;
523 firstLayerThickness_ = firstThickness;
524 finalLayerThickness_ = finalThickness;
525 thickness_ = thickness;
526 expansionRatio_ = expansionRatio;
530 if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
533 <<
"Layer iterations should be >= 0." <<
nl
534 <<
"nLayerIter:" << nLayerIter_
535 <<
" nRelaxedIter:" << nRelaxedIter_
547 for (
const entry& dEntry : layersDict)
551 const keyType& key = dEntry.keyword();
559 if (patchIDs.size() == 0)
562 <<
"Layer specification for " << key
563 <<
" does not match any patch." <<
endl
568 for (
const label patchi : patchIDs)
571 layerDict.
get<label>(
"nSurfaceLayers");
578 layerModels_[patchi] = thicknessModelTypeNames_[spec];
583 layerModels_[patchi],
584 firstLayerThickness_[patchi],
585 finalLayerThickness_[patchi],
587 expansionRatio_[patchi]
589 minThickness_[patchi] = readScalar
591 layerDict.
lookup(
"minThickness")
597 switch (layerModels_[patchi])
599 case FIRST_AND_TOTAL:
602 "firstLayerThickness",
603 firstLayerThickness_[patchi]
612 case FIRST_AND_EXPANSION:
615 "firstLayerThickness",
616 firstLayerThickness_[patchi]
621 expansionRatio_[patchi]
625 case FINAL_AND_TOTAL:
628 "finalLayerThickness",
629 finalLayerThickness_[patchi]
638 case FINAL_AND_EXPANSION:
641 "finalLayerThickness",
642 finalLayerThickness_[patchi]
647 expansionRatio_[patchi]
651 case TOTAL_AND_EXPANSION:
660 expansionRatio_[patchi]
664 case FIRST_AND_RELATIVE_FINAL:
667 "firstLayerThickness",
668 firstLayerThickness_[patchi]
672 "finalLayerThickness",
673 finalLayerThickness_[patchi]
686 minThickness_[patchi]
693 relativeSizes_[patchi]
701 forAll(numLayers_, patchi)
704 calculateLayerParameters
706 layerModels_[patchi],
708 firstLayerThickness_[patchi],
709 finalLayerThickness_[patchi],
711 expansionRatio_[patchi]
723 const scalar firstLayerThickness,
724 const scalar finalLayerThickness,
725 const scalar totalThickness,
726 const scalar expansionRatio
731 case FIRST_AND_TOTAL:
732 case FINAL_AND_TOTAL:
733 case TOTAL_AND_EXPANSION:
735 return totalThickness;
739 case FIRST_AND_EXPANSION:
741 if (
mag(expansionRatio-1) < SMALL)
743 return firstLayerThickness * nLayers;
747 return firstLayerThickness
748 *(1.0 -
pow(expansionRatio, nLayers))
749 /(1.0 - expansionRatio);
754 case FINAL_AND_EXPANSION:
756 if (
mag(expansionRatio-1) < SMALL)
758 return finalLayerThickness * nLayers;
762 scalar invExpansion = 1.0 / expansionRatio;
763 return finalLayerThickness
764 *(1.0 -
pow(invExpansion, nLayers))
765 /(1.0 - invExpansion);
770 case FIRST_AND_RELATIVE_FINAL:
772 if (
mag(expansionRatio-1) < SMALL)
774 return firstLayerThickness * nLayers;
778 scalar ratio = layerExpansionRatio
788 if (
mag(ratio-1) < SMALL)
790 return firstLayerThickness * nLayers;
794 return firstLayerThickness *
795 (1.0 -
pow(ratio, nLayers))
812 Foam::scalar Foam::layerParameters::layerExpansionRatio
816 const scalar firstLayerThickness,
817 const scalar finalLayerThickness,
818 const scalar totalThickness,
819 const scalar expansionRatio
824 case FIRST_AND_EXPANSION:
825 case FINAL_AND_EXPANSION:
826 case TOTAL_AND_EXPANSION:
828 return expansionRatio;
832 case FIRST_AND_TOTAL:
834 if (firstLayerThickness < SMALL)
841 return layerExpansionRatio
844 totalThickness/firstLayerThickness
850 case FINAL_AND_TOTAL:
852 if (finalLayerThickness < SMALL)
861 / layerExpansionRatio
864 totalThickness/finalLayerThickness
870 case FIRST_AND_RELATIVE_FINAL:
872 if (firstLayerThickness < SMALL || nLayers <= 1)
882 finalLayerThickness/firstLayerThickness,
903 const scalar firstLayerThickness,
904 const scalar finalLayerThickness,
905 const scalar totalThickness,
906 const scalar expansionRatio
911 case FIRST_AND_EXPANSION:
912 case FIRST_AND_TOTAL:
913 case FIRST_AND_RELATIVE_FINAL:
915 return firstLayerThickness;
918 case FINAL_AND_EXPANSION:
920 if (expansionRatio < SMALL)
927 return finalLayerThickness*
pow(1.0/expansionRatio, nLayers-1);
932 case FINAL_AND_TOTAL:
934 scalar r = layerExpansionRatio
943 return finalLayerThickness/
pow(r, nLayers-1);
947 case TOTAL_AND_EXPANSION:
949 scalar r = finalLayerThicknessRatio
954 scalar finalThickness = r*totalThickness;
955 return finalThickness/
pow(expansionRatio, nLayers-1);
972 const scalar expansionRatio
977 if (
mag(expansionRatio-1) < SMALL)
984 pow(expansionRatio, nLayers - 1)
985 *(1.0 - expansionRatio)
986 /(1.0 -
pow(expansionRatio, nLayers));