Loading...
Searching...
No Matches
EigenKrylovSolver.h
// Copyright (C) 2015 Chris Richardson
//
// 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/>.
//
// First added: 2005-02-04
#ifndef __DOLFIN_EIGEN_KRYLOV_SOLVER_H
#define __DOLFIN_EIGEN_KRYLOV_SOLVER_H
#include <map>
#include <memory>
#include <dolfin/common/types.h>
#include "GenericLinearSolver.h"
namespace dolfin
{
class EigenMatrix;
class EigenVector;
class GenericMatrix;
class GenericVector;
class EigenKrylovSolver : public GenericLinearSolver
{
public:
EigenKrylovSolver(std::string method="default",
std::string preconditioner="default");
~EigenKrylovSolver();
void set_operator(std::shared_ptr<const GenericLinearOperator> A);
void set_operator(std::shared_ptr<const EigenMatrix> A);
void set_operators(std::shared_ptr<const GenericLinearOperator> A,
std::shared_ptr<const GenericLinearOperator> P);
void set_operators(std::shared_ptr<const EigenMatrix> A,
std::shared_ptr<const EigenMatrix> P);
std::shared_ptr<const EigenMatrix> get_operator() const;
std::size_t solve(GenericVector& x, const GenericVector& b);
std::size_t solve(EigenVector& x, const EigenVector& b);
std::size_t solve(const GenericLinearOperator& A, GenericVector& x,
const GenericVector& b);
std::size_t solve(const EigenMatrix& A, EigenVector& x,
const EigenVector& b);
std::string str(bool verbose) const;
static std::map<std::string, std::string> methods();
static std::map<std::string, std::string> preconditioners();
static Parameters default_parameters();
std::string parameter_type() const
{ return "krylov_solver"; }
private:
// Initialize solver
void init(const std::string method, const std::string pc="default");
// Call with an actual solver
template <typename Solver>
std::size_t call_solver(Solver& solver, GenericVector& x,
const GenericVector& b);
// Chosen Krylov method
std::string _method;
// Chosen Eigen precondtioner method
std::string _pc;
// Available solvers and preconditioner descriptions
static const std::map<std::string, std::string> _methods_descr;
static const std::map<std::string, std::string> _pcs_descr;
// Operator (the matrix)
std::shared_ptr<const EigenMatrix> _matA;
// Matrix used to construct the preconditioner
std::shared_ptr<const EigenMatrix> _matP;
};
}
#endif
dolfin::EigenKrylovSolver::default_parameters
static Parameters default_parameters()
Default parameter values.
Definition EigenKrylovSolver.cpp:68
dolfin::EigenKrylovSolver::get_operator
std::shared_ptr< const EigenMatrix > get_operator() const
Get operator (matrix).
Definition EigenKrylovSolver.cpp:118
dolfin::EigenKrylovSolver::EigenKrylovSolver
EigenKrylovSolver(std::string method="default", std::string preconditioner="default")
Definition EigenKrylovSolver.cpp:75
dolfin::EigenKrylovSolver::preconditioners
static std::map< std::string, std::string > preconditioners()
Return a list of available preconditioners.
Definition EigenKrylovSolver.cpp:63
dolfin::EigenKrylovSolver::set_operator
void set_operator(std::shared_ptr< const GenericLinearOperator > A)
Set operator (matrix).
Definition EigenKrylovSolver.cpp:91
dolfin::EigenKrylovSolver::solve
std::size_t solve(GenericVector &x, const GenericVector &b)
Solve linear system Ax = b and return number of iterations.
Definition EigenKrylovSolver.cpp:129
dolfin::EigenKrylovSolver::parameter_type
std::string parameter_type() const
Return parameter type: "krylov_solver" or "lu_solver".
Definition EigenKrylovSolver.h:96
dolfin::EigenKrylovSolver::methods
static std::map< std::string, std::string > methods()
Return a list of available solver methods.
Definition EigenKrylovSolver.cpp:58
dolfin::EigenKrylovSolver::~EigenKrylovSolver
~EigenKrylovSolver()
Destructor.
Definition EigenKrylovSolver.cpp:85
dolfin::EigenKrylovSolver::set_operators
void set_operators(std::shared_ptr< const GenericLinearOperator > A, std::shared_ptr< const GenericLinearOperator > P)
Set operator (matrix) and preconditioner matrix.
Definition EigenKrylovSolver.cpp:101
dolfin::EigenKrylovSolver::str
std::string str(bool verbose) const
Return informal string representation (pretty-print).
Definition EigenKrylovSolver.cpp:291
dolfin::EigenMatrix
Definition EigenMatrix.h:47
dolfin::EigenVector
Definition EigenVector.h:46
dolfin::GenericLinearOperator
Definition GenericLinearOperator.h:43
dolfin::GenericLinearSolver
This class provides a general solver for linear systems Ax = b.
Definition GenericLinearSolver.h:38
dolfin::GenericMatrix
This class defines a common interface for matrices.
Definition GenericMatrix.h:47
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::Parameters
Definition Parameters.h:95
dolfin
Definition adapt.h:30
dolfin::init
void init(int argc, char *argv[])
Definition init.cpp:27