Add function for calculating grid boundaries.