Finite element simulation of nonlinear fluids with application to granular material and powder