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

[swak4Foam] Trouble accessing fields within expressionField

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By wyldckat
  • 1 Post By fatirishman53

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 20, 2016, 07:47
Default [swak4Foam] Trouble accessing fields within expressionField
  #1
Member
 
Join Date: Mar 2009
Posts: 90
Rep Power: 17
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, 14:00
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quick questions:
  1. Where and how did you define "UMean"?
  2. And is it "UMean" or "Umean"?
ali akbar75 likes this.
__________________
wyldckat is offline   Reply With Quote

Old   February 1, 2016, 04:15
Default
  #3
Member
 
Join Date: Mar 2009
Posts: 90
Rep Power: 17
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, 14:06
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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
Member
 
Matt
Join Date: Oct 2012
Posts: 39
Rep Power: 13
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

Old   May 12, 2017, 10:34
Default
  #6
New Member
 
David Kinast
Join Date: Nov 2016
Posts: 15
Rep Power: 9
david112 is on a distinguished road
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
david112 is offline   Reply With Quote

Old   May 12, 2017, 15:02
Default
  #7
Member
 
Matt
Join Date: Oct 2012
Posts: 39
Rep Power: 13
fatirishman53 is on a distinguished road
Quote:
Originally Posted by david112 View Post
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
Tiam addresses this issue here:
https://www.cfd-online.com/Forums/op...tml#post616247
Inquisitor101 likes this.
fatirishman53 is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing neighbor cells fields antoniofct OpenFOAM Programming & Development 7 May 3, 2021 03:14
Accessing Mesh, Fields in Foam::sixDoFRigidBodyMotionRestraints::linearSprin g kumar2 OpenFOAM Programming & Development 3 August 4, 2014 16:06
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 09:39.