Numerical investigation of spatial inhomogeneities in gravity and quantum field theory