Linear system solver using GMRES. More...
#include <ptems/solvers/gmres.hpp>
Public Types | |
typedef remove_complex_t< T > | real_type |
The real valued type the solver is for (either T, or R for T=std:complex<R>) More... | |
typedef T | value_type |
Defines the type of a matrix entry in the linear system. More... | |
typedef Ref | reference |
Defines the type of a reference to a matrix entry in the linear system. More... | |
typedef ConstRef | const_reference |
Defines the type of a const reference to a matrix entry in the linear system. More... | |
typedef std::optional< typename detail::ReferenceWrapper< reference >::type > | optional_reference |
Defines the type of a reference to a matrix entry in the linear system. More... | |
typedef std::optional< typename detail::ReferenceWrapper< const_reference >::type > | optional_const_reference |
Defines the type of a const reference to a matrix entry in the linear system. More... | |
Public Member Functions | |
GMRESSolver (const ParallelComm &comm, const SparsityPattern &mat, std::size_t size, real_type tolerance, std::size_t maxItns, bool updateInitialGuess=false) | |
Constructs a GMRES solver, without preconditioner, for a sparse matrix. More... | |
GMRESSolver (const ParallelComm &comm, const SparsityPattern &mat, std::size_t size, const PPreconditioner< T > &preconditioner, real_type tolerance, std::size_t maxItns, bool updateInitialGuess=false) | |
Constructs a GMRES solver for a sparse matrix. More... | |
const T & | InitialGuess (std::size_t i) const |
Returns a const reference to the specified entry of the initial guess. More... | |
T & | InitialGuess (std::size_t i) |
Returns a mutable reference to the specified entry of the initial guess. More... | |
void | FillInitialGuess (T value) |
Fills the initial guess vector with a constant. More... | |
template<typename It > | |
void | FillInitialGuess (It begin, It end) |
Fills the initial guess vector with the values from the specified iterator range. More... | |
virtual bool | DistributedConstruction () const override |
Gets if the matrix and right hand side should be constructed distributed (for MPI) More... | |
virtual LinearSolver< T >::optional_reference | Entry (std::size_t i, std::size_t j) override |
Gets a reference to the specified matrix entry. More... | |
virtual LinearSolver< T >::optional_const_reference | Entry (std::size_t i, std::size_t j) const override |
Gets a const reference to the specified matrix entry. More... | |
virtual void | Clear () override |
Clear the matrix of the linear system. More... | |
std::size_t | size () const override |
Gets the size of the linear system. More... | |
virtual std::vector< T > | Solve (const std::vector< T > &rhs, std::size_t offsetRHS=0, std::size_t lenRHS=-1) override |
Solves the linear system with the specified right-hand side. More... | |
virtual reference | operator() (std::size_t i, std::size_t j) |
Gets a reference to the specified matrix entry. More... | |
virtual const_reference | operator() (std::size_t i, std::size_t j) const |
Gets a const reference to the specified matrix entry. More... | |
virtual std::vector< T > | operator() (const std::vector< T > &rhs, std::size_t offsetRHS=0, std::size_t lenRHS=-1) |
Solves the linear system with the specified right-hand side. More... | |
Linear system solver using GMRES.
T | The type of the matrix entries |
|
inherited |
Defines the type of a const reference to a matrix entry in the linear system.
Can be a proxy object in some cases.
|
inherited |
Defines the type of a const reference to a matrix entry in the linear system.
Can be a proxy object in some cases.
|
inherited |
Defines the type of a reference to a matrix entry in the linear system.
Can be a proxy object in some cases.
typedef remove_complex_t<T> ptems::GMRESSolver< T >::real_type |
The real valued type the solver is for (either T, or R for T=std:complex<R>)
|
inherited |
Defines the type of a reference to a matrix entry in the linear system.
Can be a proxy object in some cases.
|
inherited |
Defines the type of a matrix entry in the linear system.
|
inline |
Constructs a GMRES solver, without preconditioner, for a sparse matrix.
comm | MPI communicator to use for construction and solving |
mat | The sparsity pattern of the sparse matrix |
size | The size of the linear system |
tolerance | The desired tolerance for the GMRES iteration |
maxItns | The maximum number of GMRES iterations to perform |
updateInitialGuess | Specifies whether the initial guess should be updated with the solution of Solve. This is useful, for example, with nonlinear solvers as the initial guess for a linear solver at a nonlibnear iteration step will be the solution from the previous iteration of the nonlinear solver. |
|
inline |
Constructs a GMRES solver for a sparse matrix.
comm | MPI communicator to use for construction and solving |
mat | The sparsity pattern of the sparse matrix |
size | The size of the linear system |
preconditioner | The preconditioner to use at each step of the GMRES iteration. Can be null to use without preconditioner |
tolerance | The desired tolerance for the GMRES iteration |
maxItns | The maximum number of GMRES iterations to perform |
updateInitialGuess | Specifies whether the initial guess should be updated with the solution of Solve. This is useful, for example, with nonlinear solvers as the initial guess for a linear solver at a nonlibnear iteration step will be the solution from the previous iteration of the nonlinear solver. |
|
inlineoverridevirtual |
Clear the matrix of the linear system.
Implements ptems::LinearSolver< T, Ref, ConstRef >.
|
inlineoverridevirtual |
Gets if the matrix and right hand side should be constructed distributed (for MPI)
Implements ptems::LinearSolver< T, Ref, ConstRef >.
|
inlineoverridevirtual |
Gets a const reference to the specified matrix entry.
std::out_of_range | If the row or column index are not less than the linear system size |
i | The row index |
j | The column index |
Implements ptems::LinearSolver< T, Ref, ConstRef >.
|
inlineoverridevirtual |
Gets a reference to the specified matrix entry.
std::out_of_range | If the row or column index are not less than the linear system size |
i | The row index |
j | The column index |
Implements ptems::LinearSolver< T, Ref, ConstRef >.
|
inline |
Fills the initial guess vector with the values from the specified iterator range.
std::invalid_argument | If the size of the specified range is different to the size of the initial guess vector. If this exception is thrown some values WILL have been copied to the initial guess vector. |
It | Type of the iterators over the range |
begin | The begin iterator of the range |
end | The first-past-the-end iterator of the range |
|
inline |
Fills the initial guess vector with a constant.
value | Value to fill initial guess vector with |
|
inline |
Returns a mutable reference to the specified entry of the initial guess.
Can be used to populate the initial guess
std::out_of_range | If i is not in the range [0, size()) |
i | Index of entry in initial guess |
|
inline |
Returns a const reference to the specified entry of the initial guess.
Can be used to populate the initial guess
std::out_of_range | If i is not in the range [0, size()) |
i | Index of entry in initial guess |
|
inlinevirtualinherited |
Solves the linear system with the specified right-hand side.
rhs | The right hand side vector |
offsetRHS | If using distributed matrix/rhs construction specifies the offset to the start of the right hand side vector populated by this process |
lenRHS | If using distributed matrix/rhs construction specifies the length of the right hand side vector populated by this process (or greater than size() for all) |
|
inlinevirtualinherited |
Gets a reference to the specified matrix entry.
std::out_of_range | If the row or column index are not less than the linear system size |
std::invalid_argument | If the entry is not a non-zero entry of the sparse matrix |
i | The row index |
j | The column index |
|
inlinevirtualinherited |
Gets a const reference to the specified matrix entry.
std::out_of_range | If the row or column index are not less than the linear system size |
std::invalid_argument | If the entry is not a non-zero entry of the sparse matrix |
i | The row index |
j | The column index |
|
inlineoverridevirtual |
Gets the size of the linear system.
Implements ptems::LinearSolver< T, Ref, ConstRef >.
|
inlineoverridevirtual |
Solves the linear system with the specified right-hand side.
rhs | The right hand side vector |
offsetRHS | If using distributed matrix/rhs construction specifies the offset to the start of the right hand side vector populated by this process |
lenRHS | If using distributed matrix/rhs construction specifies the length of the right hand side vector populated by this process (or greater than size() for all) |
Implements ptems::LinearSolver< T, Ref, ConstRef >.