Discrete element models for granular materials and rock masses