better (more general) implementation of periodic boundary conditions;

currently work fine for elastic media and serial simulations only,
will add support for acoustic media and for MPI later