14 #ifndef IFPACK2_DETAILS_LINEARSOLVERFACTORY_DEF_HPP
15 #define IFPACK2_DETAILS_LINEARSOLVERFACTORY_DEF_HPP
19 #include "Ifpack2_Details_LinearSolver.hpp"
20 #include "Ifpack2_Factory.hpp"
21 #include "Tpetra_RowMatrix.hpp"
22 #include <type_traits>
27 template <
class SC,
class LO,
class GO,
class NT>
33 using Teuchos::rcp_dynamic_cast;
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) {
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());
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.");
63 template <
class SC,
class LO,
class GO,
class NT>
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;
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;
78 #endif // HAVE_TEUCHOSCORE_CXX11
80 impl_ptr_type factory(
new factory_impl_type());
81 base_ptr_type factoryBase = factory;
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);
109 #define IFPACK2_DETAILS_LINEARSOLVERFACTORY_INSTANT(SC, LO, GO, NT) \
110 template class Ifpack2::Details::LinearSolverFactory<SC, LO, GO, NT>;
112 #endif // IFPACK2_DETAILS_LINEARSOLVERFACTORY_DEF_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static void registerLinearSolverFactory()
Register this LinearSolverFactory with the central registry.
Definition: Ifpack2_Details_LinearSolverFactory_def.hpp:65
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Interface for a "factory" that creates Ifpack2 solvers.
Definition: Ifpack2_Details_LinearSolverFactory_decl.hpp:31
Ifpack2's implementation of Trilinos::Details::LinearSolver interface.
Definition: Ifpack2_Details_LinearSolver_decl.hpp:72
virtual Teuchos::RCP< solver_type > getLinearSolver(const std::string &solverName)
Get an instance of a Ifpack2 solver.
Definition: Ifpack2_Details_LinearSolverFactory_def.hpp:30
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
Declaration of interface for preconditioners that can change their matrix after construction.