17 #ifndef dealii_slepc_solver_h
18 # define dealii_slepc_solver_h
22 # ifdef DEAL_II_WITH_SLEPC
28 # include <petscconf.h>
29 # include <petscksp.h>
31 # include <slepceps.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,
484 const EPSLanczosReorthogType r = EPS_LANCZOS_REORTHOG_FULL);
659 template <
typename OutputVector>
664 const unsigned int n_eigenpairs)
667 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <=
A.m()),
674 unsigned int n_converged = 0;
675 solve(n_eigenpairs, &n_converged);
677 if (n_converged > n_eigenpairs)
678 n_converged = n_eigenpairs;
687 for (
unsigned int index = 0; index < n_converged; ++index)
691 template <
typename OutputVector>
697 const unsigned int n_eigenpairs)
704 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <=
A.m()),
711 unsigned int n_converged = 0;
712 solve(n_eigenpairs, &n_converged);
714 if (n_converged >= n_eigenpairs)
715 n_converged = n_eigenpairs;
725 for (
unsigned int index = 0; index < n_converged; ++index)
729 template <
typename OutputVector>
733 std::vector<double> & real_eigenvalues,
734 std::vector<double> & imag_eigenvalues,
735 std::vector<OutputVector> & real_eigenvectors,
736 std::vector<OutputVector> & imag_eigenvectors,
737 const unsigned int n_eigenpairs)
744 AssertThrow(real_eigenvalues.size() == imag_eigenvalues.size(),
746 imag_eigenvalues.size()));
747 AssertThrow(real_eigenvectors.size() == imag_eigenvectors.size(),
749 imag_eigenvectors.size()));
752 AssertThrow((n_eigenpairs > 0) && (n_eigenpairs <=
A.m()),
759 unsigned int n_converged = 0;
760 solve(n_eigenpairs, &n_converged);
762 if (n_converged >= n_eigenpairs)
763 n_converged = n_eigenpairs;
769 (imag_eigenvectors.size() != 0),
772 real_eigenvectors.resize(n_converged, real_eigenvectors.front());
773 imag_eigenvectors.resize(n_converged, imag_eigenvectors.front());
774 real_eigenvalues.resize(n_converged);
775 imag_eigenvalues.resize(n_converged);
777 for (
unsigned int index = 0; index < n_converged; ++index)
779 real_eigenvalues[index],
780 imag_eigenvalues[index],
781 real_eigenvectors[index],
782 imag_eigenvectors[index]);
785 template <
typename Vector>
789 std::vector<Vec> vecs(this_initial_space.size());
791 for (
unsigned int i = 0; i < this_initial_space.size(); i++)
794 ExcMessage(
"Initial vectors should be nonzero."));
795 vecs[i] = this_initial_space[i];
804 const PetscErrorCode ierr =
805 EPSSetInitialSpace(
eps, vecs.size(), vecs.data());
813 # endif // DEAL_II_WITH_SLEPC