Foam dynamics in the presence of oil during multiphase flow in porous rock