PETSc keeps track of the "state" of Vecs i.e. how often the Vec has been modified, so it can stash calculations (e.g. norms) and reuse them if the data hasn't changed.
The all-at-once Vec in the AllAtOnceFunction just "views" the storage buffer in the Vec in aaofunc.function, the firedrake.Function for the all-at-once mixed space. The AllAtOnceFunction context managers for aaofunc._vec update the values in the aaofunc._vec by updating the values in the aaofunc.function.dat.vec using the usual Firedrake context managers.
This means that the data of the aaofunc._vec is updated without aaofunc._vec getting called directly, so the state isn't increased. PETSc then incorrectly thinks that it can reuse previously calculated values.
This PR just increments the state manually when the data in the aaofunc._vec is updated.
PETSc keeps track of the "state" of
Vecs
i.e. how often theVec
has been modified, so it can stash calculations (e.g. norms) and reuse them if the data hasn't changed.The all-at-once
Vec
in theAllAtOnceFunction
just "views" the storage buffer in theVec
inaaofunc.function
, thefiredrake.Function
for the all-at-once mixed space. TheAllAtOnceFunction
context managers foraaofunc._vec
update the values in theaaofunc._vec
by updating the values in theaaofunc.function.dat.vec
using the usual Firedrake context managers. This means that the data of theaaofunc._vec
is updated withoutaaofunc._vec
getting called directly, so the state isn't increased. PETSc then incorrectly thinks that it can reuse previously calculated values.This PR just increments the state manually when the data in the
aaofunc._vec
is updated.