The contact dynamics method for granular media