A non-standard new code to solve multiphase viscous thermo–mechanical problems applied to geophysics is presented. Two numerical methodologies employed in the code are described: A level set technique to track the position of the materials and an enrichment of the solution to allow the strain rate to be discontinuous across the interface. These techniques have low computational cost and can be used in standard desktop PCs. Examples of phase tracking with level set are presented in two and three dimensions to study slab detachment in subduction processes and Rayleigh–Taylor instabilities, respectively. The modelling of slab detachment processes includes realistic rheology with viscosity depending on temperature, pressure and strain rate; shear and adiabatic heating mechanisms; density including mineral phase changes and varying thermal conductivity. Detachment models show a first prolonged period of thermal diffusion until a fast necking of the subducting slab results in the break–off. The influence of several numerical and physical parameters on the detachment process is analyzed: The shear heating exerts a major influence accelerating the detachment process, reducing the onset time to one half and lubricating the sinking of the detached slab. The adiabatic heating term acts as a thermal stabilizer. If the mantle temperature follows an adiabatic gradient, neglecting this heating term must be included, otherwise all temperature contrasts are overestimated. As expected, the phase change at 410 km depth (olivine–spinel transition) facilitates the detachment process due to the increase in negative buoyancy. Finally, simple plume simulations are used to show how the presented numerical methodologies can be extended to three dimensions.