28Teuchos::RCP<typename LinearSolverFactory<SC, LO, GO, NT>::solver_type>
33 using Teuchos::rcp_dynamic_cast;
34 using Teuchos::TypeNameTraits;
36 typedef Tpetra::RowMatrix<SC, LO, GO, NT> ROW;
37 const char prefix[] =
"Ifpack2::Details::LinearSolverFactory::getLinearSolver: ";
39 RCP<prec_type> solver;
45 solver = Ifpack2::Factory::template create<ROW>(solverName, null);
46 }
catch (std::exception& e) {
47 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument, prefix <<
"Failed to create Ifpack2 "
48 "preconditioner named \""
49 << solverName <<
"\", for the following "
50 "template parameters: "
51 <<
"SC = " << TypeNameTraits<SC>::name() <<
", LO = " << TypeNameTraits<LO>::name() <<
", GO = " << TypeNameTraits<GO>::name() <<
", NT = " << TypeNameTraits<NT>::name() <<
". Ifpack2::Factory::create threw an exception: " << e.what());
53 TEUCHOS_TEST_FOR_EXCEPTION(solver.is_null(), std::invalid_argument, prefix <<
"Failed to create "
54 "Ifpack2 preconditioner named \""
55 << solverName <<
"\", for the "
56 "following template parameters: "
57 <<
"SC = " << TypeNameTraits<SC>::name() <<
", LO = " << TypeNameTraits<LO>::name() <<
", GO = " << TypeNameTraits<GO>::name() <<
", NT = " << TypeNameTraits<NT>::name() <<
". Ifpack2::Factory::create returned null.");
60 return Teuchos::rcp(
new impl_type(solver, solverName));
66 typedef Tpetra::MultiVector<SC, LO, GO, NT> MV;
67 typedef Tpetra::Operator<SC, LO, GO, NT> OP;
68 typedef typename MV::mag_type mag_type;
69 typedef Trilinos::Details::LinearSolverFactory<MV, OP, mag_type> factory_base_type;
72#ifdef HAVE_TEUCHOSCORE_CXX11
73 typedef std::shared_ptr<factory_base_type> base_ptr_type;
74 typedef std::shared_ptr<factory_impl_type> impl_ptr_type;
76 typedef Teuchos::RCP<factory_base_type> base_ptr_type;
77 typedef Teuchos::RCP<factory_impl_type> impl_ptr_type;
80 impl_ptr_type factory(
new factory_impl_type());
81 base_ptr_type factoryBase = factory;
83 TEUCHOS_TEST_FOR_EXCEPTION(factoryBase.get() == NULL, std::logic_error,
84 "Factory is null! This "
85 "should never happen! Please report this bug to the Ifpack2 developers.");
101 Trilinos::Details::registerLinearSolverFactory<MV, OP, mag_type>(
"Ifpack2", factoryBase);