/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "layerParameters.H" #include "polyBoundaryMesh.H" #include "refinementSurfaces.H" #include "searchableSurfaceList.H" #include "medialAxisMeshMover.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::scalar Foam::layerParameters::defaultConcaveAngle = Foam::degToRad(90); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::scalar Foam::layerParameters::layerExpansionRatio ( const label n, const scalar totalOverFirst ) const { if (n <= 1) { return 1; } const scalar tol = 1e-8; if (mag(n - totalOverFirst) < tol) { return 1; } const label maxIters = 100; // Calculate the bounds of the solution scalar minR; scalar maxR; if (totalOverFirst < n) { minR = 0; maxR = pow(totalOverFirst/n, 1/(n-1)); } else { minR = pow(totalOverFirst/n, 1/(n-1)); maxR = totalOverFirst/(n - 1); } // Starting guess scalar r = 0.5*(minR + maxR); for (label i = 0; i < maxIters; ++i) { const scalar prevr = r; const scalar fx = pow(r, n) - totalOverFirst*r - (1 - totalOverFirst); const scalar dfx = n*pow(r, n - 1) - totalOverFirst; r -= fx/dfx; if (mag(r - prevr) < tol) { break; } } return r; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::layerParameters::layerParameters ( const dictionary& dict, const polyBoundaryMesh& boundaryMesh ) : dict_(dict), numLayers_(boundaryMesh.size(), -1), relativeSizes_(dict.lookup("relativeSizes")), layerSpec_(ILLEGAL), firstLayerThickness_(boundaryMesh.size(), -123), finalLayerThickness_(boundaryMesh.size(), -123), thickness_(boundaryMesh.size(), -123), expansionRatio_(boundaryMesh.size(), -123), minThickness_ ( boundaryMesh.size(), dict.lookup("minThickness") ), mergeFaces_ ( boundaryMesh.size(), dict.found("mergeFaces") ? ( dict.lookup("mergeFaces") ? mergeFace::yes : mergeFace::no ) : mergeFace::ifOnMeshedPatch ), featureAngle_(dict.lookup("featureAngle", units::degrees)), concaveAngle_ ( dict.lookupOrDefault ( "concaveAngle", units::degrees, defaultConcaveAngle ) ), nGrow_(dict.lookup