Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_Factory_decl.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4 //
5 // Copyright 2009 NTESS and the Ifpack2 contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef IFPACK2_FACTORY_DECL_HPP
11 #define IFPACK2_FACTORY_DECL_HPP
12 
13 #include "Ifpack2_ConfigDefs.hpp"
15 #include "Ifpack2_Details_Factory.hpp"
16 
17 #include "Ifpack2_Chebyshev.hpp"
18 #include "Ifpack2_RILUK.hpp"
19 #include "Ifpack2_Experimental_RBILUK.hpp"
20 
21 #include <type_traits>
22 
23 namespace Ifpack2 {
24 
26 bool supportsUnsymmetric(const std::string& prec_type);
27 
82 class Factory {
83  public:
94  template <class MatrixType>
95  static Teuchos::RCP<Preconditioner<typename MatrixType::scalar_type,
96  typename MatrixType::local_ordinal_type,
97  typename MatrixType::global_ordinal_type,
98  typename MatrixType::node_type> >
99  create(const std::string& precType,
100  const Teuchos::RCP<const MatrixType>& matrix) {
101  using Teuchos::RCP;
102  using Teuchos::rcp_implicit_cast;
103  typedef typename MatrixType::scalar_type SC;
104  typedef typename MatrixType::local_ordinal_type LO;
105  typedef typename MatrixType::global_ordinal_type GO;
106  typedef typename MatrixType::node_type NT;
107  typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
108 
109  RCP<const row_matrix_type> A;
110  if (!matrix.is_null()) {
111  A = rcp_implicit_cast<const row_matrix_type>(matrix);
112  }
113  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
114  return factory.create(precType, A);
115  }
116 
132  template <class MatrixType>
133  static Teuchos::RCP<Preconditioner<typename MatrixType::scalar_type,
134  typename MatrixType::local_ordinal_type,
135  typename MatrixType::global_ordinal_type,
136  typename MatrixType::node_type> >
137  create(const std::string& precType,
138  const Teuchos::RCP<const MatrixType>& matrix,
139  const int overlap) {
140  using Teuchos::RCP;
141  using Teuchos::rcp_implicit_cast;
142  typedef typename MatrixType::scalar_type SC;
143  typedef typename MatrixType::local_ordinal_type LO;
144  typedef typename MatrixType::global_ordinal_type GO;
145  typedef typename MatrixType::node_type NT;
146  typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
147 
148  RCP<const row_matrix_type> A;
149  if (!matrix.is_null()) {
150  A = rcp_implicit_cast<const row_matrix_type>(matrix);
151  }
152  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
153  return factory.create(precType, A, overlap);
154  }
155 
156  template <class MatrixType>
157  static std::vector<std::string>
158  getSupportedNames() {
159  using SC = typename MatrixType::scalar_type;
160  using LO = typename MatrixType::local_ordinal_type;
161  using GO = typename MatrixType::global_ordinal_type;
162  using NT = typename MatrixType::node_type;
163 
164  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
165  return factory.getSupportedNames();
166  }
167 
168  template <class MatrixType>
169  static bool
170  isSupported(const std::string& precType) {
171  typedef typename MatrixType::scalar_type SC;
172  typedef typename MatrixType::local_ordinal_type LO;
173  typedef typename MatrixType::global_ordinal_type GO;
174  typedef typename MatrixType::node_type NT;
175 
176  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
177  return factory.isSupported(precType);
178  }
179 };
180 
181 } // namespace Ifpack2
182 
183 #endif // IFPACK2_FACTORY_DECL_HPP
bool supportsUnsymmetric(const std::string &prec_type)
true if the specified preconditioner type supports nonsymmetric matrices, else false.
Definition: Ifpack2_Factory.cpp:21
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:74
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:99
&quot;Factory&quot; for creating Ifpack2 preconditioners.
Definition: Ifpack2_Factory_decl.hpp:82
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, const int overlap)
Create an instance of Ifpack2_Preconditioner given the string name of the preconditioner type...
Definition: Ifpack2_Factory_decl.hpp:137
bool is_null() const