From 910e4549f032510d51cb2c7fd8dbe23b5269d3ad Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Wed, 26 Nov 2014 10:05:57 +0100 Subject: [PATCH] made target eigenvalue a shared pointer --- include/deal.II/lac/slepc_solver.h | 2 +- source/lac/slepc_solver.cc | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/deal.II/lac/slepc_solver.h b/include/deal.II/lac/slepc_solver.h index 8510e12504..c84c4cdb53 100644 --- a/include/deal.II/lac/slepc_solver.h +++ b/include/deal.II/lac/slepc_solver.h @@ -341,7 +341,7 @@ namespace SLEPcWrappers /** * Target eigenvalue to solve for. */ - PetscScalar target_eigenvalue; + std_cxx11::shared_ptr target_eigenvalue; /** * Which portion of the spectrum to solve from. diff --git a/source/lac/slepc_solver.cc b/source/lac/slepc_solver.cc index 7db3f88d2e..4539d5a6ad 100644 --- a/source/lac/slepc_solver.cc +++ b/source/lac/slepc_solver.cc @@ -49,7 +49,7 @@ namespace SLEPcWrappers : solver_control (cn), mpi_communicator (mpi_communicator), - target_eigenvalue (0.), + target_eigenvalue (NULL), set_which (EPS_LARGEST_MAGNITUDE), set_problem (EPS_GNHEP), opA (NULL), @@ -93,7 +93,7 @@ namespace SLEPcWrappers void SolverBase::set_target_eigenvalue (const PetscScalar &this_target) { - target_eigenvalue = this_target; + target_eigenvalue.reset (new PetscScalar(this_target)); } void @@ -159,10 +159,16 @@ namespace SLEPcWrappers if (transformation) { // set transformation type if any + // STSetShift is called inside transformation->set_context (solver_data->eps); + } - // set target eigenvalues to solve for - ierr = EPSSetTarget (solver_data->eps, target_eigenvalue); + // set target eigenvalues to solve for + // in all transformation except STSHIFT there is a direct connection between + // the target and the shift, read more on p41 of SLEPc manual. + if (target_eigenvalue.get() != 0) + { + int ierr = EPSSetTarget (solver_data->eps, *(target_eigenvalue.get()) ); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } @@ -181,8 +187,8 @@ namespace SLEPcWrappers // TODO breaks step-36 // force solvers to use true residual - EPSSetTrueResidual(solver_data->eps, PETSC_TRUE); - AssertThrow (ierr == 0, ExcSLEPcError(ierr)); + //EPSSetTrueResidual(solver_data->eps, PETSC_TRUE); + //AssertThrow (ierr == 0, ExcSLEPcError(ierr)); // Set convergence test to be absolute ierr = EPSSetConvergenceTest (solver_data->eps, EPS_CONV_ABS); -- 2.39.5