# Extrapolating to non-fluid cells (for Shallow Water Equations), for a shore/beach?

The water height $h$ and 2d velocity field $(u,w)$ are "extrapolated to non-fluid-cells, i.e., setting $h$ equal to the value in the nearest fluid cell." [Bridson]

I'm using finite differences.

Looking at the course notes, this extrapolation seems involved: tracking the zero level set surface $\phi$ (using signed distance from the surface), then taking its gradient $\nabla \phi$. It seems to be done for all non-fluid cells, not just those adjacent to fluid.

I don't understand why this done (BTW for the 2d SWE case, if the non-fluid cell is lower e.g. the lip of a dam wall, then extrapolating the water height will make large quantities of water appear from nowhere (because the height is so far above the ground).

Is there a simple explanation, and a simpler way to do this?

EDIT Two different quantities are being extrapolated, velocity and height. The velocity extrapolation seems to be needed for semi-Lagranian advection. This is where you advect a quantity $q$ by projecting velocities backwards over a timestep, to find what value of $q$ was at that location (interpolating between the grid locations where $q$ is stored). The issue is that this back-projection can land in a region where there is no $q$... so, you extrapolate the value from the nearest cell that does have $q$ (BTW which is along the normal to the surface).

EDIT The other extrapolation, of height $h$, seems to only be used for pressure acceleration. (Its effect seems to be a Neumann BC, zero derivative normal to surface, by making the other side the same as this one...?) Height $h$ is derived from depth $d$ and bottom $b$, $h=b+d$, and $h$ isn't stored, and doesn't seem to be used again. Although, logically, when $d$ is advected semi-Lagrangianly, it should need extrapolation, the same for any other $q$...

Any good references or articles with a nice precis/lit review, or survey papers?

[Bridson] I'm implementing the SWE from chapter 12 of Bridson's book Fluid Simulation for Computer Animation.

• Shallow water equations are no longer hyperbolic when $h$=0. Therefore boundary value problem becomes ill-posed. One has to do some trickery to avoid that. Check out the survey in the beginning of section 3.3 of this paper by Dutykh et al. Aug 10 '17 at 14:33