10#ifndef IFPACK2_DETAILS_FACTORY_DEF_HPP
11#define IFPACK2_DETAILS_FACTORY_DEF_HPP
13#include "Ifpack2_Factory.hpp"
15#include "Ifpack2_Details_OneLevelFactory.hpp"
16#include "Ifpack2_AdditiveSchwarz.hpp"
17#if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
18# include "Ifpack2_SupportGraph.hpp"
24template<
class SC,
class LO,
class GO,
class NT>
25Teuchos::RCP<typename Factory<SC, LO, GO, NT>::prec_type>
26Factory<SC, LO, GO, NT>::
27create (
const std::string& precType,
28 const Teuchos::RCP<const row_matrix_type>& matrix,
36 std::string precTypeUpper = canonicalize(precType);
38 if (precTypeUpper ==
"SCHWARZ") {
53 prec = rcp (
new AdditiveSchwarz<row_matrix_type> (matrix, overlap));
55 else if (precTypeUpper ==
"KRYLOV") {
56 TEUCHOS_TEST_FOR_EXCEPTION
57 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
58 "been deprecated and removed. If you want a Krylov solver, use the "
61#if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
62 else if (precTypeUpper ==
"SUPPORTGRAPH") {
63 prec = rcp (
new SupportGraph<row_matrix_type> (matrix));
68 Details::OneLevelFactory<row_matrix_type> factory;
69 prec = factory.create (precType, matrix);
70 }
catch (std::invalid_argument&) {
71 TEUCHOS_TEST_FOR_EXCEPTION(
72 true, std::invalid_argument,
"Ifpack2::Factory::create: "
73 "Invalid preconditioner type \"" << precType <<
"\".");
79template<
class SC,
class LO,
class GO,
class NT>
80Teuchos::RCP<typename Factory<SC, LO, GO, NT>::prec_type>
81Factory<SC, LO, GO, NT>::
82create (
const std::string& precType,
83 const Teuchos::RCP<const row_matrix_type>& matrix)
90 std::string precTypeUpper (precType);
91 if (precTypeUpper.size () > 0) {
92 for (
size_t k = 0; k < precTypeUpper.size (); ++k) {
93 precTypeUpper[k] = ::toupper(precTypeUpper[k]);
97 if (precTypeUpper ==
"SCHWARZ") {
119 prec = rcp (
new AdditiveSchwarz<row_matrix_type> (matrix));
121 else if (precTypeUpper ==
"KRYLOV") {
122 TEUCHOS_TEST_FOR_EXCEPTION
123 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
124 "been deprecated and removed. If you want a Krylov solver, use the "
127#if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
128 else if (precTypeUpper ==
"SUPPORTGRAPH") {
129 prec = rcp (
new SupportGraph<row_matrix_type> (matrix));
133 bool success =
false;
134 std::ostringstream err;
136 Details::OneLevelFactory<row_matrix_type> factory;
137 prec = factory.create (precType, matrix);
139 }
catch (std::invalid_argument& e) {
140 err <<
"Ifpack2::Factory::create: Invalid preconditioner type \""
141 << precType <<
"\". More information for Ifpack2 developers: "
144 TEUCHOS_TEST_FOR_EXCEPTION(! success, std::invalid_argument, err.str ());
147 TEUCHOS_TEST_FOR_EXCEPTION(
148 prec.is_null (), std::logic_error,
"Ifpack2::Factory::create: "
149 "Return value is null right before return. This should never happen. "
150 "Please report this bug to the Ifpack2 developers.");
155template<
class SC,
class LO,
class GO,
class NT>
157Factory<SC, LO, GO, NT>::
158isSupported (
const std::string& precType)
161 std::string precTypeUpper = canonicalize(precType);
163 std::vector<std::string> supportedNames = {
165#if defined(HAVE_IFPACK2_EXPERIMENTAL) && defined(HAVE_IFPACK2_SUPPORTGRAPH)
169 auto it = std::find(std::begin(supportedNames), std::end(supportedNames), precTypeUpper);
171 if (it != std::end(supportedNames)) {
174 Details::OneLevelFactory<row_matrix_type> factory;
175 return factory.isSupported (precType);
182#define IFPACK2_DETAILS_FACTORY_INSTANT(S, LO, GO, N) \
183 template class Ifpack2::Details::Factory<S, LO, GO, N>;
File for utility functions.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41