48 #ifndef IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
49 #define IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
64 template<
class SC,
class LO,
class GO,
class NT>
68 solverName_ (solverName)
71 using Teuchos::rcp_dynamic_cast;
72 const char prefix[] =
"Ifpack2::Details::LinearSolver: ";
74 prefix <<
"Input solver is NULL.");
76 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
77 typedef ::Ifpack2::Details::CanChangeMatrix<row_matrix_type> mixin_type;
78 RCP<mixin_type> innerSolver = rcp_dynamic_cast<mixin_type> (solver);
80 (innerSolver.is_null (), std::invalid_argument, prefix <<
"The input "
81 "solver does not implement the setMatrix() feature. Only Ifpack2 solvers "
82 "that inherit from Ifpack2::Details::CanChangeMatrix implement this feature.");
85 template<
class SC,
class LO,
class GO,
class NT>
91 using Teuchos::rcp_dynamic_cast;
92 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
93 typedef ::Ifpack2::Details::CanChangeMatrix<row_matrix_type> mixin_type;
94 const char prefix[] =
"Ifpack2::Details::LinearSolver::setMatrix: ";
101 RCP<const row_matrix_type> A_row;
103 A_row = rcp_dynamic_cast<
const row_matrix_type> (A);
105 (A_row.is_null (), std::invalid_argument, prefix <<
"The input matrix A, "
106 "if not null, must be a Tpetra::RowMatrix.");
109 (solver_.is_null (), std::logic_error, prefix <<
"Solver is NULL. "
110 "This should never happen! Please report this bug to the Ifpack2 "
113 RCP<mixin_type> innerSolver = rcp_dynamic_cast<mixin_type> (solver_);
115 (innerSolver.is_null (), std::logic_error, prefix <<
"The solver does not "
116 "implement the setMatrix() feature. Only input preconditioners that "
117 "inherit from Ifpack2::Details::CanChangeMatrix implement this. We should"
118 " never get here! Please report this bug to the Ifpack2 developers.");
119 innerSolver->setMatrix (A_row);
124 template<
class SC,
class LO,
class GO,
class NT>
131 template<
class SC,
class LO,
class GO,
class NT>
136 const char prefix[] =
"Ifpack2::Details::LinearSolver::solve: ";
138 (solver_.is_null (), std::logic_error, prefix <<
"The solver is NULL! "
139 "This should never happen. Please report this bug to the Ifpack2 "
142 (A_.is_null (), std::runtime_error, prefix <<
"The matrix has not been "
143 "set yet. You must call setMatrix() with a nonnull matrix before you "
144 "may call this method.");
145 solver_->apply (B, X);
148 template<
class SC,
class LO,
class GO,
class NT>
153 solver_->setParameters (*params);
156 template<
class SC,
class LO,
class GO,
class NT>
161 const char prefix[] =
"Ifpack2::Details::LinearSolver::symbolic: ";
163 (solver_.is_null (), std::logic_error, prefix <<
"The solver is NULL! "
164 "This should never happen. Please report this bug to the Ifpack2 "
167 (A_.is_null (), std::runtime_error, prefix <<
"The matrix has not been "
168 "set yet. You must call setMatrix() with a nonnull matrix before you "
169 "may call this method.");
170 solver_->initialize ();
173 template<
class SC,
class LO,
class GO,
class NT>
178 const char prefix[] =
"Ifpack2::Details::LinearSolver::numeric: ";
180 (solver_.is_null (), std::logic_error, prefix <<
"The solver is NULL! "
181 "This should never happen. Please report this bug to the Ifpack2 "
184 (A_.is_null (), std::runtime_error, prefix <<
"The matrix has not been "
185 "set yet. You must call setMatrix() with a nonnull matrix before you "
186 "may call this method.");
190 template<
class SC,
class LO,
class GO,
class NT>
195 const char prefix[] =
"Ifpack2::Details::LinearSolver::description: ";
197 (solver_.is_null (), std::logic_error, prefix <<
"The solver is NULL! "
198 "This should never happen. Please report this bug to the Ifpack2 "
200 return solver_->description ();
203 template<
class SC,
class LO,
class GO,
class NT>
209 const char prefix[] =
"Ifpack2::Details::LinearSolver::describe: ";
211 (solver_.is_null (), std::logic_error, prefix <<
"The solver is NULL! "
212 "This should never happen. Please report this bug to the Ifpack2 "
214 solver_->describe (out, verbLevel);
223 #define IFPACK2_DETAILS_LINEARSOLVER_INSTANT(SC, LO, GO, NT) \
224 template class Ifpack2::Details::LinearSolver<SC, LO, GO, NT>;
226 #endif // IFPACK2_DETAILS_LINEARSOLVER_DEF_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
void solve(MV &X, const MV &B)
Solve the linear system AX=B for X.
Definition: Ifpack2_Details_LinearSolver_def.hpp:134
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:206
Teuchos::RCP< const OP > getMatrix() const
Get the solver's matrix.
Definition: Ifpack2_Details_LinearSolver_def.hpp:127
void symbolic()
Precompute for matrix structure changes.
Definition: Ifpack2_Details_LinearSolver_def.hpp:159
void setMatrix(const Teuchos::RCP< const OP > &A)
Set the solver's matrix.
Definition: Ifpack2_Details_LinearSolver_def.hpp:88
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Set the solver's parameters.
Definition: Ifpack2_Details_LinearSolver_def.hpp:151
void numeric()
Precompute for matrix values' changes.
Definition: Ifpack2_Details_LinearSolver_def.hpp:176
Declaration of interface for preconditioners that can change their matrix after construction.
std::string description() const
Implementation of Teuchos::Describable::description.
Definition: Ifpack2_Details_LinearSolver_def.hpp:193
LinearSolver(const Teuchos::RCP< prec_type > &solver, const std::string &solverName)
Constructor.
Definition: Ifpack2_Details_LinearSolver_def.hpp:66