43 #ifndef IFPACK2_DETAILS_FACTORY_DEF_HPP
44 #define IFPACK2_DETAILS_FACTORY_DEF_HPP
46 #include "Ifpack2_Factory.hpp"
48 #include "Ifpack2_Details_OneLevelFactory.hpp"
49 #include "Ifpack2_AdditiveSchwarz.hpp"
50 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
51 # include "Ifpack2_SupportGraph.hpp"
52 #endif // defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
57 template<
class SC,
class LO,
class GO,
class NT>
60 create (
const std::string& precType,
69 std::string precTypeUpper = canonicalize(precType);
71 if (precTypeUpper ==
"SCHWARZ") {
86 prec =
rcp (
new AdditiveSchwarz<row_matrix_type> (matrix, overlap));
88 else if (precTypeUpper ==
"KRYLOV") {
90 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
91 "been deprecated and removed. If you want a Krylov solver, use the "
94 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
95 else if (precTypeUpper ==
"SUPPORTGRAPH") {
96 prec =
rcp (
new SupportGraph<row_matrix_type> (matrix));
101 Details::OneLevelFactory<row_matrix_type> factory;
102 prec = factory.create (precType, matrix);
103 }
catch (std::invalid_argument&) {
105 true, std::invalid_argument,
"Ifpack2::Factory::create: "
106 "Invalid preconditioner type \"" << precType <<
"\".");
112 template<
class SC,
class LO,
class GO,
class NT>
115 create (
const std::string& precType,
123 std::string precTypeUpper (precType);
124 if (precTypeUpper.size () > 0) {
125 for (
size_t k = 0; k < precTypeUpper.size (); ++k) {
126 precTypeUpper[k] = ::toupper(precTypeUpper[k]);
130 if (precTypeUpper ==
"SCHWARZ") {
152 prec =
rcp (
new AdditiveSchwarz<row_matrix_type> (matrix));
154 else if (precTypeUpper ==
"KRYLOV") {
156 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
157 "been deprecated and removed. If you want a Krylov solver, use the "
160 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
161 else if (precTypeUpper ==
"SUPPORTGRAPH") {
162 prec =
rcp (
new SupportGraph<row_matrix_type> (matrix));
166 bool success =
false;
167 std::ostringstream err;
169 Details::OneLevelFactory<row_matrix_type> factory;
170 prec = factory.create (precType, matrix);
172 }
catch (std::invalid_argument& e) {
173 err <<
"Ifpack2::Factory::create: Invalid preconditioner type \""
174 << precType <<
"\". More information for Ifpack2 developers: "
181 prec.is_null (), std::logic_error,
"Ifpack2::Factory::create: "
182 "Return value is null right before return. This should never happen. "
183 "Please report this bug to the Ifpack2 developers.");
188 template<
class SC,
class LO,
class GO,
class NT>
190 Factory<SC, LO, GO, NT>::
191 isSupported (
const std::string& precType)
194 std::string precTypeUpper = canonicalize(precType);
196 std::vector<std::string> supportedNames = {
198 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
202 auto it = std::find(std::begin(supportedNames), std::end(supportedNames), precTypeUpper);
204 if (it != std::end(supportedNames)) {
207 Details::OneLevelFactory<row_matrix_type> factory;
208 return factory.isSupported (precType);
215 #define IFPACK2_DETAILS_FACTORY_INSTANT(S, LO, GO, N) \
216 template class Ifpack2::Details::Factory<S, LO, GO, N>;
218 #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)
File for utility functions.
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:133