Ghost cells are regions that fall outside the boundaries represented by the grid. For example, one way to write a central difference formula is:
f ''(x) = (f(x+h) - 2f(x) + f(x-h) ) / (h2)
Assuming a structured, two-dimensional mesh, where I can range from a minimum of 1 to a maximum of Imax, this formula can be written as:
f2d(i) = (f(i+1,j) - 2*f(i,j) + f(i-1,j) )/ deltax*deltax
This formula works well for the interior of the mesh, where I is greater than 2 or less than Imax. However, when I = 1 or Imax, then the formula looks like:
f2d(i) = (f(2,j) - 2*f(2,j) + f(0,j) )/ deltax*deltax when I = 1
f2d(i) = (f(Imax+1,j) - 2*f(Imax,j) + f(Imax-1,j) )/ deltax*deltax when I = Imax
The matrix representing the grid can be larger than the grid itself, ranging from 0 to Imax+1. Those cells for I=0 and I=Imax+1 are called ghost cells.