Hi PETSc team:

I am trying to create a SIMPLE type approximation for the Schur complement.
It is a nonlinear code, so I have to update the Schur matrix once the
tangent jacobian is updated. I am trying to figure out the best way of
doing that.

In terms of generating an algebraic form of Schur S, I am trying to do the
following.

// S = A10 x A01, I have performed a diagonal scaling on all matrices, so
the diag(A00) = I.
MatMatMult(A10, A01, MAT_INITIAL_MATRIX, S);
MatScale(S, -1.0); // S = -1 x S
MatAXPY(S, 1.0, A11, S, DIFFERENT_NONZERO_PATTERN); // S = A11 + S

My questions are:
(1) When I update the Schur complement, do I need to call
MatDestroy(&S);
MatMatMult(A10, A01, MAT_INITIAL_MATRIX, S);
or shall I just call
MatMatMult(A10, A01, MAT_REUSE_MATRIX, S);

Basically, I am not sure how to properly use the flag MAT_REUSE_MATRIX.

(2) When I update the Schur complement, the initial call of MatAXPY already
incorporated the contribution of A00 in terms of nonzero patterns. So in my
second call of MatAXPY, shall I use the flag SUBSET_NONZERO_PATTERN?

Best regards,

John

Reply via email to