Porous-media formulation for multiphase flow with heat transfer