Extension of the numerical method for melting and freezing problems