From 6928511a3d92ccdfbc241fe7317bed7ebca645cc Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 15 May 2023 14:19:18 +0100 Subject: [PATCH] nutWallFunctionFvPatchScalarField::yPlusLam: Improved ypl calculation to ensure nut is always positive --- .../nutWallFunctionFvPatchScalarField.C | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 4eaac02050..e6e73a1e7a 100644 --- a/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -155,13 +155,28 @@ Foam::scalar Foam::nutWallFunctionFvPatchScalarField::yPlusLam const scalar E ) { - scalar ypl = 11.0; + const scalar ypl0 = 12.0; + + scalar ypl = ypl0; for (int i=0; i<10; i++) { ypl = log(max(E*ypl, 1))/kappa; } + // If ypl is greater than the starting value recalculate from a larger value + // to ensure the result is slightly larger rather than slightly smaller + // than exact value + if (ypl > ypl0) + { + ypl += 1; + + for (int i=0; i<10; i++) + { + ypl = log(max(E*ypl, 1))/kappa; + } + } + return ypl; }