Iterative solution of piecewise linear systems and applications to flows in porous media