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) {
126 for (
size_t k = 0; k < precTypeUpper.size (); ++k) {
127 precTypeUpper[k] = std::toupper<char> (precTypeUpper[k], locale);
131 if (precTypeUpper ==
"SCHWARZ") {
153 prec =
rcp (
new AdditiveSchwarz<row_matrix_type> (matrix));
155 else if (precTypeUpper ==
"KRYLOV") {
157 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
158 "been deprecated and removed. If you want a Krylov solver, use the "
161 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
162 else if (precTypeUpper ==
"SUPPORTGRAPH") {
163 prec =
rcp (
new SupportGraph<row_matrix_type> (matrix));
167 bool success =
false;
168 std::ostringstream err;
170 Details::OneLevelFactory<row_matrix_type> factory;
171 prec = factory.create (precType, matrix);
173 }
catch (std::invalid_argument& e) {
174 err <<
"Ifpack2::Factory::create: Invalid preconditioner type \""
175 << precType <<
"\". More information for Ifpack2 developers: "
182 prec.is_null (), std::logic_error,
"Ifpack2::Factory::create: "
183 "Return value is null right before return. This should never happen. "
184 "Please report this bug to the Ifpack2 developers.");
189 template<
class SC,
class LO,
class GO,
class NT>
191 Factory<SC, LO, GO, NT>::
192 isSupported (
const std::string& precType)
195 std::string precTypeUpper = canonicalize(precType);
197 std::vector<std::string> supportedNames = {
199 #if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
203 auto it = std::find(std::begin(supportedNames), std::end(supportedNames), precTypeUpper);
205 if (it != std::end(supportedNames)) {
208 Details::OneLevelFactory<row_matrix_type> factory;
209 return factory.isSupported (precType);
216 #define IFPACK2_DETAILS_FACTORY_INSTANT(S, LO, GO, N) \
217 template class Ifpack2::Details::Factory<S, LO, GO, N>;
219 #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:132