[petsc-users] PCFactorSetUpMatSolverPackage with SNES

Matthew Knepley knepley at gmail.com
Tue Mar 1 12:56:33 CST 2016


On Tue, 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);
> PC snes_pc;
> KSPGetPC(snes_ksp, &snes_pc);
> PCFactorSetMatSolverPackage(snes_pc, MATSOLVERMUMPS);
> PCFactorSetUpMatSolverPackage(snes_pc);
>
> 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.
>

That is a good reason. However, I would organize this differently. I would
still set the type from the command line.
Then later in your code, after SNES is setup correctly, you get out the PC
and reset the icntl values if you have a
failure. Its very difficult to get the setup logic correct, and its one of
the most error prone parts of PETSc. RIght now,
the most reliable way to do things is to have all the information available
up front in options.

Someday, I want to write a small DFA piece in PETSc that can encode all
this logic so that simple errors people
make can be diagnosed early with nice error messages.

  Thanks,

     Matt


> Thanks,
> David
>
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160301/d373f89e/attachment.html>


More information about the petsc-users mailing list