[petsc-users] KSP changes for successive solver
Mark Adams
mfadams at lbl.gov
Sun Jul 19 09:42:25 CDT 2015
On Thu, Jul 16, 2015 at 5:53 PM, Michele Rosso <mrosso at uci.edu> wrote:
> Hi,
>
> I am performing a series of solves inside a loop. The matrix for each
> solve changes but not enough to justify a rebuilt of the PC at each solve.
> Therefore I am using KSPSetReusePreconditioner to avoid rebuilding unless
> necessary. The solver is CG + MG with a custom PC at the coarse level.
>
Ah, OK this is the problem. The code I just sent gets fooled but your
custom PC, probably.
We should just remove this paternal code:
PetscBool preonly,lu,redundant,cholesky,svd
...
/*
If coarse solver is not direct method then DO NOT USE preonly
*/
ierr =
PetscObjectTypeCompare((PetscObject)mglevels[0]->smoothd,KSPPREONLY,&preonly);CHKERRQ(ierr);
if (preonly) {
ierr =
PetscObjectTypeCompare((PetscObject)cpc,PCBJACOBI,&bjaclu);CHKERRQ(ierr);
if (bjaclu) {
KSP *k2;
PetscInt ii,first;
ierr = PCBJacobiGetSubKSP(cpc,&ii,&first,&k2);CHKERRQ(ierr);
if (ii==1) {
PC pc2;
ierr = KSPGetPC(k2[0],&pc2);CHKERRQ(ierr);
ierr =
PetscObjectTypeCompare((PetscObject)pc2,PCLU,&bjaclu);CHKERRQ(ierr);
}
else bjaclu = PETSC_FALSE;
}
ierr = PetscObjectTypeCompare((PetscObject)cpc,PCLU,&lu);CHKERRQ(ierr);
ierr =
PetscObjectTypeCompare((PetscObject)cpc,PCREDUNDANT,&redundant);CHKERRQ(ierr);
ierr =
PetscObjectTypeCompare((PetscObject)cpc,PCCHOLESKY,&cholesky);CHKERRQ(ierr);
ierr =
PetscObjectTypeCompare((PetscObject)cpc,PCSVD,&svd);CHKERRQ(ierr);
if (!lu && !redundant && !cholesky && !svd && !bjaclu) {
ierr = KSPSetType(mglevels[0]->smoothd,KSPGMRES);CHKERRQ(ierr);
}
}
> If KSP is not updated each time, everything works as it is supposed to.
> When instead I allow the default PETSc behavior, i.e. updating PC every
> time the matrix changes, the coarse level KSP , initially set to PREONLY,
> is changed into GMRES
> after the first solve. I am not sure where the problem lies (my PC or
> PETSc), so I would like to have your opinion on this.
> I attached the ksp_view for the 2 successive solve and the options stack.
>
> Thanks for your help,
> Michel
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150719/632fcc6d/attachment.html>
More information about the petsc-users
mailing list