I'm looking for a grid-based numerical method that allows simulating water over a grid-based terrain, presumably something like shallow water equations. I have a square grid of terrain elevation values, and I want a numerical method that evolves water level (values of height of water layer on the same grid) in real-time. I don't mind if the method is inaccurate in some respects, but I want it to be mass-conserving and be able to deal with absence of water (i.e. dry land) without any artifacts.

The methods I've found that are closest to what I mean but don't suit all my needs:

  • Stable Fluids by Jos Stam - doesn't seem to incorporate both water height & terrain height, seems to only consider density of some solvent
  • Real-Time Erosion Using Shallow Water Simulation by Bedrich Beneš - the best I've found so far, but it lacks mass conservation, and it is not entirely clear how to restore it in a reasonable way
  • $\begingroup$ Can you add the complete references please? $\endgroup$
    – nicoguaro
    Commented Apr 20, 2020 at 16:33
  • 1
    $\begingroup$ Have you looked at the various variations of the CLAWPACK package? Some of these are for the shallow water equation. $\endgroup$ Commented Apr 20, 2020 at 20:40

1 Answer 1


This is a fairly broad topic. There are a couple of options that come to mind, depending on what your goals and restrictions are. They can be broadly classified into two groups:


  • You can solve the shallow water equations on a grid using a Riemann solver, as mentioned by Prof. Bangerth.
  • You can solve the Navier-Stokes equations with a two-phase method, such as Level-Set (usually not conservative), Volume of fluid, or phase-field methods. This is usually computationally expensive.


  • You can try Smoothed-particle-hydrodynamics. This method is often used for animating fluids and is also included in rendering software such as Blender.

Stable fluids is not a computational method in its own right. Jos Stam just applied the semi-Lagrangian approach to discretizing the convective term of the Navier Stokes equations to computer graphics. This approach was already common in numerical weather prediction before he wrote his paper, but the name "stable fluids" probably stuck in the computer graphics community. Some semi-Lagrangian solvers are mass-conserving.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.