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] groovyBC error: velocity profile (2D) >> what's wrong? (https://www.cfd-online.com/Forums/openfoam-community-contributions/137571-groovybc-error-velocity-profile-2d-whats-wrong.html)

vitorspadeto June 18, 2014 16:04

groovyBC error: velocity profile (2D) >> what's wrong?
 
groovyBC error

Hi everybody!



I'm trying to implement a parabolic velocity profile to my inlet (2D), cordinates: (x,z) . Inlet is located between the coordinates z= 0 and z=0.001. the parabolic equation for this profile is

Velocity_x_direction = 99*z - 98072*z².

This equation in this range of points (between z= 0 and z=0.001) give the exact velocity profile that I need.

I already add "libs" lines in the end of ControlDict file (I'm using swak4Foam to use GroovyBC):

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application    icoFoam;

startFrom      startTime;

startTime      0;

stopAt          endTime;

endTime        10;

deltaT          0.1;

writeControl    adjustableRunTime;

writeInterval  1;

purgeWrite      0;

writeFormat    ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision  6;

runTimeModifiable true;

adjustTimeStep  yes;

maxCo          1;

maxAlphaCo      1;

 maxDeltaT      1;



libs (
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
    );


// ************************************************************************* //

And this is my U file, with the profile velocity:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    inlet
    {
    type            groovyBC;
    variables "zp=pts().z;    velocity=(99.036*zp-98072.289*pow(zp,2));";
    valueExpression "velocity";
    value          uniform (0.02 0 0);
  }


    outlet
    {
        type            zeroGradient; // At the outlet the velocity is unknown so we take the gradient of velocity as zero here
    }

    wall
    {
        type            fixedValue;
        value                uniform (0 0 0); // we use the no slip condition at the walls so u = v = 0
    }
 
 frontAndBack
    {
        type            empty;
    }

}

// ************************************************************************* //


This is the error that appeared on the terminal:

HTML Code:

sp@sp-945GCM-S2C:~/PGSPAD/exemplos_para_o_PG/blood/Newtonian$ icoFoam
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.2.0-5be49240882f
Exec  : icoFoam
Date  : Jun 18 2014
Time  : 17:01:52
Host  : "sp-945GCM-S2C"
PID    : 4579
Case  : /home/sp/PGSPAD/exemplos_para_o_PG/blood/Newtonian
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

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

Create mesh for time = 0

Reading transportProperties

Reading field p

Reading field U

Reading/calculating face flux field phi


Starting time loop

Time = 0.1

Courant Number mean: 0.00555556 max: 10
word::stripInvalid() called for word velocity
    For debug level (= 2) > 1 this is considered fatal
Abortado (imagem do núcleo gravada)


What Should I do to correct this error?

THANKS FRIENDS!

gschaider June 18, 2014 16:24

Quote:

Originally Posted by vitorspadeto (Post 497676)
groovyBC error

Hi everybody!



I'm trying to implement a parabolic velocity profile to my inlet (2D), cordinates: (x,z) . Inlet is located between the coordinates z= 0 and z=0.001. the parabolic equation for this profile is

Velocity_x_direction = 99*z - 98072*z².

This equation in this range of points (between z= 0 and z=0.001) give the exact velocity profile that I need.

I already add "libs" lines in the end of ControlDict file (I'm using swak4Foam to use GroovyBC):

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application    icoFoam;

startFrom      startTime;

startTime      0;

stopAt          endTime;

endTime        10;

deltaT          0.1;

writeControl    adjustableRunTime;

writeInterval  1;

purgeWrite      0;

writeFormat    ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision  6;

runTimeModifiable true;

adjustTimeStep  yes;

maxCo          1;

maxAlphaCo      1;

 maxDeltaT      1;



libs (
      "libOpenFOAM.so"
      "libsimpleSwakFunctionObjects.so"
      "libswakFunctionObjects.so"
      "libgroovyBC.so"
    );


// ************************************************************************* //

And this is my U file, with the profile velocity:

Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      volVectorField;
    object      U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions      [0 1 -1 0 0 0 0];

internalField  uniform (0 0 0);

boundaryField
{
    inlet
    {
    type            groovyBC;
    variables "zp=pts().z;    velocity=(99.036*zp-98072.289*pow(zp,2));";
    valueExpression "velocity";
    value          uniform (0.02 0 0);
  }


    outlet
    {
        type            zeroGradient; // At the outlet the velocity is unknown so we take the gradient of velocity as zero here
    }

    wall
    {
        type            fixedValue;
        value                uniform (0 0 0); // we use the no slip condition at the walls so u = v = 0
    }
 
 frontAndBack
    {
        type            empty;
    }

}

// ************************************************************************* //


This is the error that appeared on the terminal:

HTML Code:

sp@sp-945GCM-S2C:~/PGSPAD/exemplos_para_o_PG/blood/Newtonian$ icoFoam
/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.2.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 2.2.0-5be49240882f
Exec  : icoFoam
Date  : Jun 18 2014
Time  : 17:01:52
Host  : "sp-945GCM-S2C"
PID    : 4579
Case  : /home/sp/PGSPAD/exemplos_para_o_PG/blood/Newtonian
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Disallowing user-supplied system call operations

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

Create mesh for time = 0

Reading transportProperties

Reading field p

Reading field U

Reading/calculating face flux field phi


Starting time loop

Time = 0.1

Courant Number mean: 0.00555556 max: 10
word::stripInvalid() called for word velocity
    For debug level (= 2) > 1 this is considered fatal
Abortado (imagem do núcleo gravada)


What Should I do to correct this error?

THANKS FRIENDS!

The problem is probably the spaces between ";" and "velocity".

Which version of swak4Foam are you using? I thought that problem was already fixed

vitorspadeto June 18, 2014 16:35

swak4Foam 0.3.0


Inserting "normal()"


inlet
{
type groovyBC;
variables "zp=pts().z;velocity=((99.036*zp)-98072.289*pow(zp,2))*normal();";
valueExpression "velocity";
value uniform (1 0 0);
}


new error:

Code:

--> FOAM FATAL ERROR:
 Parser Error for driver PatchValueExpressionDriver at "1.10-11" :"syntax error, unexpected pointScalarID"
"((99.036*zp)-98072.289*pow(zp,2))*normal()"
          ^^
-----------|

Context of the error:


- From dictionary: /home/sp/PGSPAD/exemplos_para_o_PG/blood/Newtonian/0/U.boundaryField.inlet
  Evaluating expression "((99.036*zp)-98072.289*pow(zp,2))*normal()"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1181.

FOAM exiting


gschaider June 18, 2014 18:36

Quote:

Originally Posted by vitorspadeto (Post 497685)
swak4Foam 0.3.0


Inserting "normal()"


inlet
{
type groovyBC;
variables "zp=pts().z;velocity=((99.036*zp)-98072.289*pow(zp,2))*normal();";
valueExpression "velocity";
value uniform (1 0 0);
}


new error:

Code:

--> FOAM FATAL ERROR:
 Parser Error for driver PatchValueExpressionDriver at "1.10-11" :"syntax error, unexpected pointScalarID"
"((99.036*zp)-98072.289*pow(zp,2))*normal()"
          ^^
-----------|

Context of the error:


- From dictionary: /home/sp/PGSPAD/exemplos_para_o_PG/blood/Newtonian/0/U.boundaryField.inlet
  Evaluating expression "((99.036*zp)-98072.289*pow(zp,2))*normal()"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1181.

FOAM exiting


Scalar constants are "on the faces". To use them on points you'll have to wrap them in toPoint().

Anyway: leave that. I think you want to use pos() instead of pts().

vitorspadeto June 19, 2014 15:31

thanks gschaider!

Problem Solved! Now beginners can use this post to learn more about swak4Foam/GroovyBC!


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