[petsc-users] Changing the operator for PCMG while leaving interpolation matrices unchanged
Ben Yee
bcyee at umich.edu
Wed Jan 24 09:12:36 CST 2018
Hi,
I have multiple matrices (with different nonzero structures) for which I
would like to use the same KSP operator (KSPRICHARDSON with PCMG, Galerkin
process for generating coarse grid operator). I want to use the same PCMG
structure for all the matrices (same interpolation, same restriction, same
number of levels, same smoothing techniques, etc.), so I tried using
KSPSetOperators to just change the operator. My interpolation matrices are
MPIAIJ matrices that I have defined myself and provided to PCMG. My hope
was that, with the new operator I provided, PETSc would recompute all of
the coarse/intermediate grid operators using the Galerkin process with the
old interpolation matrices and the new fine-grid operator.
However, I get the wrong solution after changing the operator with
KSPSetOperators. After some extensive digging around the PETSc source
code, it seems that the operators in mg.c are not updated by
KSPSetOperators. When I do a MatView on mglevels->A or the operator in
mglevels->smoothu or mglevels->smoothd in PCMGMCycle_Private() of mg.c, it
has the matrix values of the old matrix. From what I understand, the only
place where mglevels->A (used to compute the residual) is updated is in
PCApplyRIchardson_MG() of mg.c, from the following lines of code:
74: for (i=0; i<levels; i++) { 75: if (!mglevels[i]->A) { 76:
KSPGetOperators
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/KSP/KSPGetOperators.html#KSPGetOperators>(mglevels[i]->smoothu,&mglevels[i]->A,NULL);
77: PetscObjectReference
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectReference.html#PetscObjectReference>((PetscObject
<http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObject.html#PetscObject>)mglevels[i]->A);
78: } 79: }
It seems to me that the pointer mglevels[i]->A is only set once, when it is
undefined at the beginning of the iteration scheme. I think there are more
issues as well, but this is the easiest one to point out. (For example, it
doesn't seem like it is possible to update the operator for
mglevels[i]->smoothd from KSPSetOperators on the outermost KSP object, and,
if I try to set it manually via PCMGGetSmoother, I get errors if the
nonzero structures of the coarse-grid operators have changed, which tends
to be the case when the fine-grid operator's nonzero structure changes).
Is there something I'm doing wrong? Is there a way to do this so that I
can reuse PCMG with a new operator?
Thanks!
--
Ben Yee
NERS PhD Candidate, University of Michigan
B.S. Mech. & Nuclear Eng., U.C. Berkeley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180124/628c4d36/attachment.html>
More information about the petsc-users
mailing list