14#ifndef IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
15#define IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
18#include "Tpetra_MultiVector.hpp"
31template<
class SC,
class LO,
class GO,
class NT>
38 using Teuchos::rcp_dynamic_cast;
39 const char prefix[] =
"Ifpack2::Details::LinearSolver: ";
41 prefix <<
"Input solver is NULL.");
43 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
44 typedef ::Ifpack2::Details::CanChangeMatrix<row_matrix_type>
mixin_type;
48 "solver does not implement the setMatrix() feature. Only Ifpack2 solvers "
49 "that inherit from Ifpack2::Details::CanChangeMatrix implement this feature.");
52template<
class SC,
class LO,
class GO,
class NT>
55setMatrix (
const Teuchos::RCP<const OP>& A)
58 using Teuchos::rcp_dynamic_cast;
59 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
60 typedef ::Ifpack2::Details::CanChangeMatrix<row_matrix_type>
mixin_type;
61 const char prefix[] =
"Ifpack2::Details::LinearSolver::setMatrix: ";
72 (
A_row.is_null (), std::invalid_argument,
prefix <<
"The input matrix A, "
73 "if not null, must be a Tpetra::RowMatrix.");
76 (solver_.is_null (), std::logic_error,
prefix <<
"Solver is NULL. "
77 "This should never happen! Please report this bug to the Ifpack2 "
83 "implement the setMatrix() feature. Only input preconditioners that "
84 "inherit from Ifpack2::Details::CanChangeMatrix implement this. We should"
85 " never get here! Please report this bug to the Ifpack2 developers.");
91template<
class SC,
class LO,
class GO,
class NT>
92Teuchos::RCP<const typename LinearSolver<SC, LO, GO, NT>::OP>
98template<
class SC,
class LO,
class GO,
class NT>
101solve (MV& X,
const MV& B)
103 const char prefix[] =
"Ifpack2::Details::LinearSolver::solve: ";
105 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
106 "This should never happen. Please report this bug to the Ifpack2 "
109 (A_.is_null (), std::runtime_error,
prefix <<
"The matrix has not been "
110 "set yet. You must call setMatrix() with a nonnull matrix before you "
111 "may call this method.");
112 solver_->apply (B, X);
115template<
class SC,
class LO,
class GO,
class NT>
120 solver_->setParameters (*
params);
123template<
class SC,
class LO,
class GO,
class NT>
128 const char prefix[] =
"Ifpack2::Details::LinearSolver::symbolic: ";
130 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
131 "This should never happen. Please report this bug to the Ifpack2 "
134 (A_.is_null (), std::runtime_error,
prefix <<
"The matrix has not been "
135 "set yet. You must call setMatrix() with a nonnull matrix before you "
136 "may call this method.");
137 solver_->initialize ();
140template<
class SC,
class LO,
class GO,
class NT>
145 const char prefix[] =
"Ifpack2::Details::LinearSolver::numeric: ";
147 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
148 "This should never happen. Please report this bug to the Ifpack2 "
151 (A_.is_null (), std::runtime_error,
prefix <<
"The matrix has not been "
152 "set yet. You must call setMatrix() with a nonnull matrix before you "
153 "may call this method.");
157template<
class SC,
class LO,
class GO,
class NT>
162 const char prefix[] =
"Ifpack2::Details::LinearSolver::description: ";
164 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
165 "This should never happen. Please report this bug to the Ifpack2 "
167 return solver_->description ();
170template<
class SC,
class LO,
class GO,
class NT>
174 const Teuchos::EVerbosityLevel
verbLevel)
const
176 const char prefix[] =
"Ifpack2::Details::LinearSolver::describe: ";
178 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
179 "This should never happen. Please report this bug to the Ifpack2 "
190#define IFPACK2_DETAILS_LINEARSOLVER_INSTANT(SC, LO, GO, NT) \
191 template class Ifpack2::Details::LinearSolver<SC, LO, GO, NT>;
Declaration of interface for preconditioners that can change their matrix after construction.
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition Ifpack2_Details_LinearSolver_decl.hpp:77
void numeric()
Precompute for matrix values' changes.
Definition Ifpack2_Details_LinearSolver_def.hpp:143
void symbolic()
Precompute for matrix structure changes.
Definition Ifpack2_Details_LinearSolver_def.hpp:126
void solve(MV &X, const MV &B)
Solve the linear system AX=B for X.
Definition Ifpack2_Details_LinearSolver_def.hpp:101
void setMatrix(const Teuchos::RCP< const OP > &A)
Set the solver's matrix.
Definition Ifpack2_Details_LinearSolver_def.hpp:55
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set the solver's parameters.
Definition Ifpack2_Details_LinearSolver_def.hpp:118
std::string description() const
Implementation of Teuchos::Describable::description.
Definition Ifpack2_Details_LinearSolver_def.hpp:160
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Implementation of Teuchos::Describable::describe.
Definition Ifpack2_Details_LinearSolver_def.hpp:173
Teuchos::RCP< const OP > getMatrix() const
Get the solver's matrix.
Definition Ifpack2_Details_LinearSolver_def.hpp:94
LinearSolver(const Teuchos::RCP< prec_type > &solver, const std::string &solverName)
Constructor.
Definition Ifpack2_Details_LinearSolver_def.hpp:33
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41