CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Community Contributions (https://www.cfd-online.com/Forums/openfoam-community-contributions/)
-   -   [swak4Foam] log velocity profile with groovyBC - syntax (https://www.cfd-online.com/Forums/openfoam-community-contributions/85895-log-velocity-profile-groovybc-syntax.html)

Kbshariff December 8, 2020 05:22

Hi, thank you Bernhard for the observation, I have modified the groovyBC as follows; I define the variables a and u_f as scalars and i use the *normal() to make the expression a vector. My main concern now is pos().z,

Code:

    inlet         
  {
    type            groovyBC;
    variables "a=0.197;u_f=0.00787;n=1e-5;";
    valueExpression "(2.5*u_f*log((u_f*pos().z)/(n))+a)*normal()";

  }

My main concern now is the defination of z as pos().z, when i run the case i get this error. Its no clear for me what is the source of error.

Code:

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


SIMPLE: convergence criteria
    field p      tolerance 0.001
    field U      tolerance 0.0001
    field "(k|epsilon)"  tolerance 0.0001

Reading field p

Reading field U

--> FOAM Warning :
    From groovyBCFvPatchField<Type>::groovyBCFvPatchField(const fvPatch& p,const DimensionedField<Type, volMesh>& iF,const dictionary& dict)
    in file groovyBCFvPatchField.C at line 141
    No value defined for U on inlet therefore using the internal field next to the patch
Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting turbulence model type RAS
Selecting RAS turbulence model kEpsilon
kEpsilonCoeffs
{
    Cmu            0.09;
    C1              1.44;
    C2              1.92;
    sigmaEps        1.11;
    C3              0;
    sigmak          1;
}

No MRF models present

Creating finite volume options from "constant/fvOptions"

Selecting finite volume options type actuationDiskSource
    Source: disk1
    - selecting cells using cellSet actuationDisk1
    - selected 1036 cell(s) with volume 9.78444444444e-05
    - selecting cells using points
    - creating actuation disk zone: disk1
    - force computation method: Froude

Starting time loop

Time = 1

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2  ? in /lib64/libpthread.so.0
#3  log in /lib64/libm.so.6
#4  Foam::log(Foam::Field<double>&, Foam::UList<double> const&) at ??:?
#5  Foam::log(Foam::UList<double> const&) at ??:?
#6  parserPatch::PatchValueExpressionParser::parse() at ??:?
#7  Foam::PatchValueExpressionDriver::parseInternal(int) at ??:?
#8  Foam::CommonValueExpressionDriver::parse(Foam::exprString const&, Foam::word const&) at ??:?
#9  Foam::tmp<Foam::Field<Foam::Vector<double> > > Foam::CommonValueExpressionDriver::evaluate<Foam::Vector<double> >(Foam::exprString const&, bool) at ??:?
#10  Foam::groovyBCFvPatchField<Foam::Vector<double> >::updateCoeffs() at ??:?
#11  Foam::fvMatrix<Foam::Vector<double> >::fvMatrix(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensionSet const&) at ??:?
#12  ? at ??:?
#13  ? at ??:?
#14  __libc_start_main in /lib64/libc.so.6
#15  ? at ??:?
Floating point exception

Thank you for your time and support.

Kbshariff December 8, 2020 06:01

i attached herewith files perusal

0/U
Code:

boundaryField
{

    inlet         
  {
    type            groovyBC;
    variables "a=0.197;u_f=0.00787;n=1e-5;";
    valueExpression "(2.5*u_f*log((u_f*pos().z)/(n))+a)*normal()";

  }



            outlet
                    {
                              type            zeroGradient;
                    }

        top
                {
                        type                slip;
                }
       
        bottom
                {
                        type                slip;
                }

        walls
                {
                        type                slip;
                }
"proc.*"
{
    type            processor;
}
       
}

0/p
Code:

internalField  uniform 0;

boundaryField
{

        inlet
                {
                        type          zeroGradient;
                }

            outlet
                    {
                              type          fixedValue;
                        value                uniform 0;
                    }

        top
                {
                        type                slip;       
                }
       
        bottom
                {
                        type                slip;       
                }

        walls
                {
                        type                slip;       
                }

"proc.*"
{
    type            processor;
}
}

0/eps

Code:

internalField  uniform 1.821e-5;  //4.851e-5;

boundaryField
{
    inlet
    {
        type            fixedValue;
        value          uniform 1.821e-5;  //4.851e-5;
    }
    outlet
    {
        type            zeroGradient;
    }
    top
    {
        type            epsilonWallFunction;
        value          uniform 1.821e-5;  //4.851e-5;
    }
    bottom
    {
        type            epsilonWallFunction;
        value          uniform 1.821e-5;  //4.851e-5;
    }
    walls
    {
        type            epsilonWallFunction;
        value          uniform 1.821e-5;  //4.851e-5;
    }

"proc.*"
{
    type            processor;
}
}

0/k
Code:

internalField  uniform 0.00001756;

boundaryField
{
    inlet
    {
        type            fixedValue;
        value          uniform 0.00001756;
    }
    outlet
    {
        type            zeroGradient;
    }
    top
    {
        type            kqRWallFunction;
        value          uniform 0.00001756;
    }
    bottom
    {
        type            kqRWallFunction;
        value          uniform 0.00001756;
    }
    walls
    {
        type            kqRWallFunction;
        value          uniform 0.00001756;
    }

"proc.*"
{
    type            processor;
}
}


gschaider December 8, 2020 17:47

Quote:

Originally Posted by Kbshariff (Post 790071)
Hi, thank you Bernhard for the observation, I have modified the groovyBC as follows; I define the variables a and u_f as scalars and i use the *normal() to make the expression a vector. My main concern now is pos().z,

Code:

    inlet         
  {
    type            groovyBC;
    variables "a=0.197;u_f=0.00787;n=1e-5;";
    valueExpression "(2.5*u_f*log((u_f*pos().z)/(n))+a)*normal()";

  }

My main concern now is the defination of z as pos().z, when i run the case i get this error. Its no clear for me what is the source of error.

Code:

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0


SIMPLE: convergence criteria
    field p      tolerance 0.001
    field U      tolerance 0.0001
    field "(k|epsilon)"  tolerance 0.0001

Reading field p

Reading field U

--> FOAM Warning :
    From groovyBCFvPatchField<Type>::groovyBCFvPatchField(const fvPatch& p,const DimensionedField<Type, volMesh>& iF,const dictionary& dict)
    in file groovyBCFvPatchField.C at line 141
    No value defined for U on inlet therefore using the internal field next to the patch
Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting turbulence model type RAS
Selecting RAS turbulence model kEpsilon
kEpsilonCoeffs
{
    Cmu            0.09;
    C1              1.44;
    C2              1.92;
    sigmaEps        1.11;
    C3              0;
    sigmak          1;
}

No MRF models present

Creating finite volume options from "constant/fvOptions"

Selecting finite volume options type actuationDiskSource
    Source: disk1
    - selecting cells using cellSet actuationDisk1
    - selected 1036 cell(s) with volume 9.78444444444e-05
    - selecting cells using points
    - creating actuation disk zone: disk1
    - force computation method: Froude

Starting time loop

Time = 1

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigFpe::sigHandler(int) at ??:?
#2  ? in /lib64/libpthread.so.0
#3  log in /lib64/libm.so.6
#4  Foam::log(Foam::Field<double>&, Foam::UList<double> const&) at ??:?
#5  Foam::log(Foam::UList<double> const&) at ??:?
#6  parserPatch::PatchValueExpressionParser::parse() at ??:?
#7  Foam::PatchValueExpressionDriver::parseInternal(int) at ??:?
#8  Foam::CommonValueExpressionDriver::parse(Foam::exprString const&, Foam::word const&) at ??:?
#9  Foam::tmp<Foam::Field<Foam::Vector<double> > > Foam::CommonValueExpressionDriver::evaluate<Foam::Vector<double> >(Foam::exprString const&, bool) at ??:?
#10  Foam::groovyBCFvPatchField<Foam::Vector<double> >::updateCoeffs() at ??:?
#11  Foam::fvMatrix<Foam::Vector<double> >::fvMatrix(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::dimensionSet const&) at ??:?
#12  ? at ??:?
#13  ? at ??:?
#14  __libc_start_main in /lib64/libc.so.6
#15  ? at ??:?
Floating point exception

Thank you for your time and support.


Seems that the log function is used outside the range on which it is defined (either 0 or negative). swak4Foam can't protect you from that. Of course you can always use max to make sure that you're in the comfort zone of the function: log(max(1e-10,x)) with x being the function you want to use. But of course you should think WHY is this outside of the comfort zone (because it might be a problem in your setup)

Kbshariff December 9, 2020 15:36

Thank you Bernhard,
Yes, the log function was used with wrong z position. Initially, z coordinates ranges from - 0.15 to 0.15. Calculating log of negative is mathematically wrong. I have now change the coordinates to 0 to 0.3.

The simulation now works well. Thank you once again.


All times are GMT -4. The time now is 14:38.