Implement grid class for handling phase field and periodic boundary conditions