48#ifndef IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
49#define IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
52#include "Tpetra_MultiVector.hpp"
65template<
class SC,
class LO,
class GO,
class NT>
72 using Teuchos::rcp_dynamic_cast;
73 const char prefix[] =
"Ifpack2::Details::LinearSolver: ";
75 prefix <<
"Input solver is NULL.");
77 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
78 typedef ::Ifpack2::Details::CanChangeMatrix<row_matrix_type>
mixin_type;
82 "solver does not implement the setMatrix() feature. Only Ifpack2 solvers "
83 "that inherit from Ifpack2::Details::CanChangeMatrix implement this feature.");
86template<
class SC,
class LO,
class GO,
class NT>
89setMatrix (
const Teuchos::RCP<const OP>& A)
92 using Teuchos::rcp_dynamic_cast;
93 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
94 typedef ::Ifpack2::Details::CanChangeMatrix<row_matrix_type>
mixin_type;
95 const char prefix[] =
"Ifpack2::Details::LinearSolver::setMatrix: ";
103 if (! A.is_null ()) {
106 (
A_row.is_null (), std::invalid_argument,
prefix <<
"The input matrix A, "
107 "if not null, must be a Tpetra::RowMatrix.");
110 (solver_.is_null (), std::logic_error,
prefix <<
"Solver is NULL. "
111 "This should never happen! Please report this bug to the Ifpack2 "
117 "implement the setMatrix() feature. Only input preconditioners that "
118 "inherit from Ifpack2::Details::CanChangeMatrix implement this. We should"
119 " never get here! Please report this bug to the Ifpack2 developers.");
125template<
class SC,
class LO,
class GO,
class NT>
126Teuchos::RCP<const typename LinearSolver<SC, LO, GO, NT>::OP>
132template<
class SC,
class LO,
class GO,
class NT>
135solve (MV& X,
const MV& B)
137 const char prefix[] =
"Ifpack2::Details::LinearSolver::solve: ";
139 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
140 "This should never happen. Please report this bug to the Ifpack2 "
143 (A_.is_null (), std::runtime_error,
prefix <<
"The matrix has not been "
144 "set yet. You must call setMatrix() with a nonnull matrix before you "
145 "may call this method.");
146 solver_->apply (B, X);
149template<
class SC,
class LO,
class GO,
class NT>
154 solver_->setParameters (*
params);
157template<
class SC,
class LO,
class GO,
class NT>
162 const char prefix[] =
"Ifpack2::Details::LinearSolver::symbolic: ";
164 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
165 "This should never happen. Please report this bug to the Ifpack2 "
168 (A_.is_null (), std::runtime_error,
prefix <<
"The matrix has not been "
169 "set yet. You must call setMatrix() with a nonnull matrix before you "
170 "may call this method.");
171 solver_->initialize ();
174template<
class SC,
class LO,
class GO,
class NT>
179 const char prefix[] =
"Ifpack2::Details::LinearSolver::numeric: ";
181 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
182 "This should never happen. Please report this bug to the Ifpack2 "
185 (A_.is_null (), std::runtime_error,
prefix <<
"The matrix has not been "
186 "set yet. You must call setMatrix() with a nonnull matrix before you "
187 "may call this method.");
191template<
class SC,
class LO,
class GO,
class NT>
196 const char prefix[] =
"Ifpack2::Details::LinearSolver::description: ";
198 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
199 "This should never happen. Please report this bug to the Ifpack2 "
201 return solver_->description ();
204template<
class SC,
class LO,
class GO,
class NT>
208 const Teuchos::EVerbosityLevel
verbLevel)
const
210 const char prefix[] =
"Ifpack2::Details::LinearSolver::describe: ";
212 (solver_.is_null (), std::logic_error,
prefix <<
"The solver is NULL! "
213 "This should never happen. Please report this bug to the Ifpack2 "
224#define IFPACK2_DETAILS_LINEARSOLVER_INSTANT(SC, LO, GO, NT) \
225 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:110
void numeric()
Precompute for matrix values' changes.
Definition Ifpack2_Details_LinearSolver_def.hpp:177
void symbolic()
Precompute for matrix structure changes.
Definition Ifpack2_Details_LinearSolver_def.hpp:160
void solve(MV &X, const MV &B)
Solve the linear system AX=B for X.
Definition Ifpack2_Details_LinearSolver_def.hpp:135
void setMatrix(const Teuchos::RCP< const OP > &A)
Set the solver's matrix.
Definition Ifpack2_Details_LinearSolver_def.hpp:89
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set the solver's parameters.
Definition Ifpack2_Details_LinearSolver_def.hpp:152
std::string description() const
Implementation of Teuchos::Describable::description.
Definition Ifpack2_Details_LinearSolver_def.hpp:194
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:207
Teuchos::RCP< const OP > getMatrix() const
Get the solver's matrix.
Definition Ifpack2_Details_LinearSolver_def.hpp:128
LinearSolver(const Teuchos::RCP< prec_type > &solver, const std::string &solverName)
Constructor.
Definition Ifpack2_Details_LinearSolver_def.hpp:67
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:73