This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Set PETSc Solver Package for SLEPcEigenSolver object in python

+4 votes

I would like to set the Matrix Solver Package to mumps for a SLEPcEigenSolver object, where the spectal transformation is set to "shift and invert". In the PETSc/SLEPc C-API this can be set with the following code

ST myst;
EPSGetST(eps_,&myst);
STSetType(myst,STSINVERT);

KSP myksp;
STGetKSP(myst, &myksp);
KSPSetType(myksp, KSPPREONLY);

PC mypc;
KSPGetPC(myksp,&mypc);
PCSetType(mypc,PCLU);
PCFactorSetMatSolverPackage(mypc,MATSOLVERMUMPS);

How can this be set from python?

asked Dec 4, 2014 by thisch FEniCS Novice (580 points)

1 Answer

+1 vote
 
Best answer

The DOLFIN development version now includes support for slepc4py, so I would suggest using slepc4py to get fine-grained control from Python.

answered Dec 23, 2014 by Garth N. Wells FEniCS Expert (35,930 points)
selected Dec 23, 2014 by thisch

So all i need to do is call the eps method, which returns a slepc4py object.

Yes. I haven't tested - it was implemented by Jan Blechta.

This code works:

eps = eigensolver.eps()
st = eps.getST()
st.setType('sinvert')
ksp = st.getKSP()
ksp.setType('preonly')
pc = ksp.getPC()
pc.setType('lu')
pc.setFactorSolverPackage('mumps')
...