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,
140  typename MatrixType::local_ordinal_type,
141  typename MatrixType::global_ordinal_type,
142  typename MatrixType::node_type> >& coordinates) {
143  using Teuchos::RCP;
144  using Teuchos::rcp_implicit_cast;
145  typedef typename MatrixType::scalar_type SC;
146  typedef typename MatrixType::local_ordinal_type LO;
147  typedef typename MatrixType::global_ordinal_type GO;
148  typedef typename MatrixType::node_type NT;
149  typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
150 
151  RCP<const row_matrix_type> A;
152  if (!matrix.is_null()) {
153  A = rcp_implicit_cast<const row_matrix_type>(matrix);
154  }
155  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
156  return factory.create(precType, A, coordinates);
157  }
158 
174  template <class MatrixType>
175  static Teuchos::RCP<Preconditioner<typename MatrixType::scalar_type,
176  typename MatrixType::local_ordinal_type,
177  typename MatrixType::global_ordinal_type,
178  typename MatrixType::node_type> >
179  create(const std::string& precType,
180  const Teuchos::RCP<const MatrixType>& matrix,
181  const int overlap) {
182  using Teuchos::RCP;
183  using Teuchos::rcp_implicit_cast;
184  typedef typename MatrixType::scalar_type SC;
185  typedef typename MatrixType::local_ordinal_type LO;
186  typedef typename MatrixType::global_ordinal_type GO;
187  typedef typename MatrixType::node_type NT;
188  typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
189 
190  RCP<const row_matrix_type> A;
191  if (!matrix.is_null()) {
192  A = rcp_implicit_cast<const row_matrix_type>(matrix);
193  }
194  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
195  return factory.create(precType, A, overlap);
196  }
197 
198  template <class MatrixType>
199  static std::vector<std::string>
200  getSupportedNames() {
201  using SC = typename MatrixType::scalar_type;
202  using LO = typename MatrixType::local_ordinal_type;
203  using GO = typename MatrixType::global_ordinal_type;
204  using NT = typename MatrixType::node_type;
205 
206  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
207  return factory.getSupportedNames();
208  }
209 
210  template <class MatrixType>
211  static bool
212  isSupported(const std::string& precType) {
213  typedef typename MatrixType::scalar_type SC;
214  typedef typename MatrixType::local_ordinal_type LO;
215  typedef typename MatrixType::global_ordinal_type GO;
216  typedef typename MatrixType::node_type NT;
217 
218  Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
219  return factory.isSupported(precType);
220  }
221 };
222 
223 } // namespace Ifpack2
224 
225 #endif // IFPACK2_FACTORY_DECL_HPP
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 Teuchos::RCP< const Tpetra::MultiVector< typename Teuchos::ScalarTraits< typename MatrixType::scalar_type >::magnitudeType, typename MatrixType::local_ordinal_type, typename MatrixType::global_ordinal_type, typename MatrixType::node_type > > &coordinates)
Create an instance of Ifpack2_Preconditioner given the string name of the preconditioner type...
Definition: Ifpack2_Factory_decl.hpp:137
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:179
bool is_null() const