firedrakeproject / asQ

A library for implementing ParaDIAG timestepping algorithms using Firedrake
MIT License
4 stars 1 forks source link

Update state of aaofunc._vec when underlying data is changed #157

Closed JHopeCollins closed 9 months ago

JHopeCollins commented 9 months ago

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.