Loading...
Searching...
No Matches
SLEPcEigenSolver.h
// Copyright (C) 2005-2017 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
#ifndef __SLEPC_EIGEN_SOLVER_H
#define __SLEPC_EIGEN_SOLVER_H
#ifdef HAS_SLEPC
#include <memory>
#include <string>
#include <slepceps.h>
#include "dolfin/common/types.h"
#include "dolfin/common/MPI.h"
#include "PETScObject.h"
namespace dolfin
{
class GenericVector;
class PETScMatrix;
class PETScVector;
class VectorSpaceBasis;
class SLEPcEigenSolver : public Variable, public PETScObject
{
public:
explicit SLEPcEigenSolver(MPI_Comm comm);
explicit SLEPcEigenSolver(EPS eps);
explicit SLEPcEigenSolver(std::shared_ptr<const PETScMatrix> A);
SLEPcEigenSolver(MPI_Comm comm, std::shared_ptr<const PETScMatrix> A);
SLEPcEigenSolver(std::shared_ptr<const PETScMatrix> A,
std::shared_ptr<const PETScMatrix> B);
SLEPcEigenSolver(MPI_Comm comm, std::shared_ptr<const PETScMatrix> A,
std::shared_ptr<const PETScMatrix> B);
~SLEPcEigenSolver();
void set_operators(std::shared_ptr<const PETScMatrix> A,
std::shared_ptr<const PETScMatrix> B);
void solve();
void solve(std::size_t n);
void get_eigenvalue(double& lr, double& lc, std::size_t i) const;
void get_eigenpair(double& lr, double& lc,
GenericVector& r, GenericVector& c, std::size_t i) const;
void get_eigenpair(double& lr, double& lc,
PETScVector& r, PETScVector& c, std::size_t i) const;
std::size_t get_iteration_number() const;
std::size_t get_number_converged() const;
void set_deflation_space(const VectorSpaceBasis& deflation_space);
void set_initial_space(const VectorSpaceBasis& initial_space);
void set_options_prefix(std::string options_prefix);
std::string get_options_prefix() const;
void set_from_options() const;
EPS eps() const;
static Parameters default_parameters()
{
Parameters p("slepc_eigenvalue_solver");
p.add<std::string>("problem_type");
p.add<std::string>("spectrum");
p.add<std::string>("solver");
p.add<double>("tolerance");
p.add<int>("maximum_iterations");
p.add<std::string>("spectral_transform");
p.add<double>("spectral_shift");
p.add<bool>("verbose");
return p;
}
private:
void read_parameters();
// Set problem type (used for SLEPc internals)
void set_problem_type(std::string type);
// Set spectral transform
void set_spectral_transform(std::string transform, double shift);
// Set spectrum
void set_spectrum(std::string solver);
// Set solver
void set_solver(std::string spectrum);
// Set tolerance
void set_tolerance(double tolerance, int maxiter);
// SLEPc solver pointer
EPS _eps;
};
}
#endif
#endif
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::PETScMatrix
Definition PETScMatrix.h:59
dolfin::PETScObject::PETScObject
PETScObject()
Constructor. Ensures that PETSc has been initialised.
Definition PETScObject.h:38
dolfin::PETScVector
Definition PETScVector.h:61
dolfin::Parameters
Definition Parameters.h:95
dolfin::Parameters::add
void add(std::string key)
Definition Parameters.h:128
dolfin::SLEPcEigenSolver::get_options_prefix
std::string get_options_prefix() const
Definition SLEPcEigenSolver.cpp:349
dolfin::SLEPcEigenSolver::get_number_converged
std::size_t get_number_converged() const
Get the number of converged eigenvalues.
Definition SLEPcEigenSolver.cpp:295
dolfin::SLEPcEigenSolver::solve
void solve()
Compute all eigenpairs of the matrix A (solve Ax = \lambda x).
Definition SLEPcEigenSolver.cpp:153
dolfin::SLEPcEigenSolver::SLEPcEigenSolver
SLEPcEigenSolver(MPI_Comm comm)
Create eigenvalue solver.
Definition SLEPcEigenSolver.cpp:32
dolfin::SLEPcEigenSolver::set_from_options
void set_from_options() const
Set options from PETSc options database.
Definition SLEPcEigenSolver.cpp:358
dolfin::SLEPcEigenSolver::set_deflation_space
void set_deflation_space(const VectorSpaceBasis &deflation_space)
Definition SLEPcEigenSolver.cpp:303
dolfin::SLEPcEigenSolver::eps
EPS eps() const
Return SLEPc EPS pointer.
Definition SLEPcEigenSolver.cpp:546
dolfin::SLEPcEigenSolver::set_initial_space
void set_initial_space(const VectorSpaceBasis &initial_space)
Definition SLEPcEigenSolver.cpp:322
dolfin::SLEPcEigenSolver::set_options_prefix
void set_options_prefix(std::string options_prefix)
Definition SLEPcEigenSolver.cpp:341
dolfin::SLEPcEigenSolver::set_operators
void set_operators(std::shared_ptr< const PETScMatrix > A, std::shared_ptr< const PETScMatrix > B)
Definition SLEPcEigenSolver.cpp:142
dolfin::SLEPcEigenSolver::~SLEPcEigenSolver
~SLEPcEigenSolver()
Destructor.
Definition SLEPcEigenSolver.cpp:135
dolfin::SLEPcEigenSolver::default_parameters
static Parameters default_parameters()
Default parameter values.
Definition SLEPcEigenSolver.h:196
dolfin::SLEPcEigenSolver::get_eigenpair
void get_eigenpair(double &lr, double &lc, GenericVector &r, GenericVector &c, std::size_t i) const
Get ith eigenpair.
Definition SLEPcEigenSolver.cpp:246
dolfin::SLEPcEigenSolver::get_iteration_number
std::size_t get_iteration_number() const
Get the number of iterations used by the solver.
Definition SLEPcEigenSolver.cpp:538
dolfin::SLEPcEigenSolver::get_eigenvalue
void get_eigenvalue(double &lr, double &lc, std::size_t i) const
Get ith eigenvalue.
Definition SLEPcEigenSolver.cpp:226
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin::VectorSpaceBasis
Definition VectorSpaceBasis.h:34
dolfin
Definition adapt.h:30