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);
702 template <
typename OutputVector>
707 const unsigned int n_eigenpairs)
710 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
717 unsigned int n_converged = 0;
718 solve(n_eigenpairs, &n_converged);
720 if (n_converged > n_eigenpairs)
721 n_converged = n_eigenpairs;
730 for (
unsigned int index = 0; index < n_converged; ++index)
734 template <
typename OutputVector>
740 const unsigned int n_eigenpairs)
747 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
754 unsigned int n_converged = 0;
755 solve(n_eigenpairs, &n_converged);
757 if (n_converged >= n_eigenpairs)
758 n_converged = n_eigenpairs;
768 for (
unsigned int index = 0; index < n_converged; ++index)
772 template <
typename OutputVector>
776 std::vector<double> & real_eigenvalues,
777 std::vector<double> & imag_eigenvalues,
778 std::vector<OutputVector> & real_eigenvectors,
779 std::vector<OutputVector> & imag_eigenvectors,
780 const unsigned int n_eigenpairs)
787 AssertThrow(real_eigenvalues.size() == imag_eigenvalues.size(),
789 imag_eigenvalues.size()));
790 AssertThrow(real_eigenvectors.size() == imag_eigenvectors.size(),
792 imag_eigenvectors.size()));
795 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <= A.
m()),
802 unsigned int n_converged = 0;
803 solve(n_eigenpairs, &n_converged);
805 if (n_converged >= n_eigenpairs)
806 n_converged = n_eigenpairs;
812 (imag_eigenvectors.size() != 0),
815 real_eigenvectors.resize(n_converged, real_eigenvectors.front());
816 imag_eigenvectors.resize(n_converged, imag_eigenvectors.front());
817 real_eigenvalues.resize(n_converged);
818 imag_eigenvalues.resize(n_converged);
820 for (
unsigned int index = 0; index < n_converged; ++index)
822 real_eigenvalues[index],
823 imag_eigenvalues[index],
824 real_eigenvectors[index],
825 imag_eigenvectors[index]);
828 template <
typename Vector>
832 std::vector<Vec> vecs(this_initial_space.size());
834 for (
unsigned int i = 0; i < this_initial_space.size(); ++i)
836 Assert(this_initial_space[i].l2_norm() > 0.0,
837 ExcMessage(
"Initial vectors should be nonzero."));
838 vecs[i] = this_initial_space[i];
847 const PetscErrorCode ierr =
848 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)