A unified variational framework for the space discontinuous Galerkin method for elastic wave propagation in anisotropic and piecewise homogeneous media