Piecewise coefficient function


Is there an easy way to define a piecewise coefficient function? I want to use it in defining mass matrices for my fem scheme:
\int \sigma(x)uv dx
where sigma(x) will be zeros for a range of values in the space im integrating over.


You can use IfPos. For a CoefficientFunction f, IfPos(f, a, b) will be equal to a when f>0 and b otherwise.