CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (https://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   yPlusLam() in RASModel.C (https://www.cfd-online.com/Forums/openfoam-bugs/67487-ypluslam-rasmodel-c.html)

 guanghaowu August 17, 2009 02:41

yPlusLam() in RASModel.C

In $SRC/turbulenceModels/incompressible/RAS/RASModel.C, Line148 scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const { scalar ypl = 11.0; for (int i=0; i<10; i++) <== ??? { ypl = log(max(E*ypl, 1))/kappa; } return ypl; } I cant understand the for{...}, how about as follows? scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const { scalar ypl = 11.0; ypl = log(max(E*ypl, 1))/kappa; return ypl; } Also, in$SRC/turbulenceModels/compressible/RAS/RASModel.C, Line153

scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
{
scalar ypl = 11.0;

for (int i=0; i<10; i++)
{
ypl = log(E*ypl)/kappa;
}

return ypl;
}

=>

scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const
{
scalar ypl = 11.0;

ypl = log(max(E*ypl, 1))/kappa;

return ypl;
}

 ngj August 17, 2009 03:12

Good morning

It is because it is a non-linear equation, hence you need to solve it in an iterative manner.

Best regards,

NIels

 guanghaowu August 17, 2009 03:20

Hi, NLels

Just now I found its my misunderstanding.
You've replied before I delete my thread.

However, thank you very much.

 feldy77 March 20, 2012 19:45

Dear friends,
I am also puzzled about the above for loop.
Can you please explain in more detais which non linear equation it
supposed to solve and how it does it
Mnay tahnks, Yuri

 AlexC March 18, 2014 14:06

I am getting an error where the product E*ypl was negative in:

Quote:
 ypl = log(E*ypl)/kappa;
I ran gdb and here's the output that shows a log of a negative number, and the values of kappa, and E:

Quote:
 (gdb) bt #0 0x00007ffff162ead4 in log () from /lib64/libm.so.6 #1 0x00007ffff5bd67ad in Foam::log (s=-0.0072670797110974744) at /home/achan/foam/foam-extend-3.0/src/foam/lnInclude/Scalar.H:242 #2 0x00007ffff3af7d9e in Foam::compressible::RASModel::yPlusLam (this=0xd3bb10, kappa=0.40999999999999998, E=0.95255364484361649) at RASModel/RASModel.C:162 #3 0x00007ffff3bca35a in Foam::compressible::RASModels::mutRoughWallFunctio nFvPatchScalarField::calcMut ( this=0xd41d10) at derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C:98 #4 0x00007ffff3bc9321 in Foam::compressible::RASModels::mutWallFunctionFvPa tchScalarField::updateCoeffs ( this=0xd41d10) at derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C:192 #5 0x00000000004c0ff5 in Foam::fvPatchField::evaluate (this=0xd41d10) at /home/achan/foam/foam-extend-3.0/src/finiteVolume/lnInclude/fvPatchField.C:237 #6 0x00000000004b12d9 in Foam::GeometricField::GeometricBoundaryField::evaluate (this=0xd3c350) at /home/achan/foam/foam-extend-3.0/src/foam/lnInclude/GeometricBoundaryField.C:308 #7 0x000000000049ba1e in Foam::GeometricField::correctBoundaryConditions (this=0xd3c278) at /home/achan/foam/foam-extend-3.0/src/foam/lnInclude/GeometricField.C:880 #8 0x00007ffff3b37e4c in Foam::compressible::RASModels::kEpsilon::correct (this=0xd3bb10) at kEpsilon/kEpsilon.C:335
How could that product be negative?

 randolph July 11, 2018 12:57

Quote:
 Originally Posted by AlexC (Post 480724) Two years later, I too have a question about this - why only iterate 10 times? I am getting an error where the product E*ypl was negative in: I ran gdb and here's the output that shows a log of a negative number, and the values of kappa, and E: How could that product be negative?
ypl = log(max(E*ypl, 1))/kappa;

 mAlletto September 23, 2020 04:17

Just for clarification: The function calculates the intersection between the velocity profile of the laminar sublayer and the velocity profile in the log layer which results in the non linear equation solved:

 All times are GMT -4. The time now is 16:07.