[petsc-users] PCFactorSetUpMatSolverPackage with SNES

David Knezevic david.knezevic at akselos.com
Tue Mar 1 18:43:19 CST 2016


Hi Barry,

    I have added an error checker so the code will produce a useful error
> message instead of just crashing here in the code.
>

This sounds helpful. I assume this is in the dev branch? I'm using 3.6.1,
but I gather from this list that 3.7 will be out soon, so I'll switch to
that once it's available.



>     You can only call this routine AFTER the matrix has been provided to
> the KSP object. Normally with SNES this won't happen until after the solve
> has started (hence is not easy for you to put in your parameters) but
> adding the code I suggest below might work
>


OK, makes sense. Unfortunately the change below didn't help, I still get
the same segfault. But it's not a big deal, since I went with Matt's
suggestion which seems to be working well.

Thanks,
David




> > On Mar 1, 2016, at 12:52 PM, David Knezevic <david.knezevic at akselos.com>
> wrote:
> >
> > Based on KSP ex52, I use PCFactorSetUpMatSolverPackage in the process of
> setting various MUMPS ictnl options. This works fine for me when I'm
> solving linear problems.
> >
> > I then wanted to use PCFactorSetUpMatSolverPackage with the PC from a
> SNES object. I tried to do this with the following code (after calling
> SNESCreate, SNESSetFunction, and SNESSetJacobian):
> >
> > KSP snes_ksp;
> > SNESGetKSP(snes, &snes_ksp);
> KSPSetOperators(ksp,mat,pmat);
>      /* mat and pmat (which may be the same) are the Jacobian arguments to
> SNESSetJacobian(), the matrices must exist and types set but they don't
> have to have the correct Jacobian entries at this point (since the
> nonlinear solver has not started you cannot know the Jacobian entries yet.)
> > PC snes_pc;
> > KSPGetPC(snes_ksp, &snes_pc);
> PCSetType(snes_pc,PCLU);
> > PCFactorSetMatSolverPackage(snes_pc, MATSOLVERMUMPS);
> > PCFactorSetUpMatSolverPackage(snes_pc);
>
> Let me know if this does not work and where it goes wrong.
> >
> > However, I get a segfault on the call to PCFactorSetUpMatSolverPackage
> in this case. I was wondering what I need to do to make this work?
> >
> > Note that I want to set the MUMPS ictnl parameters via code rather than
> via the commandline since sometimes MUMPS fails (e.g. with error -9 due to
> a workspace size that is too small) and I need to automatically re-run the
> solve with different ictnl values when this happens.
> >
> > Thanks,
> > David
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160301/a73f7a55/attachment-0001.html>


More information about the petsc-users mailing list