As the first part of the question is a duplicate of:
I’ll just supply you with a reference on how to compute the midpoint of all cells local to a process: