Gravitational-wave background as an initiator of longitudinal structure formation in a confined relativistic gas