Numerical simulation of foam flow in porous media