CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   How to create a free surface application in Openfoam ? (

phuchuynh July 27, 2011 23:29

How to create a free surface application in Openfoam ?
i am new user of OpenFoam (1.7.1) and I want to creat a free surface application.
For example : in backward facing, I want to creat a free upper surface ?

thank you !


elvis July 28, 2011 03:28


In my opinion
the dam break case is a free surface application

or tank sloshing
https://openfoam-extend.svn.sourcefo...ckFoam/tank3D/ but this is OpenFOAM-1.6-ext

so have a look at interFoam or multiphaseInterFoam

kwardle July 28, 2011 14:55

Right. Just take one of the backward step example cases and tweak it to run with interFoam. Take a look at the damBreak tutorial for interFoam to see what files you need (e.g. you need to make an alpha1 field and may need to change the name of p to p_rgh).

You should be able to set the alpha1 fraction on the inlet to 1 and start with the volume empty and watch it fill up. You may have to tweak the outlet BC (perhaps like the top boundary on damBreak--although I am not sure if this will work correctly. There may be a better BC type for this sort of outlet (half-full liquid flow).

Hope this is useful.

phuchuynh August 2, 2011 07:40

I want to creat a free surface application for solvers ..basic/scalarTransportFoam/pitzDaily.
I replaced the words in library blockmeshDict " wall upperWall " by " patch atmosphere" ; in libray boundary and T , U " upper Wall " by "atmosphere " , But the result remains unchanged. So how do I do ?
Plz ! help me ?
thanks !

kwardle August 2, 2011 10:51

Sounds like all you have done is change the name of the boundaries. You need to change the names in constant/polyMesh/boundary (or rerun blockMesh with your modified blockMeshDict). You also must change the boundary conditions in the 0 directory. You will need to copy the alpha1 file from a damBreak case and change the BC names to match the new case. You will need to add an inlet (which will be type fixedValue) for the inlet. You'll need to update U and p (as p_rgh) as well. You will also need to copy the fvSolution and fvSchemes files from the damBreak case into the new one (alternatively, you can just copy the whole damBreak case and copy in your blockMeshDict from the back step case and start modifying from there). Does this make sense? If you make some changes and try to run the case and get some errors, don't give up, just take a look at what they say--usually they will tell you what is missing so you can make it work.

phuchuynh August 3, 2011 15:34

1 Attachment(s)
thank Kent for your interest to my topic !
I copied the alpha1,,p_rgh, U files form a damBreak/0 directory and to change the boundary conditions. I also copied the fvSolution and fvSchemes files from the damBreak case into the new case.
However, appeared some errors

keyword SIMPLE is undefined in dictionary "/home/phucdaigia/OpenFOAM/root-1.7.1/run/tutorials/basic/scalarTransportFoamB/pitzDaily/system/fvSolution"

file: /home/phucdaigia/OpenFOAM/root-1.7.1/run/tutorials/basic/scalarTransportFoamB/pitzDaily/system/fvSolution from line 22 to line 58.

    From function dictionary::subDict(const word& keyword) const
    in file db/dictionary/dictionary.C at line 456.

FOAM exiting

Plz, help me ? thanks ....

kwardle August 4, 2011 10:32

Inlet on alpha1 should be:

type fixedValue;
value uniform 1;

and for U you need to specify a inlet flow velocity--right now it is (0 0 0).

As for your error message, what solver are you trying to run? You should be running interFoam (but from the error message I am guessing you are not) which means in your system/fvSolution file it should say "PISO" where it now says SIMPLE. You should just copy the fvSolution, fvSchemes, and controlDict files from the damBreak tutorial for interFoam. You will also need the files from constant there too (transportProperties, turbulenceProperties, g).

Hope this helps.

phuchuynh August 9, 2011 03:39

2 Attachment(s)
Thank for your help ! I did as your request and received this result. However, I haven't seen any change of the free surface ?

Please, You can help me ?

kwardle August 11, 2011 17:07

First of all, what are you plotting in your attached results? Looks like the velocity or pressure field not the volume fraction field (alpha). Also, unless you sent me an older version of the case, you did not make the changes I suggested. Here is what you need to do:

- copy fvSolution, fvSchemes, and transportProperties from the damBreak tutorial for interFoam

- for your setFieldsDict, change the patch for alpha1 to something useful such as
box (-1 0 -1) (0 1 1);
which will patch alpha1 into the inlet section

- fix 0/p_rgh so it has frontAndBack instead of defaultFaces

- I would also set 0/U on the inlet to be something smaller say (1 0 0) instead of 10

This will work with interFoam. I have tried it and attached is an animation of the results out to t=0.75s. As you can see, the outlet BC is a little wonky--basically, your outlet is not an outlet, but a wall and so stuff is flowing up the wall and out the top (never to return...).

Good luck!

phuchuynh August 11, 2011 23:59

1 Attachment(s)
Hi Kwardle,
I user OF 1.7.1.
I sent you sent me an older version of the case, and my result was run as above.
thanks !

kwardle August 12, 2011 09:29

I tried this with interFoam in 1.7.x and see you are still missing PISO in fvSolutions which means you haven't made all the changes. Please see my previous post. This tells you exactly what changes you need to make to get this working with interFoam. Also, you will want to patch in alpha1 using setFields as I mentioned above so that the solution starts with a little liquid inside the inlet BC--if you don't do this, sometimes you can get screwy startup.

phuchuynh August 15, 2011 05:22

Hi kwardle !

I run the solver with interFoam, and the result appeared free surface.
Thank for your help and Thank you very much !


MOHAMMAD67 September 7, 2011 13:29

Dear kwardle, Hi
thanks for your help in advance. I really learn a lot from your posts.
I want to know how I can simulate free surface flow in circular pipe. What changes I should implement in setFieldDict to achieve this? Is there any files I should change( e.g. inlet in boundary field)?

nimasam September 8, 2011 03:49


Originally Posted by MOHAMMAD67 (Post 323316)
Dear kwardle, Hi
thanks for your help in advance. I really learn a lot from your posts.
I want to know how I can simulate free surface flow in circular pipe. What changes I should implement in setFieldDict to achieve this? Is there any files I should change( e.g. inlet in boundary field)?

set field only support a few distribution for geometry for example box or sphere or ... ! i suggest you using funkySetFields which can be found in openFOAM wiki

MOHAMMAD67 September 8, 2011 07:31

free surface flow in pipe
Hi nima
Before involving in the funkySetfField I want to know how I can model free surface flow? I successfully solved the problem in this discussion. but I couldn't make free surface flow for this specific problem. what should I do in this smple 2D problem?

nimasam September 8, 2011 15:04

whats ur mean how?
for simulation of free surface flow, if you use interFoam, actually u are going to simulate a two phase flow and track interface between them. interFoam uses VOF method, in this method a scalar function (alpha) defines each phase! dam break case is discussed above can be found in tutorials, what else do u like to know?

MOHAMMAD67 September 8, 2011 15:46

free surface flow boundary condition
Dear nima
I didn't state my question clearly. I mean how i can change the inlet boundary condition to have free surface flow in pipe. It's better to see this picture. I intend to model it.

nimasam September 8, 2011 16:28

1) set up ur simulation geometry ( pipe and internal barrier)

2) for inlet :
U : fixedValue
P : zeroGradient
alpha: fixedValue 0.5 or nonuniform with groovyBC
for wall :
U : fixedValue uniform (0 0 0)
P : zeroGradient or bouyant pressure
alpha : zeroGradient
for Outlet:
U : zero Gradient or outletInlet
P : fixedValue
alpha : zeroGradient

3) you can initialize field in time zero with funkySetFields

MOHAMMAD67 September 12, 2011 01:34

Outlet Pressure?
2 Attachment(s)
Dear Nima, Hi
I've done what you said for the case discussed in this thread ( two phase flow with the geometery of Pitzdaily problem). Fortunately It worked but I think pressure outlet for my case is not fixed value. The pressure above the surface in the whole system is atmospheric pressure. Viewing the results near the outlet confirms this claim.
So what should I do? Should I implemet hydrostatic pressure? How?

Attachment 9150

Attachment 9151

nimasam September 12, 2011 09:56

use bouyantPressure in out let!
i guess it will consider the variation of pressure due to gravity direction! but im not sure
if it does not work you can implement it easily with groovyBC.

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