On Tue, Mar 1, 2016 at 1:56 PM, Matthew Knepley <knep...@gmail.com> wrote:
> On Tue, Mar 1, 2016 at 12:52 PM, David Knezevic < > david.kneze...@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 > OK, thanks for the info, I'll go with that approach. David