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/)
-   -   Calculate a new filed from variables in the controldict (https://www.cfd-online.com/Forums/openfoam-post-processing/230709-calculate-new-filed-variables-controldict.html)

Carlo_P October 2, 2020 04:00

Calculate a new filed from variables in the controldict
 
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?

Yann October 2, 2020 09:17

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

Carlo_P October 2, 2020 09:51

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!

Yann October 2, 2020 10:28

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


All times are GMT -4. The time now is 23:14.