Hey guys I found a lot of tutorials on 2D height field/swe water simulation but I have yet to find one that takes into account of ground height, i.e.


The overall water simulation results is fantastic however it does not takes into account of ground height and it doesnt work when the height of water is 0.

Would appreciate help on how to implement that as I've been stuck for several weeks on how to implement it. Thanks!


1 Answer 1


In a nutshell, what makes a shallow water equation a shallow water equation is that the water height is not zero and it assumes no variation in the seafloor.

Note: No fluid dynamics equation will allow for a water depth of 0, as that would mean you have no fluid.

You should read the Wikipedia article on the shallow water equation. Basically, in shallow water, the vertical velocity is ignored because the value is so small and has minor impact to the wave propagation.

To quote the section in case of modification of the source page:

The equations are derived from depth-integrating the Navier–Stokes equations, in the case where the horizontal length scale is much greater than the vertical length scale. Under this condition, conservation of mass implies that the vertical velocity of the fluid is small. It can be shown from the momentum equation that vertical pressure gradients are nearly hydrostatic, and that horizontal pressure gradients are due to the displacement of the pressure surface, implying that the horizontal velocity field is constant throughout the depth of the fluid. Vertically integrating allows the vertical velocity to be removed from the equations. The shallow water equations are thus derived.

While a vertical velocity term is not present in the shallow water equations, note that this velocity is not necessarily zero. This is an important distinction because, for example, the vertical velocity cannot be zero when the floor changes depth, and thus if it were zero only flat floors would be usable with the shallow water equations. Once a solution (i.e. the horizontal velocities and free surface displacement) has been found, the vertical velocity can be recovered via the continuity equation.

TL;DR: In order to do what you want to do, you should be using the Boussinesq Approximation, which does not assume a flat seafloor surface.

This is a very interesting question by the way, I don't see many people try proper water simulation often.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .