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

Calculate a new filed from variables in the controldict

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 2, 2020, 05:00
Default Calculate a new filed from variables in the controldict
  #1
Senior Member
 
Carlo_P
Join Date: May 2019
Location: Italy
Posts: 176
Rep Power: 8
Carlo_P is on a distinguished road
I would like to calculate the absoulute presssure starting from the cinematic pressure given from a simpleFoam simulation.


I know that it is possible to do in paraview, but how can be done in openFOAM directly?


something like #calc pAbs=p*1.2+101.325


How can be written in the controldict as functionObject?
Carlo_P is offline   Reply With Quote

Old   October 2, 2020, 10:17
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Hello Carlo,

Depending on what OpenFOAM version you are using, you should manage to do it either with the reference functionObject for ESI's OF versions, or with a combination of scale and add functionObject for the foundation's versions.

Cheers,
Yann
Yann is offline   Reply With Quote

Old   October 2, 2020, 10:51
Default
  #3
Senior Member
 
Carlo_P
Join Date: May 2019
Location: Italy
Posts: 176
Rep Power: 8
Carlo_P is on a distinguished road
For me it is not a version problem, I can use both.


If I understood correctly, I have to put this lines in the controlDict, correclty?


Quote:
"
reference1 { // Mandatory entries (unmodifiable) type reference; libs (fieldFunctionObjects); // Mandatory (inherited) entry (runtime modifiable) field <field>; // Optional entries (runtime modifiable) position (0 0 0); scale 1.0; offset 0.0; interpolationScheme cell; // Optional (inherited) entries ... }
"
In field I have to write p, correct?
Then scale 1.2

but for the absolute pressure? (+101325)

Should go in the offset?

Thanks a lot!
Carlo_P is offline   Reply With Quote

Old   October 2, 2020, 11:28
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,236
Rep Power: 29
Yann will become famous soon enoughYann will become famous soon enough
Quote:
Originally Posted by Carlo_P
In field I have to write p, correct?
Then scale 1.2

but for the absolute pressure? (+101325)

Should go in the offset?
This was my first idea, but after having a look at the function definition, I see the scaling factor also effects the offset value:

Code:
   r_c = s(f_{c}(t) - f_p + f_{off})

where

        r_c    | field values at cell
        s     | optional scale factor (default = 1)
        f_{c}(t)  | current field values at cell at this time
        f_p    | field value at position
        f_{off}  | offset field value (default = 0)
In order to make it work, you should divide your offset value by the scaling factor to achieve the operation you want to do ( 1.2.p+101325 )
So it should give you something like :

Code:
    p_Abs
    {
        type        reference;
        libs        (fieldFunctionObjects);

        field       p;

        scale       1.2;
        offset      84437.5; //ie 101325/1.2
    }

Of course you can add usual parameters for function objects, such as writeControl and writeInterval to control the function execution.
Let us know if it does the job for you!

Cheers,
Yann
Yann is offline   Reply With Quote

Reply

Tags
postprocessing; openfoam;


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
How to define and calculate LES variables rhoPisoFoam Jotazeld OpenFOAM 1 April 3, 2020 05:12
OpenFOAM - Control and Editing of Lagrangian Output Variables gmag OpenFOAM Programming & Development 1 June 25, 2019 13:29
Sensitivity information for custom design variables dghate SU2 0 March 20, 2017 07:39
Need of Help: HowTo designate explicitely unknown variables of a question? Democritus OpenFOAM Programming & Development 6 April 12, 2016 09:38
how to calculate the averaged mass flow along a line over time ? iampolaris OpenFOAM Post-Processing 0 March 10, 2011 23:03


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