Approximate the gradient norm of phi using an upwind scheme. The scheme chosen is appropriate to propagate the level-set equation
d/dt phi + f |grad phi |= 0
in time. If the argument f is given, its sign is used to find the correct upwind direction. If it is not present, positive sign is assumed throughout the domain. h gives the grid spacing to use for the difference approximation.
phi can be an array of arbitrary dimension, and gnorm is always of the same size as phi. If f is given, it must also be of the same size as phi.
The gradient is approximated with finite differences, either the forward or backward difference quotient. The direction chosen at each grid point depends on the sign of f and the gradient of phi at that point. The approximation used is from section 6.4 of
J. A. Sethian: Level Set Methods and Fast Marching Methods, second edition, 1999. Cambridge Monographs on Applied and Computational Mathematics, Cambridge University Press.
See also: ls_time_step.
Package: level-set