[petsc-users] Shell matrix and MatMultAdd.

Vijay S. Mahadevan vijay.m at gmail.com
Thu Dec 2 14:45:25 CST 2010


Hi all,

There is probably some minor inconsistency in my understanding but is
there a fundamental difference between the following two options ?

// Option 1
ierr = MatMult(A, solution, temporaryvec) ;CHKERRQ(ierr);
ierr = VecAXPY(rhs, 1.0, temporaryvec) ;CHKERRQ(ierr);
// Option 2
ierr = MatMultAdd(A, solution, rhs, rhs) ;CHKERRQ(ierr);

Here A is a shell matrix (serial) that has a routine defined to
perform MATOP_MULT only.

I ask because Option 1 gives me the right result while Option 2
segfaults at the MatMultAdd line. My only logical conclusion is that I
need to define a MATOP_MULT_ADD or something similar for the shell for
this to work. Is this understanding correct ? I implicitly assumed
that petsc recognizes that MATOP_MULT has been defined already and
since MatMultAdd only requires the action of a matrix on a vector to
perform its operation, should this not be computed by petsc
automatically ? I really do not want to creat an extra vector here
with Option 1 since this occurs at a finer level in my calculation.
But is there any way that you would suggest I do this without extra
allocations ? Any comments or pointers will be much appreciated.

Vijay


More information about the petsc-users mailing list