User subroutine UEL of ABAQUS was used in secondary developments for an elastoplastic Drucker-Prager model based on the Cosserat continuum theory.A uniaxial compression was performed,and the result showed that this model can ensure well-posedness in strain localization.Strength reserve coefficient method was adopted to simulate the strain localization for the foundation of gravity dam.Comparison between the result of the cosserat continuum theory and classical continuum theory showed that the cosserat continuum theory is not sensitive to the mesh intensity,and strength reserve coefficient to FEM iteration unconverged has a substantial increase.