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"
57template<
class SC,
class LO,
class GO,
class NT>
58Teuchos::RCP<typename Factory<SC, LO, GO, NT>::prec_type>
59Factory<SC, LO, GO, NT>::
60create (
const std::string& precType,
61 const Teuchos::RCP<const row_matrix_type>& matrix,
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") {
89 TEUCHOS_TEST_FOR_EXCEPTION
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&) {
104 TEUCHOS_TEST_FOR_EXCEPTION(
105 true, std::invalid_argument,
"Ifpack2::Factory::create: "
106 "Invalid preconditioner type \"" << precType <<
"\".");
112template<
class SC,
class LO,
class GO,
class NT>
113Teuchos::RCP<typename Factory<SC, LO, GO, NT>::prec_type>
114Factory<SC, LO, GO, NT>::
115create (
const std::string& precType,
116 const Teuchos::RCP<const row_matrix_type>& matrix)
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") {
155 TEUCHOS_TEST_FOR_EXCEPTION
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: "
177 TEUCHOS_TEST_FOR_EXCEPTION(! success, std::invalid_argument, err.str ());
180 TEUCHOS_TEST_FOR_EXCEPTION(
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.");
188template<
class SC,
class LO,
class GO,
class NT>
190Factory<SC, LO, GO, NT>::
191isSupported (
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>;
File for utility functions.
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:74