28Teuchos::RCP<typename LinearSolverFactory<SC, LO, GO, NT>::solver_type>
34 using Teuchos::rcp_dynamic_cast;
35 using Teuchos::TypeNameTraits;
37 typedef Tpetra::RowMatrix<SC, LO, GO, NT> ROW;
38 const char prefix[] =
"Ifpack2::Details::LinearSolverFactory::getLinearSolver: ";
40 RCP<prec_type> solver;
46 solver = Ifpack2::Factory::template create<ROW> (solverName, null);
48 catch (std::exception& e) {
49 TEUCHOS_TEST_FOR_EXCEPTION
50 (
true, std::invalid_argument, prefix <<
"Failed to create Ifpack2 "
51 "preconditioner named \"" << solverName <<
"\", for the following "
52 "template parameters: "
53 <<
"SC = " << TypeNameTraits<SC>::name ()
54 <<
", LO = " << TypeNameTraits<LO>::name ()
55 <<
", GO = " << TypeNameTraits<GO>::name ()
56 <<
", NT = " << TypeNameTraits<NT>::name ()
57 <<
". Ifpack2::Factory::create threw an exception: " << e.what ());
59 TEUCHOS_TEST_FOR_EXCEPTION
60 (solver.is_null (), std::invalid_argument, prefix <<
"Failed to create "
61 "Ifpack2 preconditioner named \"" << solverName <<
"\", for the "
62 "following template parameters: "
63 <<
"SC = " << TypeNameTraits<SC>::name ()
64 <<
", LO = " << TypeNameTraits<LO>::name ()
65 <<
", GO = " << TypeNameTraits<GO>::name ()
66 <<
", NT = " << TypeNameTraits<NT>::name ()
67 <<
". Ifpack2::Factory::create returned null.");
70 return Teuchos::rcp (
new impl_type (solver, solverName));
78 typedef Tpetra::MultiVector<SC, LO, GO, NT> MV;
79 typedef Tpetra::Operator<SC, LO, GO, NT> OP;
80 typedef typename MV::mag_type mag_type;
81 typedef Trilinos::Details::LinearSolverFactory<MV, OP, mag_type> factory_base_type;
84#ifdef HAVE_TEUCHOSCORE_CXX11
85 typedef std::shared_ptr<factory_base_type> base_ptr_type;
86 typedef std::shared_ptr<factory_impl_type> impl_ptr_type;
88 typedef Teuchos::RCP<factory_base_type> base_ptr_type;
89 typedef Teuchos::RCP<factory_impl_type> impl_ptr_type;
92 impl_ptr_type factory (
new factory_impl_type ());
93 base_ptr_type factoryBase = factory;
95 TEUCHOS_TEST_FOR_EXCEPTION
96 (factoryBase.get () == NULL, std::logic_error,
"Factory is null! This "
97 "should never happen! Please report this bug to the Ifpack2 developers.");
113 Trilinos::Details::registerLinearSolverFactory<MV, OP, mag_type> (
"Ifpack2", factoryBase);