Pattern formation in porous media