[petsc-users] [petsc-maint] Create SIMPLE pc for Schur explicitly

Smith, Barry F. bsmith at mcs.anl.gov
Tue Mar 6 16:13:47 CST 2018



> On Mar 6, 2018, at 4:09 PM, John <johnlucassaturday at gmail.com> wrote:
> 
> 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);

   The second form. No reason to delete the matrix and rebuild it each time (delete and rebuild will be a bit slower)

> 
> 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?

   If it is a subset then you should use the subset flag, if they have same nonzero pattern you should use SAME_NONZERO_PATTERN (same nonzero is fastest)

   Barry

> 
> Best regards,
> 
> John



More information about the petsc-users mailing list