16#ifndef dealii_slepc_solver_h
17# define dealii_slepc_solver_h
21# ifdef DEAL_II_WITH_SLEPC
27# include <petscconf.h>
177 template <
typename OutputVector>
182 const unsigned int n_eigenpairs = 1);
189 template <
typename OutputVector>
195 const unsigned int n_eigenpairs = 1);
202 template <
typename OutputVector>
206 std::vector<double> &real_eigenvalues,
207 std::vector<double> &imag_eigenvalues,
208 std::vector<OutputVector> &real_eigenvectors,
209 std::vector<OutputVector> &imag_eigenvectors,
210 const unsigned int n_eigenpairs = 1);
218 template <
typename Vector>
273 <<
" An error with error number " << arg1
274 <<
" occurred while calling a SLEPc function");
282 <<
" The number of converged eigenvectors is " << arg1
283 <<
" but " << arg2 <<
" were requested. ");
310 solve(
const unsigned int n_eigenpairs,
unsigned int *n_converged);
329 double &real_eigenvalues,
330 double &imag_eigenvalues,
370 PetscScalar real_eigenvalue,
371 PetscScalar imag_eigenvalue,
372 PetscReal residual_norm,
373 PetscReal *estimated_error,
502 const EPSLanczosReorthogType r = EPS_LANCZOS_REORTHOG_FULL);
703 template <
typename OutputVector>
708 const unsigned int n_eigenpairs)
711 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
718 unsigned int n_converged = 0;
719 solve(n_eigenpairs, &n_converged);
721 if (n_converged > n_eigenpairs)
722 n_converged = n_eigenpairs;
731 for (
unsigned int index = 0; index < n_converged; ++index)
735 template <
typename OutputVector>
741 const unsigned int n_eigenpairs)
748 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
755 unsigned int n_converged = 0;
756 solve(n_eigenpairs, &n_converged);
758 if (n_converged >= n_eigenpairs)
759 n_converged = n_eigenpairs;
769 for (
unsigned int index = 0; index < n_converged; ++index)
773 template <
typename OutputVector>
777 std::vector<double> &real_eigenvalues,
778 std::vector<double> &imag_eigenvalues,
779 std::vector<OutputVector> &real_eigenvectors,
780 std::vector<OutputVector> &imag_eigenvectors,
781 const unsigned int n_eigenpairs)
788 AssertThrow(real_eigenvalues.size() == imag_eigenvalues.size(),
790 imag_eigenvalues.size()));
791 AssertThrow(real_eigenvectors.size() == imag_eigenvectors.size(),
793 imag_eigenvectors.size()));
796 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
803 unsigned int n_converged = 0;
804 solve(n_eigenpairs, &n_converged);
806 if (n_converged >= n_eigenpairs)
807 n_converged = n_eigenpairs;
813 (imag_eigenvectors.size() != 0),
816 real_eigenvectors.resize(n_converged, real_eigenvectors.front());
817 imag_eigenvectors.resize(n_converged, imag_eigenvectors.front());
818 real_eigenvalues.resize(n_converged);
819 imag_eigenvalues.resize(n_converged);
821 for (
unsigned int index = 0; index < n_converged; ++index)
823 real_eigenvalues[index],
824 imag_eigenvalues[index],
825 real_eigenvectors[index],
826 imag_eigenvectors[index]);
829 template <
typename VectorType>
832 const std::vector<VectorType> &this_initial_space)
834 std::vector<Vec> vecs(this_initial_space.size());
836 for (
unsigned int i = 0; i < this_initial_space.size(); ++i)
838 Assert(this_initial_space[i].l2_norm() > 0.0,
839 ExcMessage(
"Initial vectors should be nonzero."));
840 vecs[i] = this_initial_space[i];
849 const PetscErrorCode ierr =
850 EPSSetInitialSpace(
eps, vecs.size(), vecs.data());
SolverArnoldi(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
SolverControl & control() const
EPSConvergedReason reason
void set_target_eigenvalue(const PetscScalar &this_target)
const MPI_Comm mpi_communicator
void set_matrices(const PETScWrappers::MatrixBase &A)
SolverBase(SolverControl &cn, const MPI_Comm mpi_communicator)
void get_solver_state(const SolverControl::State state)
void set_initial_space(const std::vector< Vector > &initial_space)
void set_problem_type(EPSProblemType set_problem)
SolverControl & solver_control
void get_eigenpair(const unsigned int index, PetscScalar &eigenvalues, PETScWrappers::VectorBase &eigenvectors)
void set_transformation(SLEPcWrappers::TransformationBase &this_transformation)
void solve(const PETScWrappers::MatrixBase &A, std::vector< PetscScalar > &eigenvalues, std::vector< OutputVector > &eigenvectors, const unsigned int n_eigenpairs=1)
static int convergence_test(EPS eps, PetscScalar real_eigenvalue, PetscScalar imag_eigenvalue, PetscReal residual_norm, PetscReal *estimated_error, void *solver_control)
void set_which_eigenpairs(EPSWhich set_which)
const AdditionalData additional_data
SolverGeneralizedDavidson(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
SolverJacobiDavidson(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
const AdditionalData additional_data
SolverKrylovSchur(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
SolverLAPACK(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
const AdditionalData additional_data
SolverLanczos(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
SolverPower(SolverControl &cn, const MPI_Comm mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DeclException0(Exception0)
static ::ExceptionBase & ExcSLEPcEigenvectorConvergenceMismatchError(int arg1, int arg2)
static ::ExceptionBase & ExcSLEPcError(int arg1)
#define Assert(cond, exc)
#define DeclException2(Exception2, type1, type2, outsequence)
static ::ExceptionBase & ExcDimensionMismatch(std::size_t arg1, std::size_t arg2)
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & ExcSLEPcWrappersUsageError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
bool delayed_reorthogonalization
AdditionalData(const bool delayed_reorthogonalization=false)
AdditionalData(bool double_expansion=false)
AdditionalData(const EPSLanczosReorthogType r=EPS_LANCZOS_REORTHOG_FULL)
EPSLanczosReorthogType reorthog
std::array< Number, 1 > eigenvalues(const SymmetricTensor< 2, 1, Number > &T)
std::array< std::pair< Number, Tensor< 1, dim, Number > >, std::integral_constant< int, dim >::value > eigenvectors(const SymmetricTensor< 2, dim, Number > &T, const SymmetricTensorEigenvectorMethod method=SymmetricTensorEigenvectorMethod::ql_implicit_shifts)