* SLEPc solvers before calling <code>solve()</code>. For example, if
* the matrices of the general eigenspectrum problem are not hermitian
* and the lower eigenvalues are wanted only, the following code can
- * be implemented:
+ * be implemented before calling <code>solve()</code>:
* @code
* system.set_problem_type (EPS_NHEP);
* system.set_which_eigenpairs (EPS_SMALLEST_REAL);
* @note Various tweaks and enhancments contributed by Eloy Romero and
* Jose E. Roman 2009, 2010.
*/
-
namespace SLEPcWrappers
{
* Set up matrices for solving; Actually solve the system; Gather
* the solution(s); and reset.
*
- * Note that the number of converged eigenvectors can be larger
- * than the number of eigenvectors requested; this is due to a
- * round off error (success) of the eigenproblem solver
+ * @note Note that the number of converged eigenvectors can be
+ * larger than the number of eigenvectors requested; this is due
+ * to a round off error (success) of the eigenproblem solver
* context. If this is found to be the case we simply do not
* bother with more eigenpairs than requested, but handle that it
* may be more than specified by ignoring any extras. By default
std::vector<OutputVector> &vr,
const unsigned int n_eigenvectors = 1);
- /**
- * Initialize solver for the linear system $Ax=\lambda x$. (Note:
- * this is required before calling solve ())
- */
- void
- set_matrices (const PETScWrappers::MatrixBase &A);
-
- /**
- * Same as above, but here initialize solver for the linear system
- * $A x=\lambda B x$.
- */
- void
- set_matrices (const PETScWrappers::MatrixBase &A,
- const PETScWrappers::MatrixBase &B);
-
/**
* Set the initial vector for the solver.
*/
void
set_transformation (SLEPcWrappers::TransformationBase &this_transformation);
+ /**
+ * Set target eigenvalues in the spectrum to be computed. By
+ * default, no target is set.
+ */
+ void
+ set_target_eigenvalue (const double &this_target);
+
/**
* Indicate which part of the spectrum is to be computed. By
* default largest magnitude eigenvalues are computed.
void
set_problem_type (EPSProblemType set_problem);
- /**
- * Solve the linear system for n_eigenvectors
- * eigenstates. Parameter <code>n_converged</code> contains the
- * actual number of eigenstates that have . converged; this can
- * be both fewer or more than n_eigenvectors, depending on the
- * SLEPc eigensolver used.
- */
- void
- solve (const unsigned int n_eigenvectors, unsigned int *n_converged);
-
- /**
- * Access the solutions for a solved eigenvector problem, pair
- * index solutions, $\text{index}\,\in\,0\hdots
- * \text{n\_converged}-1$.
- */
- void
- get_eigenpair (const unsigned int index,
-#ifndef PETSC_USE_COMPLEX
- double &kr,
-#else
- std::complex<double> &kr,
-#endif
- PETScWrappers::VectorBase &vr);
-
- /**
- * Reset the solver, and return memory for eigenvectors
- */
- void
- reset ();
-
- /**
- * Retrieve the SLEPc solver object that is internally used.
- */
- EPS *get_eps ();
-
/**
* Take the information provided from SLEPc and checks it against
* deal.II's own SolverControl objects to see if convergence has
* been reached.
*/
- void get_solver_state (const SolverControl::State state);
-
- /**
- * Access to the object that controls convergence.
- */
- SolverControl &control () const;
+ void
+ get_solver_state (const SolverControl::State state);
/**
* Exception. Standard exception.
<< " The number of converged eigenvectors is " << arg1
<< " but " << arg2 << " were requested. ");
+ /**
+ * Access to the object that controls convergence.
+ */
+ SolverControl &control () const;
+
protected:
/**
*/
virtual void set_solver_type (EPS &eps) const = 0;
+ /**
+ * Reset the solver, and return memory for eigenvectors
+ */
+ void
+ reset ();
+
+ /**
+ * Retrieve the SLEPc solver object that is internally used.
+ */
+ EPS *get_eps ();
+
+ /**
+ * Solve the linear system for n_eigenvectors
+ * eigenstates. Parameter <code>n_converged</code> contains the
+ * actual number of eigenstates that have . converged; this can
+ * be both fewer or more than n_eigenvectors, depending on the
+ * SLEPc eigensolver used.
+ */
+ void
+ solve (const unsigned int n_eigenvectors, unsigned int *n_converged);
+
+ /**
+ * Access the solutions for a solved eigenvector problem, pair
+ * index solutions, $\text{index}\,\in\,0\hdots
+ * \text{n\_converged}-1$.
+ */
+ void
+ get_eigenpair (const unsigned int index,
+#ifndef PETSC_USE_COMPLEX
+ double &kr,
+#else
+ std::complex<double> &kr,
+#endif
+ PETScWrappers::VectorBase &vr);
+
+ /**
+ * Initialize solver for the linear system $Ax=\lambda x$. (Note:
+ * this is required before calling solve ())
+ */
+ void
+ set_matrices (const PETScWrappers::MatrixBase &A);
+
+ /**
+ * Same as above, but here initialize solver for the linear system
+ * $A x=\lambda B x$.
+ */
+ void
+ set_matrices (const PETScWrappers::MatrixBase &A,
+ const PETScWrappers::MatrixBase &B);
+
+ /**
+ * Target eigenvalue to solve for.
+ */
+ PetscScalar target_eigenvalue;
+
/**
* Which portion of the spectrum to solve from.
*/
*/
EPSProblemType set_problem;
+ private:
+
/**
* The matrix $A$ of the generalized eigenvalue problem
* $Ax=B\lambda x$, or the standard eigenvalue problem $Ax=\lambda
*/
SLEPcWrappers::TransformationBase *transformation;
- private:
-
/**
* A function that can be used in SLEPc as a callback to check on
* convergence.
unsigned int n_converged = 0;
// Set the matrices of the problem
- set_matrices (A);
+ set_matrices (A);
// and solve
solve (n_eigenvectors, &n_converged);
template <typename OutputVector>
void
- SolverBase::solve (const PETScWrappers::MatrixBase &A,
- const PETScWrappers::MatrixBase &B,
- std::vector<double> &kr,
- std::vector<OutputVector> &vr,
- const unsigned int n_eigenvectors)
+ SolverBase::solve (const PETScWrappers::MatrixBase &A,
+ const PETScWrappers::MatrixBase &B,
+ std::vector<double> &kr,
+ std::vector<OutputVector> &vr,
+ const unsigned int n_eigenvectors)
{
// Panic if no eigenpairs are wanted.
AssertThrow (n_eigenvectors != 0, ExcSLEPcWrappersUsageError());