Thermodynamics of phase equilibrium for systems containing gels