Ifpack2 Templated Preconditioning Package
Version 1.0
|
Ifpack2's implementation of Trilinos::Details::LinearSolver interface. More...
#include <Ifpack2_Details_LinearSolver_decl.hpp>
Public Member Functions | |
LinearSolver (const Teuchos::RCP< prec_type > &solver, const std::string &solverName) | |
Constructor. More... | |
virtual | ~LinearSolver () |
Destructor (virtual for memory safety). More... | |
void | setMatrix (const Teuchos::RCP< const OP > &A) |
Set the solver's matrix. More... | |
Teuchos::RCP< const OP > | getMatrix () const |
Get the solver's matrix. More... | |
void | solve (MV &X, const MV &B) |
Solve the linear system AX=B for X. More... | |
void | setParameters (const Teuchos::RCP< Teuchos::ParameterList > ¶ms) |
Set the solver's parameters. More... | |
void | symbolic () |
Precompute for matrix structure changes. More... | |
void | numeric () |
Precompute for matrix values' changes. More... | |
std::string | description () const |
Implementation of Teuchos::Describable::description. More... | |
void | describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const |
Implementation of Teuchos::Describable::describe. More... | |
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
SC | Scalar type; 1st template parameter of Tpetra::Operator |
LO | Local ordinal type; 2nd template parameter of Tpetra::Operator |
GO | Global ordinal type; 3rd template parameter of Tpetra::Operator |
NT | Node type; 4th template parameter of Tpetra::Operator |
Note to Ifpack2 developers: The main choice when implementing Trilinos::Details::LinearSolver for a solver package, is whether the LinearSolver or the LinearSolverFactory should know how to create solvers from that package. For Ifpack2, one would think that LinearSolver needs to know how to create solvers. This is because not every Ifpack2::Preconditioner subclass knows how to change its matrix, which is necessary for implementing setMatrix. If solvers don't know how to change their matrix, then the LinearSolver subclass has to destroy and recreate the solver with the new matix.
Ifpack2 has a complication, though: Some Ifpack2 solvers have a choice, either to create an inner solver using Trilinos::Details::LinearSolverFactory, or to use an Ifpack2::Preconditioner provided by the user. AdditiveSchwarz is the prototypical example. For simplicity, we let AdditiveSchwarz wrap the user's Ifpack2::Preconditioner in this LinearSolver class. However, that means that AdditiveSchwarz needs to include Ifpack2_Details_LinearSolver.hpp (since it needs to invoke the constructor). When ETI (explicit template instantiation) is OFF, this means that AdditiveSchwarz pulls in both the declaration and definition of this LinearSolver class. As a result, we cannnot use Ifpack2::Factory in this class, because that would reintroduce one of the circular dependencies that LinearSolverFactory is meant to avoid!
Thankfully, Ifpack2 gives us a way out. AdditiveSchwarz already requires that its inner solver implement Ifpack2::Details::CanChangeMatrix, which has a setMatrix() method. This means we can restrict the set of Ifpack2 solvers that LinearSolver wraps, to those that implement CanChangeMatrix. As a result, we can move use of Ifpack2::Factory to Ifpack2::Details::LinearSolverFactory. This class thus takes an Ifpack2::Preconditioner, and a solver name. If the solver name is "CUSTOM", we assume that the Ifpack2::Preconditioner comes from the user (via e.g., AdditiveSchwarz::setInnerPreconditioner), and that Ifpack2::Factory might not know how to create it.
Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::LinearSolver | ( | const Teuchos::RCP< prec_type > & | solver, |
const std::string & | solverName | ||
) |
Constructor.
solver | [in] The Ifpack2 solver to wrap. It MUST implement Ifpack2::Details::CanChangeMatrix<row_matrix_type>. |
solverName | [in] Name of the solver. If the solver name is "CUSTOM", we assume that the solver comes from the user (via e.g., Ifpack2::AdditiveSchwarz::setInnerPreconditioner), and that Ifpack2::Factory might not know how to create it. Otherwise, the name needs to be that of a solver that Ifpack2::Factory::create knows how to create. |
|
inlinevirtual |
Destructor (virtual for memory safety).
Reimplemented from Trilinos::Details::LinearSolver< Tpetra::MultiVector< SC, LO, GO, NT >, Tpetra::Operator< SC, LO, GO, NT >, Tpetra::MultiVector< SC, LO, GO, NT >::mag_type >.
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::setMatrix | ( | const Teuchos::RCP< const OP > & | A | ) |
Set the solver's matrix.
A | [in] Pointer to the matrix A in the linear system(s) AX=B to solve. |
|
virtual |
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::solve | ( | MV & | X, |
const MV & | B | ||
) |
Solve the linear system AX=B for X.
|
virtual |
Set the solver's parameters.
|
virtual |
Precompute for matrix structure changes.
|
virtual |
Precompute for matrix values' changes.
|
virtual |
Implementation of Teuchos::Describable::description.
Reimplemented from Teuchos::Describable.
|
virtual |
Implementation of Teuchos::Describable::describe.
Reimplemented from Teuchos::Describable.