A model for grain flow and debris flow