46#include "Teuchos_Assert.hpp"
48#include "ml_include.h"
49#include "ml_MultiLevelPreconditioner.h"
58 if (
precParams->isType<std::string>(
"default values")) {
59 Teuchos::ParameterList ml_defaults;
60 ML_Epetra::SetDefaults(
precParams->get<std::string>(
"default values"),
62 precParams->setParametersNotAlreadySet(ml_defaults);
67Teuchos::RCP<Epetra_Operator>
69compute(
const Teuchos::RCP<Epetra_Operator>& op,
bool compute_prec) {
71 Teuchos::RCP<Epetra_RowMatrix> mat =
72 Teuchos::rcp_dynamic_cast<Epetra_RowMatrix>(op,
true);
73 Teuchos::RCP<ML_Epetra::MultiLevelPreconditioner> ml_prec =
74 Teuchos::rcp(
new ML_Epetra::MultiLevelPreconditioner(*mat, *precParams,
79 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
80 "Stokhos::MLPreconditionerFactory is available " <<
81 "only with configured with ML support!");
88recompute(
const Teuchos::RCP<Epetra_Operator>& op,
89 const Teuchos::RCP<Epetra_Operator>& prec_op) {
92 Teuchos::RCP<Epetra_CrsMatrix> mat =
93 Teuchos::rcp_dynamic_cast<Epetra_CrsMatrix>(op,
true);
94 Teuchos::RCP<ML_Epetra::MultiLevelPreconditioner> ml_prec =
95 Teuchos::rcp_dynamic_cast<ML_Epetra::MultiLevelPreconditioner>(prec_op);
101 non_const_prec_crs_mat = *mat;
104 ml_prec->ComputePreconditioner();
106 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
107 "Stokhos::MLPreconditionerFactory is available " <<
108 "only with configured with ML support!");
MLPreconditionerFactory(const Teuchos::RCP< Teuchos::ParameterList > &p)
Constructor.
Teuchos::RCP< Teuchos::ParameterList > precParams
Preconditioner parameters.
virtual Teuchos::RCP< Epetra_Operator > compute(const Teuchos::RCP< Epetra_Operator > &op, bool compute_prec=true)
Compute preconditioner.
virtual void recompute(const Teuchos::RCP< Epetra_Operator > &op, const Teuchos::RCP< Epetra_Operator > &prec)
Recompute preconditioner operator for a new matrix.