PETScVector ghost values not up-to-date when needed

Issue #425 new
Jan Blechta created an issue

Plot from MWE #258 shows that ghost values are not correct. To obtain expected behaviour one can put as_backend_type(u.vector()).update_ghost_values() or u.vector().apply('insert') to the code.

This is basically a follow-up of #263 which was not resolved robustly. It was originally agreed to "update lately when needed; introduce dirty flag". Garth finally implemented updating early after solve or some PETScVector operations (apply, *=, +=, axpy, ...) without dirty flag.

In a case that we do not regard this as a bug, then as_backend_type(u.vector()).update_ghost_values() line must be added to demo_petsc4py.py and moreover user/developer will be everytime responsible to do update whenever needed.

The advantage of late update (when dirty) is that probably only assembler, (maybe also DirichletBC), plotting and IO will do the updates in the library so the vector will be most of the time in arbitrary but known state. Potentially this leaves less space for bugs.

Comments (8)

  1. Jan Blechta reporter

    I don't think there's an easy fix. This requires that we revisit the discussion how to handle up-to-dateness of ghost values and agree on some consensus. Also new aspects of the problem may appear with the introduction of TPetra backend.

    I will kick off discussion on mailing list after release.

  2. Prof Garth Wells

    We can use a PETSc flag. We really shouldn't write our own flag since the vector can be modified by PETSc.

    It's still not perfect because a vector change might not touch ghost values.

  3. Log in to comment