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 =
dict.
get<scalar>(
"firstLayerThickness");
133 thickness =
dict.
get<scalar>(
"thickness");
136 case FIRST_AND_EXPANSION:
139 Info<<
"Layer specification as" <<
nl
140 <<
"- first layer thickness ('firstLayerThickness')" <<
nl
141 <<
"- expansion ratio ('expansionRatio')" <<
endl;
143 firstLayerThickness =
dict.
get<scalar>(
"firstLayerThickness");
144 expansionRatio =
dict.
get<scalar>(
"expansionRatio");
147 case FINAL_AND_TOTAL:
150 Info<<
"Layer specification as" <<
nl
151 <<
"- final layer thickness ('finalLayerThickness')" <<
nl
152 <<
"- overall thickness ('thickness')" <<
endl;
154 finalLayerThickness =
dict.
get<scalar>(
"finalLayerThickness");
155 thickness =
dict.
get<scalar>(
"thickness");
158 case FINAL_AND_EXPANSION:
161 Info<<
"Layer specification as" <<
nl
162 <<
"- final layer thickness ('finalLayerThickness')" <<
nl
163 <<
"- expansion ratio ('expansionRatio')" <<
endl;
165 finalLayerThickness =
dict.
get<scalar>(
"finalLayerThickness");
166 expansionRatio =
dict.
get<scalar>(
"expansionRatio");
169 case TOTAL_AND_EXPANSION:
172 Info<<
"Layer specification as" <<
nl
173 <<
"- overall thickness ('thickness')" <<
nl
174 <<
"- expansion ratio ('expansionRatio')" <<
endl;
176 thickness =
dict.
get<scalar>(
"thickness");
177 expansionRatio =
dict.
get<scalar>(
"expansionRatio");
180 case FIRST_AND_RELATIVE_FINAL:
183 Info<<
"Layer specification as" <<
nl
184 <<
"- absolute first layer thickness"
185 <<
" ('firstLayerThickness')"
187 <<
"- and final layer thickness"
188 <<
" ('finalLayerThickness')" <<
nl
191 firstLayerThickness =
dict.
get<scalar>(
"firstLayerThickness");
192 finalLayerThickness =
dict.
get<scalar>(
"finalLayerThickness");
203 void Foam::layerParameters::calculateLayerParameters
205 const thicknessModelType& spec,
207 scalar& firstThickness,
208 scalar& finalThickness,
210 scalar& expansionRatio
216 case FIRST_AND_TOTAL:
217 expansionRatio = layerExpansionRatio
228 *finalLayerThicknessRatio(nLayers, expansionRatio);
232 case FIRST_AND_EXPANSION:
233 thickness = layerThickness
244 *finalLayerThicknessRatio(nLayers, expansionRatio);
248 case FINAL_AND_TOTAL:
249 firstThickness = firstLayerThickness
258 expansionRatio = layerExpansionRatio
270 case FINAL_AND_EXPANSION:
271 firstThickness = firstLayerThickness
280 thickness = layerThickness
291 case TOTAL_AND_EXPANSION:
292 firstThickness = firstLayerThickness
303 *finalLayerThicknessRatio(nLayers, expansionRatio);
307 case FIRST_AND_RELATIVE_FINAL:
308 thickness = layerThickness
317 expansionRatio = layerExpansionRatio
339 Foam::layerParameters::layerParameters
341 const dictionary&
dict,
342 const polyBoundaryMesh& boundaryMesh,
348 numLayers_(boundaryMesh.size(), -1),
352 meshRefinement::
get<
bool>(
dict,
"relativeSizes", dryRun)
354 layerModels_(boundaryMesh.size(), FIRST_AND_TOTAL),
355 firstLayerThickness_(boundaryMesh.size(), -123),
356 finalLayerThickness_(boundaryMesh.size(), -123),
357 thickness_(boundaryMesh.size(), -123),
358 expansionRatio_(boundaryMesh.size(), -123),
362 meshRefinement::
get<scalar>(
dict,
"minThickness", dryRun)
364 featureAngle_(meshRefinement::
get<scalar>(
dict,
"featureAngle", dryRun)),
365 mergePatchFacesAngle_
367 dict.getOrDefault<scalar>
369 "mergePatchFacesAngle",
375 dict.getOrDefault<scalar>(
"concaveAngle", defaultConcaveAngle)
377 nGrow_(meshRefinement::
get<label>(
dict,
"nGrow", dryRun)),
378 maxFaceThicknessRatio_
380 meshRefinement::
get<scalar>(
dict,
"maxFaceThicknessRatio", dryRun)
382 nBufferCellsNoExtrude_
384 meshRefinement::
get<label>(
dict,
"nBufferCellsNoExtrude", dryRun)
386 nLayerIter_(meshRefinement::
get<label>(
dict,
"nLayerIter", dryRun)),
388 additionalReporting_(
dict.getOrDefault(
"additionalReporting", false)),
394 medialAxisMeshMover::typeName
403 layerModels_ = thicknessModelTypeNames_[spec];
410 bool haveFirst =
dict.
found(
"firstLayerThickness");
415 bool haveFinal =
dict.
found(
"finalLayerThickness");
420 bool haveTotal =
dict.
found(
"thickness");
425 bool haveExp =
dict.
found(
"expansionRatio");
431 if (nSpec == 2 && haveFirst && haveTotal)
437 else if (nSpec == 2 && haveFirst && haveExp)
443 else if (nSpec == 2 && haveFinal && haveTotal)
449 else if (nSpec == 2 && haveFinal && haveExp)
455 else if (nSpec == 2 && haveTotal && haveExp)
461 else if (nSpec == 2 && haveFirst && haveFinal)
470 <<
"Over- or underspecified layer thickness."
471 <<
" Please specify" <<
nl
472 <<
" first layer thickness ('firstLayerThickness')"
473 <<
" and overall thickness ('thickness') or" <<
nl
474 <<
" first layer thickness ('firstLayerThickness')"
475 <<
" and expansion ratio ('expansionRatio') or" <<
nl
476 <<
" final layer thickness ('finalLayerThickness')"
477 <<
" and expansion ratio ('expansionRatio') or" <<
nl
478 <<
" final layer thickness ('finalLayerThickness')"
479 <<
" and overall thickness ('thickness') or" <<
nl
480 <<
" overall thickness ('thickness')"
481 <<
" and expansion ratio ('expansionRatio'"
488 scalar firstThickness;
489 scalar finalThickness;
502 firstLayerThickness_ = firstThickness;
503 finalLayerThickness_ = finalThickness;
509 if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
512 <<
"Layer iterations should be >= 0." <<
nl
513 <<
"nLayerIter:" << nLayerIter_
514 <<
" nRelaxedIter:" << nRelaxedIter_
526 for (
const entry& dEntry : layersDict)
530 const keyType&
key = dEntry.keyword();
531 const dictionary& layerDict = dEntry.dict();
535 boundaryMesh.patchSet(wordRes(one{}, wordRe(
key)))
538 if (patchIDs.size() == 0)
541 <<
"Layer specification for " <<
key
542 <<
" does not match any patch." <<
endl
543 <<
"Valid patches are " << boundaryMesh.names() <<
endl;
547 for (
const label patchi : patchIDs)
550 layerDict.get<label>(
"nSurfaceLayers");
553 if (layerDict.readIfPresent(
"thicknessModel", spec))
557 layerModels_[patchi] = thicknessModelTypeNames_[spec];
562 layerModels_[patchi],
563 firstLayerThickness_[patchi],
564 finalLayerThickness_[patchi],
566 expansionRatio_[patchi]
568 minThickness_[patchi] =
569 layerDict.get<scalar>(
"minThickness");
574 switch (layerModels_[patchi])
577 layerDict.readIfPresent
579 "firstLayerThickness",
580 firstLayerThickness_[patchi]
582 layerDict.readIfPresent
590 layerDict.readIfPresent
592 "firstLayerThickness",
593 firstLayerThickness_[patchi]
595 layerDict.readIfPresent
598 expansionRatio_[patchi]
603 layerDict.readIfPresent
605 "finalLayerThickness",
606 finalLayerThickness_[patchi]
608 layerDict.readIfPresent
616 layerDict.readIfPresent
618 "finalLayerThickness",
619 finalLayerThickness_[patchi]
621 layerDict.readIfPresent
624 expansionRatio_[patchi]
629 layerDict.readIfPresent
634 layerDict.readIfPresent
637 expansionRatio_[patchi]
642 layerDict.readIfPresent
644 "firstLayerThickness",
645 firstLayerThickness_[patchi]
647 layerDict.readIfPresent
649 "finalLayerThickness",
650 finalLayerThickness_[patchi]
660 layerDict.readIfPresent
663 minThickness_[patchi]
667 layerDict.readIfPresent
670 relativeSizes_[patchi]
678 forAll(numLayers_, patchi)
681 calculateLayerParameters
683 layerModels_[patchi],
685 firstLayerThickness_[patchi],
686 finalLayerThickness_[patchi],
688 expansionRatio_[patchi]
698 const thicknessModelType layerSpec,
700 const scalar firstLayerThickness,
701 const scalar finalLayerThickness,
702 const scalar totalThickness,
703 const scalar expansionRatio
708 case FIRST_AND_TOTAL:
709 case FINAL_AND_TOTAL:
710 case TOTAL_AND_EXPANSION:
712 return totalThickness;
716 case FIRST_AND_EXPANSION:
718 if (
mag(expansionRatio-1) < SMALL)
720 return firstLayerThickness * nLayers;
724 return firstLayerThickness
725 *(1.0 -
pow(expansionRatio, nLayers))
726 /(1.0 - expansionRatio);
731 case FINAL_AND_EXPANSION:
733 if (
mag(expansionRatio-1) < SMALL)
735 return finalLayerThickness * nLayers;
739 scalar invExpansion = 1.0 / expansionRatio;
740 return finalLayerThickness
741 *(1.0 -
pow(invExpansion, nLayers))
742 /(1.0 - invExpansion);
747 case FIRST_AND_RELATIVE_FINAL:
749 if (
mag(expansionRatio-1) < SMALL)
751 return firstLayerThickness * nLayers;
755 scalar ratio = layerExpansionRatio
765 if (
mag(ratio-1) < SMALL)
767 return firstLayerThickness * nLayers;
771 return firstLayerThickness *
772 (1.0 -
pow(ratio, nLayers))
789 Foam::scalar Foam::layerParameters::layerExpansionRatio
791 const thicknessModelType layerSpec,
793 const scalar firstLayerThickness,
794 const scalar finalLayerThickness,
795 const scalar totalThickness,
796 const scalar expansionRatio
801 case FIRST_AND_EXPANSION:
802 case FINAL_AND_EXPANSION:
803 case TOTAL_AND_EXPANSION:
805 return expansionRatio;
809 case FIRST_AND_TOTAL:
811 if (firstLayerThickness < SMALL)
818 return layerExpansionRatio
821 totalThickness/firstLayerThickness
827 case FINAL_AND_TOTAL:
829 if (finalLayerThickness < SMALL)
838 / layerExpansionRatio
841 totalThickness/finalLayerThickness
847 case FIRST_AND_RELATIVE_FINAL:
849 if (firstLayerThickness < SMALL || nLayers <= 1)
859 finalLayerThickness/firstLayerThickness,
878 const thicknessModelType layerSpec,
880 const scalar firstLayerThickness,
881 const scalar finalLayerThickness,
882 const scalar totalThickness,
883 const scalar expansionRatio
888 case FIRST_AND_EXPANSION:
889 case FIRST_AND_TOTAL:
890 case FIRST_AND_RELATIVE_FINAL:
892 return firstLayerThickness;
895 case FINAL_AND_EXPANSION:
897 if (expansionRatio < SMALL)
904 return finalLayerThickness*
pow(1.0/expansionRatio, nLayers-1);
909 case FINAL_AND_TOTAL:
911 scalar r = layerExpansionRatio
920 return finalLayerThickness/
pow(r, nLayers-1);
924 case TOTAL_AND_EXPANSION:
926 scalar r = finalLayerThicknessRatio
931 scalar finalThickness = r*totalThickness;
932 return finalThickness/
pow(expansionRatio, nLayers-1);
949 const scalar expansionRatio
954 if (
mag(expansionRatio-1) < SMALL)
961 pow(expansionRatio, nLayers - 1)
962 *(1.0 - expansionRatio)
963 /(1.0 -
pow(expansionRatio, nLayers));