[petsc-users] PCFactorSetUpMatSolverPackage with SNES
Barry Smith
bsmith at mcs.anl.gov
Tue Mar 1 18:14:11 CST 2016
David,
I have added an error checker so the code will produce a useful error message instead of just crashing here in the code.
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
> 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
>
>
More information about the petsc-users
mailing list