17#ifndef dealii_slepc_solver_h
18# define dealii_slepc_solver_h
22# ifdef DEAL_II_WITH_SLEPC
28# include <petscconf.h>
178 template <
typename OutputVector>
183 const unsigned int n_eigenpairs = 1);
190 template <
typename OutputVector>
196 const unsigned int n_eigenpairs = 1);
203 template <
typename OutputVector>
207 std::vector<double> & real_eigenvalues,
208 std::vector<double> & imag_eigenvalues,
209 std::vector<OutputVector> & real_eigenvectors,
210 std::vector<OutputVector> & imag_eigenvectors,
211 const unsigned int n_eigenpairs = 1);
219 template <
typename Vector>
274 <<
" An error with error number " << arg1
275 <<
" occurred while calling a SLEPc function");
283 <<
" The number of converged eigenvectors is " << arg1
284 <<
" but " << arg2 <<
" were requested. ");
311 solve(
const unsigned int n_eigenpairs,
unsigned int *n_converged);
330 double & real_eigenvalues,
331 double & imag_eigenvalues,
371 PetscScalar real_eigenvalue,
372 PetscScalar imag_eigenvalue,
373 PetscReal residual_norm,
374 PetscReal * estimated_error,
502 const EPSLanczosReorthogType r = EPS_LANCZOS_REORTHOG_FULL);
701 template <
typename OutputVector>
706 const unsigned int n_eigenpairs)
709 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
716 unsigned int n_converged = 0;
717 solve(n_eigenpairs, &n_converged);
719 if (n_converged > n_eigenpairs)
720 n_converged = n_eigenpairs;
729 for (
unsigned int index = 0; index < n_converged; ++index)
733 template <
typename OutputVector>
739 const unsigned int n_eigenpairs)
746 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
753 unsigned int n_converged = 0;
754 solve(n_eigenpairs, &n_converged);
756 if (n_converged >= n_eigenpairs)
757 n_converged = n_eigenpairs;
767 for (
unsigned int index = 0; index < n_converged; ++index)
771 template <
typename OutputVector>
775 std::vector<double> & real_eigenvalues,
776 std::vector<double> & imag_eigenvalues,
777 std::vector<OutputVector> & real_eigenvectors,
778 std::vector<OutputVector> & imag_eigenvectors,
779 const unsigned int n_eigenpairs)
786 AssertThrow(real_eigenvalues.size() == imag_eigenvalues.size(),
788 imag_eigenvalues.size()));
789 AssertThrow(real_eigenvectors.size() == imag_eigenvectors.size(),
791 imag_eigenvectors.size()));
794 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
801 unsigned int n_converged = 0;
802 solve(n_eigenpairs, &n_converged);
804 if (n_converged >= n_eigenpairs)
805 n_converged = n_eigenpairs;
811 (imag_eigenvectors.size() != 0),
814 real_eigenvectors.resize(n_converged, real_eigenvectors.front());
815 imag_eigenvectors.resize(n_converged, imag_eigenvectors.front());
816 real_eigenvalues.resize(n_converged);
817 imag_eigenvalues.resize(n_converged);
819 for (
unsigned int index = 0; index < n_converged; ++index)
821 real_eigenvalues[index],
822 imag_eigenvalues[index],
823 real_eigenvectors[index],
824 imag_eigenvectors[index]);
827 template <
typename Vector>
831 std::vector<Vec> vecs(this_initial_space.size());
833 for (
unsigned int i = 0; i < this_initial_space.size(); ++i)
835 Assert(this_initial_space[i].l2_norm() > 0.0,
836 ExcMessage(
"Initial vectors should be nonzero."));
837 vecs[i] = this_initial_space[i];
846 const PetscErrorCode ierr =
847 EPSSetInitialSpace(
eps, vecs.size(), vecs.data());
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)
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 solve(const PETScWrappers::MatrixBase &A, std::vector< PetscScalar > &eigenvalues, std::vector< OutputVector > &eigenvectors, const unsigned int n_eigenpairs=1)
void get_eigenpair(const unsigned int index, PetscScalar &eigenvalues, PETScWrappers::VectorBase &eigenvectors)
void set_transformation(SLEPcWrappers::TransformationBase &this_transformation)
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
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
const AdditionalData additional_data
#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
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)