CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   [swak4Foam] Trouble accessing fields within expressionField (https://www.cfd-online.com/Forums/openfoam-post-processing/165568-swak4foam-trouble-accessing-fields-within-expressionfield.html)

aerogt3 January 20, 2016 07:47

[swak4Foam] Trouble accessing fields within expressionField
 
Hello all,


I am trying to use swak4foam to calculate a velocity field (based on position in the mesh), and this works great! But then I try to add that velocity field to the UMean field calculate by OpenFOAM 2.4.0, using the following controlDict entry:

Code:

    UCalc
    {
        after  $monStart;
        type expressionField;
        outputControlMode  outputTime;
        outputInterval    $endTime;
        fieldName UCalc;
        dimension [ 0 1 -1 0 0 0 0 ];
        expression "UMean + Urot";
        autowrite true;
    }

This gives the following errors:

Code:

Creating expression field Urot ... type:volVectorField
[13]
[13]
[13] --> FOAM FATAL ERROR:
[13]  Parser Error for driver FieldValueExpressionDriver at "1.1-5" :"field UMean not existing or of wrong type"
"UMean + Urot"
  ^^^^^
--|   

Context of the error:


- Driver constructed from scratch
  Evaluating expression "UMean + Urot"
[13]
[13]
[13]    From function parsingValue
[13]    in file lnInclude/CommonValueExpressionDriverI.H at line 1189.
[13]
FOAM parallel run exiting

I am bit confused what is going wrong, as UMean definitely exists for all timesteps. Perhaps I need to load UMean within the controlDict entry, before swak4foam has access to it? Any ideas?


wyldckat January 31, 2016 14:00

Quick questions:
  1. Where and how did you define "UMean"?
  2. And is it "UMean" or "Umean"?

aerogt3 February 1, 2016 04:15

Quote:

Originally Posted by wyldckat (Post 583134)
Quick questions:
  1. Where and how did you define "UMean"?
  2. And is it "UMean" or "Umean"?

Thanks for the reply. UMean is created by the open foam function object fieldAverage.

wyldckat February 21, 2016 14:06

Quick answer: Sorry, but only today did I managed to come back to your problem.

OK, I believe that the problem is because you need to use a function object that loads the field after it's saved. For example:
Code:

readFields
{
    // Where to load it from (if not already in solver)
    functionObjectLibs ("libfieldFunctionObjects.so");

    type            readFields;
    fields          (UMean);
}

You will need to add this before the function object you provided.

The other solution is to use swak4Foam's own function object for calculating the "UMean" field.

fatirishman53 June 10, 2016 01:46

Quote:

Originally Posted by wyldckat (Post 586178)
Quick answer: Sorry, but only today did I managed to come back to your problem.

OK, I believe that the problem is because you need to use a function object that loads the field after it's saved. For example:
Code:

readFields
{
    // Where to load it from (if not already in solver)
    functionObjectLibs ("libfieldFunctionObjects.so");

    type            readFields;
    fields          (UMean);
}

You will need to add this before the function object you provided.

The other solution is to use swak4Foam's own function object for calculating the "UMean" field.

I was hoping that this would fix my problem as well, but it did not for either OF 2.3 or 3.0 :(

Here is what I am working with:
Code:

...
functions
{
    cubeUx
    {
        type expressionField;
        dimension [0 3 -3 0 0 0 0];
        fieldName "cubeUx";
        expression "pow(U.x,3)";
        verbose true;
        autowrite false;
        outputControl timeStep;
    }
   
    fieldAverage1
    {
        type            fieldAverage;
        functionObjectLibs ( "libfieldFunctionObjects.so" );
        enabled        true;
        outputControl  outputTime;

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            cubeUx
            {
                mean on;
                prime2Mean off;
                base time;
            }
        );
    }

    readFields
    {
        functionObjectLibs  ("libfieldFunctionObjects.so");
        type        readFields;
        fields      (cubeUxMean);
    }

    skewnessX
    {
        type expressionField;
        dimension [0 3 -3 0 0 0 0];
        fieldName "skewnessX";
        expression "(cubeUxMean-3*UMean.x*UPrime2Mean.xx-pow(UMean.x,3))/pow(UPrime2Mean.xx,1.5)";
        verbose true;
        autowrite true;
        outputControl timeStep;
    }
}

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


david112 May 12, 2017 10:34

Hi,

rigth now I have the same problem. readFields and also reading the Field with the solver does not solve that in OpenFOAM 4.1 :mad:

fatirishman53 May 12, 2017 15:02

Quote:

Originally Posted by david112 (Post 648657)
Hi,

rigth now I have the same problem. readFields and also reading the Field with the solver does not solve that in OpenFOAM 4.1 :mad:

Tiam addresses this issue here:
https://www.cfd-online.com/Forums/op...tml#post616247


All times are GMT -4. The time now is 22:10.