It should be clear from this example that the Jacobi iteration is a very slow method. Because this iteration converges so slowly, it is necessary to test for convergence less frequently.

It is possible to avoid the step that copies xnew back into xlocal either by using pointer operations (basically swapping xnew and xlocal) or by doing two iterations at a time. This latter approach requires another exchange of ghost points and another relaxation sweep.