CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Post-Processing (
-   -   InterFoam freeSurface area calculation with sampleSurface (

jaswi December 28, 2007 07:32

Dear Forum Wish you all a v
Dear Forum

Wish you all a very nice day.

I am using interFoam and for the post processing i need the surface area of the free surface.

Using sampleSurface i could extract the isoSurface. Didn't know it was so easy !!!!! :-)

This is how the sampleDict looks
interpolationScheme cellPointFace;

surfaceFormat foamFile;


name gammaSurface;
field gamma;
value 0.5;


As a result i have the faces and points which correspond to this surface. Using the able given dict with the

surfaceFormat vtk;

I could see the surface in paraFoam.

I sense that with points and faces available one can for sure calculate the area of this surface.
Please share if someone knows about a utility or tool in openFoam to take the next step.

Wishing you all Happy Holidays


mattijs December 28, 2007 10:38

Can't Paraview calculate the a
Can't Paraview calculate the area?

jaswi December 28, 2007 16:29

Hi Mattijs Thanks for your
Hi Mattijs

Thanks for your reply.

I tried various options under the filter section of paraview but couldn't get the job done.

The isoSurface option in paraview shows the free surface corresponding to gamma lying in the interval [0,1] but no where i could find an option which could calculate its area.

It seems from your question that it must be quite easy to do that. please give some tips where to look for or which filter does that.

Best Regards

mattijs December 29, 2007 09:57

Try selecting the 'foamFile' t
Try selecting the 'foamFile' type (sampleSurface/surfaceWriters/foamFile/foamFile.C).

Read in your pointField from an IFstream of the "points" file. Read in a faceList from the "faces" file. Sum all areas:

scalar area = 0;
forAll(faces, i)
area += faces[i].mag(points);

asaha December 29, 2007 12:42

It is very interesting to find
It is very interesting to find the area of free surface, though I have never thought of it before doing with interFoam. I would appreciate giving details how to implement this.

jaswi December 29, 2007 15:14

Hi Mattijs Thanks once agai
Hi Mattijs

Thanks once again for your reply.

Will try it and probably will need some more help if i would get some compiling errors.

Best Regards

saf5029 June 26, 2008 14:40

Jaswinder, I have created a

I have created a sampleSurfaceDict 100% identical to yours, and when I execute it, my files for
sampleSurface/15/gammaSurface/points and
merely look like this:


Did you ever experience this sort of issue?? If so can you provide any insight??

PrzemekPL December 9, 2009 04:52

Hi Jaswinder and other OF users,

Did you manage to calculate freeSurace area?
I'm dealing with the same problem now.
I'm using OF1.6
I understand Jaswinders way of thinking (first post in this thread) but I can't follow mattijs tips.

Could anyone give me and other users more tips regarding to the freeSurface area calculation.


jaswi December 10, 2009 09:57

Hi Przemek

Please insert this into your code and it shall give you the correct free surface area.
(this code snippet is available courtesy of Eugene De Villiers)

volScalarField gradGamma
= mag(fvc::grad(gamma));
scalar totalSurfaceArea
= sum(gradGamma.internalField()*mesh.V());

For parallel runs, change sum to gSum. For a simple check for validation, try calculating area of circle or rectangle for cylindrical and cube geometries. In that way you will see that this formulation does gives you a very accurate calculation for surface area.

Hope that helps

Best Regards

PrzemekPL December 10, 2009 12:07

Hi Jaswi,

Thank you for your answer!!

I'll apply your code before next simulation.
This will give me area of the whole free surface but I need also to measure free surface area only in some particular locations.
I just found how to make it in paraview without any additional coding.
I write it here for others, hope this will help someone:)

Step by step, how to measure free surface area in paraview:
  1. Use Contour tool to plot free surface.
  2. Use Clip to show only interesting for you part of the domain and free surface which has to be measured.
  3. Use Integrate Variables tool. Table with data should appear. In table change Attribute from Point Data to Cell Data and you should see Area in one of the columns. This is what you are looking for:)
Alternative way:
  1. Use Contour tool to plot free surface.
  2. Use Clip to show only interesting you part of the domain and free surface which has to be measured.
  3. Export Data to .VRML format which can be imported in some graphical software. I've imported it in Rhinoceros and used it to measure area of the free surface.


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