CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Post-Processing

[swak4Foam] Trouble accessing fields within expressionField

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 20, 2016, 08:47
Default [swak4Foam] Trouble accessing fields within expressionField
  #1
Member
 
Join Date: Mar 2009
Posts: 75
Rep Power: 9
aerogt3 is on a distinguished road
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?

aerogt3 is offline   Reply With Quote

Old   January 31, 2016, 15:00
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,748
Blog Entries: 39
Rep Power: 103
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
Quick questions:
  1. Where and how did you define "UMean"?
  2. And is it "UMean" or "Umean"?
__________________
wyldckat is offline   Reply With Quote

Old   February 1, 2016, 05:15
Default
  #3
Member
 
Join Date: Mar 2009
Posts: 75
Rep Power: 9
aerogt3 is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
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.
aerogt3 is offline   Reply With Quote

Old   February 21, 2016, 15:06
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,748
Blog Entries: 39
Rep Power: 103
wyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of lightwyldckat is a glorious beacon of light
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.
__________________
wyldckat is offline   Reply With Quote

Old   June 10, 2016, 01:46
Default
  #5
New Member
 
Matt
Join Date: Oct 2012
Posts: 28
Rep Power: 6
fatirishman53 is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
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"
    );
fatirishman53 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing neighbor cells fields antoniofct OpenFOAM Programming & Development 3 May 13, 2015 17:53
Accessing Mesh, Fields in Foam::sixDoFRigidBodyMotionRestraints::linearSprin g kumar2 OpenFOAM Programming & Development 0 August 4, 2014 15:55
a reconstructPar issue immortality OpenFOAM Post-Processing 8 June 16, 2013 11:25
an odd(at least for me!) reconstructPar error on a field immortality OpenFOAM Running, Solving & CFD 3 June 3, 2013 22:36
PostChannel maka OpenFOAM Post-Processing 5 July 22, 2009 09:15


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