Hi Firedrakers, I have two functions, v(x,y) and h(x,y). I find a quantity u(x,y)=v(x,y)/h(x,y) to solve a PDE. Now, I'm struggling with using u(x,y) when h(x,y) is equal to 0 at some cells. I get DIVERGED_NAN errors as I'm trying to divide by 0. Now what I have done is to build a kernel that allows me to set the cells that will be dividing by 0, to 0, and otherwise proceed as normal on the cells that won't be dividing by 0. This arises since v is momentum and h is depth, and thus u is velocity. With 0 depth, I would like 0 velocity. However, sometimes I divide by a restriction to a function and thus can't use a kernel. I was wondering if there was a clean way (potentially UFL way) to set cells of functions from NANS to 0, or anything similar that would help me? Many Thanks, Alastair Gregory ------------------------------------------------------------------------------------------ Research Assistant (Maths Foresees Feasibility Study) Imperial College London Room 759 Huxley Building, South Kensington (Tel: 07794 243913) | (Email: a.gregory14@imperial.ac.uk) -------------------------------------------------------------------------------------------