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] Error using groovyBC - 'parser error for expression driver' (https://www.cfd-online.com/Forums/openfoam-community-contributions/158992-error-using-groovybc-parser-error-expression-driver.html)

odellar September 7, 2015 09:13

Error using groovyBC - 'parser error for expression driver'
 
I'm using a valueExpression in my 0/U file in order to implement a boundary condition which is a function of a 'measurement' (probe reading). In the controlDict I have:

Code:

    vorticity
    {
        type expressionField;
        autowrite true;
        dimension [0 0 -1 0 0 0 0];
        fieldName "vorticity";
        expression "curl(U)";
        verbose true;
        autowrite true;
        outputControl timeStep;
    }

in order to compute the vorticity flow field whilst solving, followed by (again in the controlDict):

Code:

sensorMeasurement
        {
        type createSampledSet;
        outputControl outputTime;
        outputInterval 1;
        setName vorticity_sensor1;
        set {
                type cloud;
                axis xyz;
                points (
                        (0 -0.5 0.5)
                );
        } }

in order to 'measure' the vorticity at a point, (0 -0.5 0.5), using a probe - the setName is vorticity_sensor1.

In my 0/U file I then have something which looks like this:
Code:

BOUNDARY1
{
type groovyBC;
value uniform (0 0 0);
variables (
"vorticityMeasurement{set'vorticity_sensor1}=average(vorticity);"
"w=vorticityMeasurement;"
"wMovingAvg=deltaT()*w/15.4+(1-deltaT()/15.4)*wMovingAvg;" //**** THIS LINE ****
);
storedVariables (
{
name wMovingAvg;
initialValue "0";
}
);
valueExpression "vector(1.4142*wMovingAvg,1.4142*wMovingAvg,0)";
}

However when I try run the solver (pimpleFoam) I get the following error (clearly corresponding to the line I've highlighted above):

Code:

[0] --> FOAM FATAL ERROR:
[0]  Parser Error for driver PatchValueExpressionDriver at "1.45-44" :"syntax error, unexpected $end"
"deltaT()*w/15.4+(1-deltaT()/15.4)*wMovingAvg"

----------------------------------------------

Context of the error:


- From dictionary: /mnt/fastdata/cop13ojd/BFS_H_Infinity/processor0/0/U.boundaryField.actuator
  Evaluating expression "deltaT()*w/15.4+(1-deltaT()/15.4)*wMovingAvg"
[0]
[0]
[0]    From function parsingValue
[0]    in file lnInclude/CommonValueExpressionDriverI.H at line 1181.
[0]
FOAM parallel run exiting
[0]
[3]
[3]
[3] --> FOAM FATAL ERROR:
[3]  Parser Error for driver PatchValueExpressionDriver at "1.45-44" :"syntax error, unexpected $end"
"deltaT()*w/15.4+(1-deltaT()/15.4)*wMovingAvg"

----------------------------------------------

Can anyone help me out here?
Thank you

odellar September 21, 2015 09:34

No ideas?
 
No ideas? :(

odellar September 21, 2015 10:25

An idea
 
I've just thought - this could potentially because I'm using a quantity I've computed called vorticity, which is a vector quantity - I actually only mean the z-component of the vector - what is the syntax in openFOAM to address a particular element of the variable?

In matlab for example one would write vorticity(3) to access the third element of the vector.

Thanks

wyldckat September 21, 2015 12:14

Quick answer: I'm not familiar enough with groovyBC, but I suspect that the problem is in the first line of the expression list, namely this part:
Code:

set'vorticity_sensor1
The separator between "set" and "vorticity_sensor1" is a quote which is opened but not closed.

Where did you read about this feature, namely the ability to use the value on a "set"?

odellar September 21, 2015 12:51

Quote:

Originally Posted by wyldckat (Post 565010)
Quick answer: I'm not familiar enough with groovyBC, but I suspect that the problem is in the first line of the expression list, namely this part:
Code:

set'vorticity_sensor1
The separator between "set" and "vorticity_sensor1" is a quote which is opened but not closed.

Where did you read about this feature, namely the ability to use the value on a "set"?

Thanks, but that is the correct way of using that expression.

I *think* I've now got it working, by saying average(vorticity.z) in order to access the z-component. It seems to be running fine, so we'll see.


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