Skip to content
Snippets Groups Projects
Commit 34dc470d authored by Axel Modave's avatar Axel Modave
Browse files

eigenSolver: add options in argument

parent 17b10e3d
Branches
Tags
No related merge requests found
......@@ -34,7 +34,7 @@ eigenSolver::eigenSolver(dofManager<double> *manager, std::string A,
eigenSolver::eigenSolver(linearSystemPETSc<double> *A,linearSystemPETSc<double> *B, bool hermitian) : _A(A), _B(B), _hermitian(hermitian){}
bool eigenSolver::solve(int numEigenValues, std::string which)
bool eigenSolver::solve(int numEigenValues, std::string which, std::string method, double tolVal, int iterMax)
{
if(!_A) return false;
Mat A = _A->getMatrix();
......@@ -63,11 +63,17 @@ bool eigenSolver::solve(int numEigenValues, std::string which)
// set some default options
_try(EPSSetDimensions(eps, numEigenValues, PETSC_DECIDE, PETSC_DECIDE));
_try(EPSSetTolerances(eps, 1.e-7, 20));//1.e-7 20
_try(EPSSetType(eps, EPSKRYLOVSCHUR)); //default
//_try(EPSSetType(eps, EPSARNOLDI));
//_try(EPSSetType(eps, EPSARPACK));
//_try(EPSSetType(eps, EPSPOWER));
_try(EPSSetTolerances(eps, tolVal, iterMax));
if (method=="krylovschur")
_try(EPSSetType(eps, EPSKRYLOVSCHUR));
else if (method=="arnoldi")
_try(EPSSetType(eps, EPSARNOLDI));
else if (method=="arpack")
_try(EPSSetType(eps, EPSARPACK));
else if (method=="power")
_try(EPSSetType(eps, EPSPOWER));
else
Msg::Fatal("eigenSolver: method '%s' not available", method.c_str());
// override these options at runtime, petsc-style
_try(EPSSetFromOptions(eps));
......
......@@ -28,7 +28,8 @@ class eigenSolver{
std::string B="", bool hermitian=true);
eigenSolver(linearSystemPETSc<double> *A, linearSystemPETSc<double>* B = NULL,
bool hermitian=true);
bool solve(int numEigenValues=0, std::string which="");
bool solve(int numEigenValues=0, std::string which="", std::string method="krylovschur",
double tolVal=1.e-7, int iterMax=20);
int getNumEigenValues(){ return _eigenValues.size(); }
std::complex<double> getEigenValue(int num){ return _eigenValues[num]; }
std::vector<std::complex<double> > &getEigenVector(int num){ return _eigenVectors[num]; }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment