From 0e4ff5ee09729a6bf0aa7c0599e4d80db31388e7 Mon Sep 17 00:00:00 2001 From: "Toby D. Young" Date: Wed, 4 Aug 2010 14:06:34 +0000 Subject: [PATCH] A simple slepc 3.1 compatibility patch to the SLPEcWrappers: Also added working Davidson solver class. git-svn-id: https://svn.dealii.org/trunk@21609 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/slepc_solver.h | 4 +-- deal.II/lac/source/slepc_solver.cc | 29 ++++++++++--------- .../source/slepc_spectral_transformation.cc | 17 +++++++---- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/deal.II/lac/include/lac/slepc_solver.h b/deal.II/lac/include/lac/slepc_solver.h index bdc08e0408..3accb6229a 100644 --- a/deal.II/lac/include/lac/slepc_solver.h +++ b/deal.II/lac/include/lac/slepc_solver.h @@ -206,14 +206,14 @@ namespace SLEPcWrappers */ void set_initial_vector - (const PETScWrappers::VectorBase &set_initial_vector); + (const PETScWrappers::VectorBase &this_initial_vector); /** * Set the spectral transformation * to be used. */ void - set_transformation (SLEPcWrappers::TransformationBase &set_transformation); + set_transformation (SLEPcWrappers::TransformationBase &this_transformation); /** * Indicate which part of the diff --git a/deal.II/lac/source/slepc_solver.cc b/deal.II/lac/source/slepc_solver.cc index f48a0b30cf..4d13adb124 100644 --- a/deal.II/lac/source/slepc_solver.cc +++ b/deal.II/lac/source/slepc_solver.cc @@ -71,15 +71,15 @@ namespace SLEPcWrappers } void - SolverBase::set_initial_vector (const PETScWrappers::VectorBase &set_initial_vector) + SolverBase::set_initial_vector (const PETScWrappers::VectorBase &this_initial_vector) { - initial_vector = (&set_initial_vector); + initial_vector = (&this_initial_vector); } void - SolverBase::set_transformation (SLEPcWrappers::TransformationBase &set_transformation) + SolverBase::set_transformation (SLEPcWrappers::TransformationBase &this_transformation) { - transformation = &set_transformation; + transformation = &this_transformation; } void @@ -175,8 +175,8 @@ namespace SLEPcWrappers AssertThrow (solver_data.get() != 0, ExcSLEPcWrappersUsageError()); // get converged eigenpair - int ierr = EPSGetEigenpair(solver_data->eps, index, - &kr, PETSC_NULL, vr, PETSC_NULL); + int ierr = EPSGetEigenpair (solver_data->eps, index, + &kr, PETSC_NULL, vr, PETSC_NULL); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } @@ -193,8 +193,9 @@ namespace SLEPcWrappers EPS * SolverBase::get_EPS () { - if( solver_data.get() == 0 ) + if (solver_data.get() == 0) return NULL; + return &solver_data->eps; } @@ -321,8 +322,8 @@ namespace SLEPcWrappers // number of iteration steps to // the SLEPc convergence // criterion. - ierr = EPSSetTolerances(eps, this->solver_control.tolerance(), - this->solver_control.max_steps()); + ierr = EPSSetTolerances (eps, this->solver_control.tolerance(), + this->solver_control.max_steps()); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } @@ -348,8 +349,8 @@ namespace SLEPcWrappers // number of iteration steps to // the SLEPc convergence // criterion. - ierr = EPSSetTolerances(eps, this->solver_control.tolerance(), - this->solver_control.max_steps()); + ierr = EPSSetTolerances (eps, this->solver_control.tolerance(), + this->solver_control.max_steps()); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } @@ -368,7 +369,7 @@ namespace SLEPcWrappers SolverDavidson::set_solver_type (EPS &eps) const { int ierr; - ierr = EPSSetType (eps, const_cast(EPSDAVIDSON)); + ierr = EPSSetType (eps, const_cast(EPSGD)); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); // hand over the absolute @@ -376,8 +377,8 @@ namespace SLEPcWrappers // number of iteration steps to // the SLEPc convergence // criterion. - ierr = EPSSetTolerances(eps, this->solver_control.tolerance(), - this->solver_control.max_steps()); + ierr = EPSSetTolerances (eps, this->solver_control.tolerance(), + this->solver_control.max_steps()); AssertThrow (ierr == 0, ExcSLEPcError(ierr)); } #endif diff --git a/deal.II/lac/source/slepc_spectral_transformation.cc b/deal.II/lac/source/slepc_spectral_transformation.cc index 7545234a8a..beb45d6bfd 100644 --- a/deal.II/lac/source/slepc_spectral_transformation.cc +++ b/deal.II/lac/source/slepc_spectral_transformation.cc @@ -32,16 +32,13 @@ DEAL_II_NAMESPACE_OPEN namespace SLEPcWrappers { TransformationBase::TransformationData::~TransformationData () - { - } + {} TransformationBase::TransformationBase () - { - } + {} TransformationBase::~TransformationBase () - { - } + {} void TransformationBase::set_context (EPS &eps) { @@ -56,6 +53,7 @@ namespace SLEPcWrappers } /* ------------------- TransformationShift --------------------- */ + TransformationShift::AdditionalData:: AdditionalData (const double shift_parameter) : @@ -79,6 +77,7 @@ namespace SLEPcWrappers } /* ---------------- TransformationShiftInvert ------------------ */ + TransformationShiftInvert::AdditionalData:: AdditionalData (const double shift_parameter) : @@ -94,7 +93,11 @@ namespace SLEPcWrappers TransformationShiftInvert::set_transformation_type (ST &st) const { int ierr; +#if DEAL_II_PETSC_VERSION_LT(3,1,0) ierr = STSetType (st, const_cast(STSINV)); +#else + ierr = STSetType (st, const_cast(STSINVERT)); +#endif AssertThrow (ierr == 0, SolverBase::ExcSLEPcError(ierr)); ierr = STSetShift (st, additional_data.shift_parameter); @@ -102,6 +105,7 @@ namespace SLEPcWrappers } /* --------------- TransformationSpectrumFolding ----------------- */ + TransformationSpectrumFolding::AdditionalData:: AdditionalData (const double shift_parameter) : @@ -126,6 +130,7 @@ namespace SLEPcWrappers } /* ------------------- TransformationCayley --------------------- */ + TransformationCayley::AdditionalData:: AdditionalData (const double shift_parameter, const double antishift_parameter) -- 2.39.5