Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
Ifpack2::Details::LinearSolver< SC, LO, GO, NT > Class Template Reference

Ifpack2's implementation of Trilinos::Details::LinearSolver interface. More...

#include <Ifpack2_Details_LinearSolver_decl.hpp>

Inheritance diagram for Ifpack2::Details::LinearSolver< SC, LO, GO, NT >:
Inheritance graph
[legend]

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 > &params)
 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...
 

Detailed Description

template<class SC, class LO, class GO, class NT>
class Ifpack2::Details::LinearSolver< SC, LO, GO, NT >

Ifpack2's implementation of Trilinos::Details::LinearSolver interface.

Template Parameters
SCScalar type; 1st template parameter of Tpetra::Operator
LOLocal ordinal type; 2nd template parameter of Tpetra::Operator
GOGlobal ordinal type; 3rd template parameter of Tpetra::Operator
NTNode 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.

Constructor & Destructor Documentation

template<class SC , class LO , class GO , class NT >
Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::LinearSolver ( const Teuchos::RCP< prec_type > &  solver,
const std::string &  solverName 
)

Constructor.

Parameters
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.
template<class SC , class LO , class GO , class NT >
virtual Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::~LinearSolver ( )
inlinevirtual

Member Function Documentation

template<class SC , class LO , class GO , class NT >
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::setMatrix ( const Teuchos::RCP< const OP > &  A)

Set the solver's matrix.

Parameters
A[in] Pointer to the matrix A in the linear system(s) AX=B to solve.
template<class SC , class LO , class GO , class NT >
Teuchos::RCP< const typename LinearSolver< SC, LO, GO, NT >::OP > Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::getMatrix ( ) const
virtual
template<class SC , class LO , class GO , class NT >
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::solve ( MV &  X,
const MV &  B 
)

Solve the linear system AX=B for X.

template<class SC , class LO , class GO , class NT >
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::setParameters ( const Teuchos::RCP< Teuchos::ParameterList > &  params)
virtual
template<class SC , class LO , class GO , class NT >
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::symbolic ( )
virtual
template<class SC , class LO , class GO , class NT >
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::numeric ( )
virtual
template<class SC , class LO , class GO , class NT >
std::string Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::description ( ) const
virtual

Implementation of Teuchos::Describable::description.

Reimplemented from Teuchos::Describable.

template<class SC , class LO , class GO , class NT >
void Ifpack2::Details::LinearSolver< SC, LO, GO, NT >::describe ( Teuchos::FancyOStream out,
const Teuchos::EVerbosityLevel  verbLevel = Teuchos::Describable::verbLevel_default 
) const
virtual

Implementation of Teuchos::Describable::describe.

Reimplemented from Teuchos::Describable.


The documentation for this class was generated from the following files: