This uses a PETSc "trick". When a norm is computed on a vector it is "stashed" in the object and retrieved quickly if requested again.
https://petsc.org/main/src/vec/vec/interface/rvector.c.html#VecNorm <https://petsc.org/main/src/vec/vec/interface/rvector.c.html#VecNorm> Because PETSc controls write access to the vector it always knows if the current stashed value is valid or invalid so can avoid unneeded recompilations. When GMRES normalizes the vector, its known norm which is stashed is suitably scaled in the VecScale routine https://petsc.org/main/src/vec/vec/interface/rvector.c.html#VecScale <https://petsc.org/main/src/vec/vec/interface/rvector.c.html#VecScale> and thus available the the MATMFFD_WP at no cost. With right conditioned GMRES or other KSP methods since the norm of a is generally not known the call to VecNorm triggers is computation; but with left preconditioned GMRES is available "for free" in the stash. Barry > On Mar 25, 2022, at 7:07 AM, Pierre Seize <[email protected]> wrote: > > Hello PETSc team and users, > > I have a question regarding MATMFFD_WP : the documentation states that 1) || > U || does not change between linear iterations and 2) in GMRES || a || = 1 > except at restart. > > In src/mat/impls/mffd/wp.c, in MatMFFDCompute_WP, I see that the computation > of || U || is inside an if statement, which I guess corresponds to what is > stated in the documentation, but the computation of || a || is done every > time. > > Does this mean that || a || is computed at each GMRES iteration, even when we > know it's 1 ? > > I was checking this to see how you handle the case of right preconditioning : > then in GMRES it is no longer true than || a || == 1, i think. > > > Thank you in advance for your replies. > > > Pierre Seize >
