An algorithm based on incompatible modes for the global tracking of strong discontinuities in shear localization analyses