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] a groovyBC error (https://www.cfd-online.com/Forums/openfoam-community-contributions/110704-groovybc-error.html)

immortality December 18, 2012 11:20

a groovyBC error
 
why this error is shown?
thesis@thesis-X58A-UD7:~/Desktop/method_4$ rhoCentralFoam
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.1.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.1.0-0bc225064152
Exec : rhoCentralFoam
Date : Dec 18 2012
Time : 19:22:27
Host : "thesis-X58A-UD7"
PID : 3659
Case : /home/thesis/Desktop/method_4
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 thermophysical properties
Selecting thermodynamics package ePsiThermo<pureMixture<constTransport<specieThermo <hConstThermo<perfectGas>>>>>
Reading field U
Creating turbulence model
Selecting turbulence model type RASModel
Selecting RAS turbulence model kOmegaSST
kOmegaSSTCoeffs
{
alphaK1 0.85034;
alphaK2 1;
alphaOmega1 0.5;
alphaOmega2 0.85616;
Prt 1;
gamma1 0.5532;
gamma2 0.4403;
beta1 0.075;
beta2 0.0828;
betaStar 0.09;
a1 0.31;
c1 10;
}
Reading thermophysicalProperties
fluxScheme: Kurganov
Starting time loop
Mean and max Courant Numbers = 1.70419 74.97
deltaT = 1.33387e-10
Time = 1.33387e-10
diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal: Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal: Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0
 
--> FOAM FATAL ERROR:
Parser Error at "1.29-31" :"syntax error, unexpected TOKEN_points"
"(0<=time() && time()<=(w_w1-pts().y)/v_r)||((w_w1+w_p1-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2-pts().y)/v_r)||((w_w1+w_p1+w_w2+w_p2-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2+w_p2+w_w3-w_cell)/v_r)?1:0"
" ^^^ "
From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 802.
FOAM exiting

gschaider December 18, 2012 12:36

Quote:

Originally Posted by immortality (Post 398108)
why this error is shown?
 
--> FOAM FATAL ERROR:
Parser Error at "1.29-31" :"syntax error, unexpected TOKEN_points"
"(0<=time() && time()<=(w_w1-pts().y)/v_r)||((w_w1+w_p1-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2-pts().y)/v_r)||((w_w1+w_p1+w_w2+w_p2-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2+w_p2+w_w3-w_cell)/v_r)?1:0"
" ^^^ "
From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 802.
FOAM exiting

The problem is probably a mixing of point fields (fields defined on the vertices - which pts() is) and face fields (which is the regular thing). swak does not automatically interpolate between these (reasons are: loss of precision and ambiguity)

Either you juggle with the toFace() to toPoint() functions (see Examples) or you use pos() instead of pts() (which I think is what you wanted to use in the first place)

immortality December 19, 2012 08:14

thanks.I want to use fields on vertices.because I want the points on the patch gradually change from wall condition to environment(p0,T0).then I should use for example toPoint(U.x)? U should be internalField(U.x) for reading U from neighbour cells in grid.how should I merge these then?
thank you and best regards.
I wrote as this:
left
{
type groovyBC;
variables (
//"pi=3.1415926535;"
"ymax=max(pos().y);"
"ymin=min(pos().y);"
"r=0.06;"
"rpm=3600;"
"omega=rpm*pi/30;"
"v_r=r*omega;"
"w_cell=.003;"
"w_w1=.003;"
"w_p1=.06*11*pi/180;"
"w_w2=.06*49*pi/180;"
"w_p2=.06*30*pi/180;"
"w_w3=.003;"
"p0_1=250000;"
"T0_1=288;"
"p0_2=100000;"
"T0_2=288;"
"gamma=1.4;"
"R=287.14;"

);


fractionExpression "((0<=time() && time()<=(w_w1-pts().y)/v_r)||((w_w1+w_p1-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2-pts().y)/v_r)||((w_w1+w_p1+w_w2+w_p2-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2+w_p2+w_w3-w_cell)/v_r))?0:1";
valueExpression "((w_w1-pts().y)/v_r<time() && time()<(w_w1+w_p1-pts().y)/v_r)?(p0_1/pow((1+(gamma-1)/2*sqr(U.x)/(gamma*R*T0_1-(gamma-1)/2*sqr(U.x)),gamma/(gamma-1))):(p0_2/pow((1+(gamma-1)/2*sqr(U.x)/(gamma*R*T0_2-(gamma-1)/2*sqr(U.x)),gamma/(gamma-1)))";
value uniform 100000;
gradientExpression "0";

//type fixedValue;
//value uniform 250000;
}

gschaider December 19, 2012 08:34

Quote:

Originally Posted by immortality (Post 398237)
thanks.I want to use fields on vertices.because I want the points on the patch gradually change from wall condition to environment(p0,T0).then I should use for example toPoint(U.x)? U should be internalField(U.x) for reading U from neighbour cells in grid.how should I merge these then?
thank you and best regards.
I wrote as this:
left
{
type groovyBC;
variables (
//"pi=3.1415926535;"
"ymax=max(pos().y);"
"ymin=min(pos().y);"
"r=0.06;"
"rpm=3600;"
"omega=rpm*pi/30;"
"v_r=r*omega;"
"w_cell=.003;"
"w_w1=.003;"
"w_p1=.06*11*pi/180;"
"w_w2=.06*49*pi/180;"
"w_p2=.06*30*pi/180;"
"w_w3=.003;"
"p0_1=250000;"
"T0_1=288;"
"p0_2=100000;"
"T0_2=288;"
"gamma=1.4;"
"R=287.14;"

);


fractionExpression "((0<=time() && time()<=(w_w1-pts().y)/v_r)||((w_w1+w_p1-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2-pts().y)/v_r)||((w_w1+w_p1+w_w2+w_p2-pts().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2+w_p2+w_w3-w_cell)/v_r))?0:1";
valueExpression "((w_w1-pts().y)/v_r<time() && time()<(w_w1+w_p1-pts().y)/v_r)?(p0_1/pow((1+(gamma-1)/2*sqr(U.x)/(gamma*R*T0_1-(gamma-1)/2*sqr(U.x)),gamma/(gamma-1))):(p0_2/pow((1+(gamma-1)/2*sqr(U.x)/(gamma*R*T0_2-(gamma-1)/2*sqr(U.x)),gamma/(gamma-1)))";
value uniform 100000;
gradientExpression "0";

//type fixedValue;
//value uniform 250000;
}

I think what you want is rewrite some of the variables to points form ("ymax=max(pts().y);") and use the face positions ("pos()") in the main expression.

Draw yourself a sketch of a small sketch (5 faces or so are sufficient) and think what the difference in point and face positions mean for your expression

immortality December 22, 2012 10:47

I changed all terms to pos() function.but this error appeared:

fluxScheme: Kurganov
Starting time loop
Mean and max Courant Numbers = 1.70419 4.02331
deltaT = 2.48509e-08
Time = 2.48509e-08
diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal: Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal: Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0
smoothSolver: Solving for Ux, Initial residual = 0.00115429, Final residual = 4.61702e-18, No Iterations 3
smoothSolver: Solving for Uy, Initial residual = 1, Final residual = 8.05495e-17, No Iterations 3
diagonal: Solving for rhoE, Initial residual = 0, Final residual = 0, No Iterations 0
smoothSolver: Solving for e, Initial residual = 0.00265688, Final residual = 3.54541e-12, No Iterations 3
swak4Foam: Allocating new repository for sampledGlobalVariables
 
--> FOAM FATAL ERROR:
Parser Error at "1.33" :"syntax error, unexpected ')'"
"1-(gamma-1)*sqr(internalField(U))/(2*gamma*R*T0_1)"
" ^ "
From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 802.
FOAM exiting
 
---------------------------------------------------------------------------------------
my BC is:
---------------------------------------------------------------------------------------
left
{
type groovyBC;
variables (
//"pi=3.1415926535;"
"ymax=max(pos().y);"
"ymin=min(pos().y);"
"r=0.06;"
"rpm=3600;"
"omega=rpm*pi/30;"
"v_r=r*omega;"
"w_cell=.003;"
"w_w1=.003;"
"w_p1=.06*11*pi/180;"
"w_w2=.06*49*pi/180;"
"w_p2=.06*30*pi/180;"
"w_w3=.003;"
"p0_1=250000;"
"T0_1=288;"
"p0_2=100000;"
"T0_2=288;"
"gamma=1.4;"
"R=287.14;"
"par1=1-(gamma-1)*sqr(internalField(U))/(2*gamma*R*T0_1);"
"par2=1-(gamma-1)*sqr(internalField(U))/(2*gamma*R*T0_2);"


);


fractionExpression "(0<=time()&&time()<=(.003-pos().y)/22)||((.003+.01151917-pos().y)/22<=time()&&time()<=(.003+.01151917+.05131268-pos().y)/22)||((.003+.01151917+.05131268+.031415927-pos().y)/22<=time()&&time()<=(.003+.01151917+.05131268+.031 415927+.003-.003)/22)?0:1";
valueExpression "((w_w1-pos().y)/v_r<time() && time()<(w_w1+w_p1-pos().y)/v_r)? p0_1*pow(part1,3.5) : p0_2*pow(par2,3.5)";
value uniform 1000000;
gradientExpression "0";

//type fixedValue;
//value uniform 250000;
//(p0_1/pow(1+(gamma-1)/2*sqr(internalField(U)/(gamma*R*T0_1-(gamma-1)/2*sqr(internalField(U),3.5))
//(w_w1-pos().y)/22<time() && time()<(w_w1+w_p1-pos().y)/22)?
//p0_1*pow(1-(gamma-1)*sqr(internalField(U))/(2*gamma*R*T0_1),gamma/(gamma-1))
//2*gamma*R*T0_1
}
walls
{
type zeroGradient;

}
empty
{
type empty;

}

gschaider December 22, 2012 19:01

Quote:

Originally Posted by immortality (Post 398672)
 
--> FOAM FATAL ERROR:
Parser Error at "1.33" :"syntax error, unexpected ')'"
"1-(gamma-1)*sqr(internalField(U))/(2*gamma*R*T0_1)"
" ^ "
From function parsingValue
in file lnInclude/CommonValueExpressionDriverI.H at line 802.
FOAM exiting

How am I supposed to easily see which')' the '^' points too?

Using the CODE-tag for terminal output improves the usefulness tremendously (although in my example the '^' is still not at the right place):
Code:

--> FOAM FATAL ERROR:
Parser Error at "1.33" :"syntax error, unexpected ')'"
"1-(gamma-1)*sqr(internalField(U))/(2*gamma*R*T0_1)"
"                  ^ "

Anyway: your problem probably is that in OpenFOAM sqr of a vector is a symmetric tensor but in your expression the parser expects a scalar. So either use sqr(mag(U)) and then square it or something like U&U (insert the internalField correctly to make it work the way you want to)

immortality December 23, 2012 09:27

I refined it in this manner:
Code:

left
    {
      type groovyBC;

        variables (

      //"pi=3.1415926535;"
                  "ymax=max(pos().y);"
                  "ymin=min(pos().y);"
                  "r=0.06;"
                  "rpm=3600;"
                  "omega=rpm*pi/30;"
                  "v_r=r*omega;"
                  "w_cell=.003;"
                  "w_w1=.003;"
                  "w_p1=.06*11*pi/180;"
                  "w_w2=.06*49*pi/180;"
                  "w_p2=.06*30*pi/180;"
                  "w_w3=.003;"
                  "p0_1=2500000;"
                  "T0_1=288;"
                  "p0_2=1000000;"
                  "T0_2=288;"
                  "gamma=1.4;"
                  "R=287.14;"
                 
                 
);

   
       
      fractionExpression "(0<=time() && time()<=(w_w1-pos().y)/v_r)||((w_w1+w_p1-pos().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2-pos().y)/v_r)||((w_w1+w_p1+w_w2+w_p2-pos().y)/v_r<=time() && time()<=(w_w1+w_p1+w_w2+w_p2+w_w3-w_cell)/v_r)?0:1";
      valueExpression "(w_w1-pos().y)/v_r<time() && time()<(w_w1+w_p1-pos().y)/v_r) ? T0_1-(gamma-1)/(2*gamma*R)*magSqr(internalField(U.x)):T0_2-(gamma-1)/(2*gamma*R)*magSqr(internalField(U.x))";
      value uniform 288;
      gradientExpression "0";
     
    }

but the error is persistent:

Code:

Starting time loop

Mean and max Courant Numbers = 1.70419 4.02331
deltaT = 2.48546e-09
Time = 2.48546e-09

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal:  Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal:  Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0
smoothSolver:  Solving for Ux, Initial residual = 1, Final residual = 5.94738e-17, No Iterations 3
smoothSolver:  Solving for Uy, Initial residual = 1, Final residual = 1.2546e-16, No Iterations 3
diagonal:  Solving for rhoE, Initial residual = 0, Final residual = 0, No Iterations 0


--> FOAM FATAL ERROR:
 Parser Error at "1.60" :"syntax error, unexpected ')', expecting $end"
"(w_w1-pos().y)/v_r<time() && time()<(w_w1+w_p1-pos().y)/v_r) ? T0_1-(gamma-1)/(2*gamma*R)*magSqr(internalField(U.x)):T0_2-(gamma-1)/(2*gamma*R)*magSqr(internalField(U.x))"
"                                                            ^                                                                                                            "

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

FOAM exiting


gschaider December 23, 2012 11:02

Quote:

Originally Posted by immortality (Post 398779)
but the error is persistent:

Code:

Starting time loop

Mean and max Courant Numbers = 1.70419 4.02331
deltaT = 2.48546e-09
Time = 2.48546e-09

diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal:  Solving for rhoUx, Initial residual = 0, Final residual = 0, No Iterations 0
diagonal:  Solving for rhoUy, Initial residual = 0, Final residual = 0, No Iterations 0
smoothSolver:  Solving for Ux, Initial residual = 1, Final residual = 5.94738e-17, No Iterations 3
smoothSolver:  Solving for Uy, Initial residual = 1, Final residual = 1.2546e-16, No Iterations 3
diagonal:  Solving for rhoE, Initial residual = 0, Final residual = 0, No Iterations 0


--> FOAM FATAL ERROR:
 Parser Error at "1.60" :"syntax error, unexpected ')', expecting $end"
"(w_w1-pos().y)/v_r<time() && time()<(w_w1+w_p1-pos().y)/v_r) ? T0_1-(gamma-1)/(2*gamma*R)*magSqr(internalField(U.x)):T0_2-(gamma-1)/(2*gamma*R)*magSqr(internalField(U.x))"
"                                                            ^                                                                                                            "

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

FOAM exiting


Look at where the ^ is pointing. There's 6 '(' and this is the 7th ')' so the error message is spot-on: there is no way that at any point in the expression can there be more closing ')' than opening '('.

Have you ever considered to think for 5 minutes about what the error message means and whether it could be your input that caused it? I think that would be faster than copy/pasting it to the message board and waiting for someone else to do the thinking you should have done. Especially if people stop answering

immortality December 23, 2012 12:21

thanks.sorry also I grasped it after sending.good people never refuse to help even if the question is silly.
thanks for your help.:)


All times are GMT -4. The time now is 20:13.