43 #ifndef IFPACK2_DETAILS_FACTORY_DEF_HPP
44 #define IFPACK2_DETAILS_FACTORY_DEF_HPP
46 #include "Ifpack2_Details_OneLevelFactory.hpp"
47 #include "Ifpack2_AdditiveSchwarz.hpp"
48 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
49 # include "Ifpack2_SupportGraph.hpp"
50 #endif // defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
55 template<
class SC,
class LO,
class GO,
class NT>
58 create (
const std::string& precType,
67 std::string precTypeUpper (precType);
68 if (precTypeUpper.size () > 0) {
70 for (
size_t k = 0; k < precTypeUpper.size (); ++k) {
71 precTypeUpper[k] = std::toupper<char> (precTypeUpper[k], locale);
75 if (precTypeUpper ==
"SCHWARZ") {
90 prec =
rcp (
new AdditiveSchwarz<row_matrix_type> (matrix, overlap));
92 else if (precTypeUpper ==
"KRYLOV") {
94 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
95 "been deprecated and removed. If you want a Krylov solver, use the "
98 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
99 else if (precTypeUpper ==
"SUPPORTGRAPH") {
100 prec =
rcp (
new SupportGraph<row_matrix_type> (matrix));
105 Details::OneLevelFactory<row_matrix_type> factory;
106 prec = factory.create (precType, matrix);
107 }
catch (std::invalid_argument&) {
109 true, std::invalid_argument,
"Ifpack2::Factory::create: "
110 "Invalid preconditioner type \"" << precType <<
"\".");
116 template<
class SC,
class LO,
class GO,
class NT>
119 create (
const std::string& precType,
127 std::string precTypeUpper (precType);
128 if (precTypeUpper.size () > 0) {
130 for (
size_t k = 0; k < precTypeUpper.size (); ++k) {
131 precTypeUpper[k] = std::toupper<char> (precTypeUpper[k], locale);
135 if (precTypeUpper ==
"SCHWARZ") {
157 prec =
rcp (
new AdditiveSchwarz<row_matrix_type> (matrix));
159 else if (precTypeUpper ==
"KRYLOV") {
161 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
162 "been deprecated and removed. If you want a Krylov solver, use the "
165 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
166 else if (precTypeUpper ==
"SUPPORTGRAPH") {
167 prec =
rcp (
new SupportGraph<row_matrix_type> (matrix));
171 bool success =
false;
172 std::ostringstream err;
174 Details::OneLevelFactory<row_matrix_type> factory;
175 prec = factory.create (precType, matrix);
177 }
catch (std::invalid_argument& e) {
178 err <<
"Ifpack2::Factory::create: Invalid preconditioner type \""
179 << precType <<
"\". More information for Ifpack2 developers: "
186 prec.is_null (), std::logic_error,
"Ifpack2::Factory::create: "
187 "Return value is null right before return. This should never happen. "
188 "Please report this bug to the Ifpack2 developers.");
195 #define IFPACK2_DETAILS_FACTORY_INSTANT(S, LO, GO, N) \
196 template class Ifpack2::Details::Factory<S, LO, GO, N>;
198 #endif // IFPACK2_DETAILS_FACTORY_DEF_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static Teuchos::RCP< Preconditioner< typename MatrixType::scalar_type, typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type > > create(const std::string &precType, const Teuchos::RCP< const MatrixType > &matrix)
Create an instance of Ifpack2_Preconditioner given the string name of the preconditioner type...
Definition: Ifpack2_Factory_decl.hpp:135