Cyclic compaction of soils, grains and powders