This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Update ghost values

0 votes

I had some trouble with parallel calculations using the PETSc interface in the following way:

A = PETScMatrix()
b = PETScVector()
assemble(a, tensor=A)
assemble(L, tensor=b)
ksp = PETSC.KSP().create()
# some PETSc KSP setup...
ksp.setOperators(A)

# the solution function
w = Function(W)
ksp.solve(b.vec(), as_backend_type(w.vector().vec())

because I forgot to call update_ghost_values() after the solve. In that case, the 'interfaces' of the parallel partition of the problem are zero.
If, instead, I do

(x, _) = A.mat().getVecs()
ksp.solve(b.vec(), x)
w.vector()[:] = x

calling update_ghost_values() is apparently not necessary.

So my simple question is: When do I have to call update_ghost_values()?

asked Mar 31, 2017 by dajuno FEniCS User (4,140 points)
...