Formation of layered structures in double-diffusive convection as applied to the geosciences