CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   interFoam : post processing (

udiitm February 20, 2012 07:16

interFoam : post processing

I want to collect the cell information on the basis of alpha value ( 0.5 i.e. at interface) and the pressure at nearby cells with their x and y co-ordinates.
The information i have to get is interface.sigmaK())*fvc::snGrad(alpha1)
in the part

fvc::interpolate(interface.sigmaK())*fvc::snGrad(a lpha1)

- ghf*fvc::snGrad(rho)

Please tell me how to extract these information?
I need the information in the following format:
for each value of alpha=0.5 i.e at interface

Co- ordinates.... value of sigmaK* grad(alpha)....... Value of pressure at near by cells
X Y................... (as mentioned above).................. p1 p2 p3 p4


Bernhard February 20, 2012 09:22

What is your question?

udiitm February 21, 2012 02:10

Dear Bernhard,
Sorry for the incomplete thread...My question is how to get the information of Cell at interface and the corresponding value of sigmaK*grad(alpha) and pressure value at near by cell as i have edited in original thread?


Bernhard February 21, 2012 04:11

The easiest would be to do this during runtime.

Create a volVectorField (name X here), like for U in createFields.H (only replace MUST_READ by NO_READ)

Then you can easily write
X=fvc::reconstruct( fvc::interpolate(interface.sigmaK() ) * fvc::snGrad(alpha1) )

This should be enough to recompile. During runtime you will now create a field X.

You can combine this with sampling during runtime put this in your controlDict

        type            surfaces;
        outputControl  outputTime;
        outputInterval  1; 
        surfaceFormat  vtk;
                type        isoSurfaceCell;
                isoField    alpha1;
                isoValue    0.5;
                interpolate false;
                regularise  false;
        interpolationScheme cell;

Which basically creates an iso-surface at alpha1=0.5, and interpolates X to it. The resulting vtk files can easily be read in ParaView,

Good luck!

udiitm February 23, 2012 05:58

Dear Bernhard,

Thanks for your reply. I have tried to compile the changes in createField.H but got an error:

error: ‘interface’ was not declared in this scope

when i used the expression for "X" i.e.

X=fvc::interpolate(interface.sigmaK())*fvc::snGrad (alpha1) 'OR'
X=fvc::reconstruct(fvc::interpolate(interface.sigm aK())*fvc::snGrad(alpha1))


Bernhard February 23, 2012 06:32

My excuses for being incomplete in my previous post.

In createFields.H you only create the field X as you create U (just to have it somewhere available)

You want to update and store the value for X each timestep, so your expression should be inside the timeloop. createFields is of course only executed once, before the simulation really starts. I would put it in the main file (interFoam.C), just in front of runTime.write(). (Also give it a name different from X, to make it more or less self-explanatory for future users)

Finally, it is always a good idea to carefully read the errormessages of the compiler, since they give a good explanation on where to find the error. As interface was not declared, I suppose you put the line with X higher than line 87 of createFields.H.

udiitm March 2, 2012 01:30

Dear Bernhard,

Thanks for your reply.
your suggestion was very helpful for solving my problem


udiitm March 21, 2012 06:47

Dear Bernhard,
Thanks for your suggestion.
Now I want to get the information of cells ( elements) which contains some value for the variable "X" calculated by above steps.
I am actually looking for the neighbour cells for the cells containing non-zero value of variable "X" to manipulate pressure and other values. i.e.

suppose for cell(i,j) with X = non-zero value
I need pressure (P) for cells ( i+1,j ; i-1,j ; i,j-1 ; i,j+1 ; i,j-1)

Thanks and Regards,

angelmonsalve August 11, 2015 18:10

Thanks for this explanation!! couple of years later but works pretty well

All times are GMT -4. The time now is 20:45.