OpenFoam Example: 3D Dambreak

Openfoam comes with many “cases”, which are running examples of the implimentation of various solvers on various very simple problems.

One of these is the Dambreak case, which was shown in the last example on the website here. OpenFoam is actually always working in 3D, and can only be “fooled” into
working in 2D by making the front and rear faces of the 3D block dissapear. This is done by calling them “empty”.

To change the Dambreak so its really showing the result properly in full 3D, is in theory very simple. Just change the name from empty to wall ! However to actually make it
work…is in fact quite complicated unless you already know how to use Openfoam quite well (which I did not, and doing this was part of the learning process).

So here is alot of information which should make it much easier to understand how the mesh dimentions are defined in OpenFoam and so on. The main mesh is defined in the
blockMeshDict” text file, which contains all the points and blocks as I have plotted below in 3D space – so you can visualise what is going on in the way it organizes
all the points and blocks. Its pretty hard to get it all to work properly unless you know how this works (although naturally its obvious how to make it “thicker” because
only one set of points has a Z depth…so they are obviously the “front face”).

Showing whats doing what in the blockMeshDict
Showing whats doing what in the blockMeshDict

However even understanding this confused me because I couldnt work out how the Alpha1 boundary was working…(which defines the space where the column of fluid starts from).

To edit Alpha1, you need to go to the setFieldsDict file, there are two things in this file that DO NOT work in the same way as they do in the blockMeshDict file (where the boundary mesh
is defined).

1) The units are not requiring to be converted ! So thats why the command “convertToMeters” is missing….that really annoyed me while I was trying to work out the cartesian co-ordinates
for the Alpha1 volume with respect to the main mesh boundaries…

2) The block Alpha1 is defined using a different method than the blocks in the blockMeshDict are defined. In setFieldsDict the Alpha1 block is defined by two points. XYZ min and max. The main blocks for the boudary mesh are created with 8 points (or vertices if you consider that one end of the line is always connected to XYZ=0=).
This is the “boxToCell” command. Annoyingly as standard the Alpha1 block is correct in XY but is just arbitrarily much larger in Z than the actual boundary mesh in blockMeshDict.
It doesnt have to be, as standard its defined as being 2meters deep (starts at -1m z and finishes at +1m z). You can just edit this to a size the same in Z as the main mesh
and it works fine. I eventually made Alpha1 smaller in Z than the main mesh was, so I could get a more interesting flow pattern to show whats happening in 3D.

DamBreakVerticesBlocks

DamBreakVerticesNumbering

DamBreakVerticesNumbering3D

Here is the result you can get, I am still playing with ParaView to learn how to display these results in a nice way.

Which files do I need to edit to make it transition from 2D to 3D problem?

You will need to edit these, named in the OpenFoam file system convention


Dambreak/0/U
(edit “defaultFaces” to match either left,right or lowerWall)

Dambreak/Constant/Polymesh/blockMeshDict
(edit meshsize by changing the correct points in “z” – illustrated at the start)

Dambreak/system/setFieldsDict
(edit the Alpha1 block, it controls the fluid column start area)

However to get a nice result you will also need to edit this – to play with the time steps and so on. However this is not needed to make the problem run in 3D.

Dambreak/system/controlDict

3 thoughts on “OpenFoam Example: 3D Dambreak

  1. Hello
    Thank you for this useful lecture. I am about simulating this case but when I run interFoam, I receive this error: “Cannot find patchField entry for frontWall”.
    What should I do?

    1. Go and check your BlockMeshDict and all files in 0 folder. You`ve probably not named something correctly

  2. Hello,
    Thank you so much for this, saved my life

Leave a Reply

Your email address will not be published. Required fields are marked *