Ifpack2 Templated Preconditioning Package Version 1.0
Loading...
Searching...
No Matches
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
23namespace Ifpack2 {
24
26bool supportsUnsymmetric (const std::string& prec_type);
27
82class Factory {
83public:
94 template<class MatrixType>
95 static
96 Teuchos::RCP<Preconditioner<typename MatrixType::scalar_type,
97 typename MatrixType::local_ordinal_type,
98 typename MatrixType::global_ordinal_type,
99 typename MatrixType::node_type> >
100 create (const std::string& precType,
101 const Teuchos::RCP<const MatrixType>& matrix)
102 {
103 using Teuchos::RCP;
104 using Teuchos::rcp_implicit_cast;
105 typedef typename MatrixType::scalar_type SC;
106 typedef typename MatrixType::local_ordinal_type LO;
107 typedef typename MatrixType::global_ordinal_type GO;
108 typedef typename MatrixType::node_type NT;
109 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
110
111 RCP<const row_matrix_type> A;
112 if (! matrix.is_null ()) {
113 A = rcp_implicit_cast<const row_matrix_type> (matrix);
114 }
115 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
116 return factory.create (precType, A);
117 }
118
134 template<class MatrixType>
135 static
136 Teuchos::RCP<Preconditioner<typename MatrixType::scalar_type,
137 typename MatrixType::local_ordinal_type,
138 typename MatrixType::global_ordinal_type,
139 typename MatrixType::node_type> >
140 create (const std::string& precType,
141 const Teuchos::RCP<const MatrixType>& matrix,
142 const int overlap)
143 {
144 using Teuchos::RCP;
145 using Teuchos::rcp_implicit_cast;
146 typedef typename MatrixType::scalar_type SC;
147 typedef typename MatrixType::local_ordinal_type LO;
148 typedef typename MatrixType::global_ordinal_type GO;
149 typedef typename MatrixType::node_type NT;
150 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
151
152 RCP<const row_matrix_type> A;
153 if (! matrix.is_null ()) {
154 A = rcp_implicit_cast<const row_matrix_type> (matrix);
155 }
156 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
157 return factory.create (precType, A, overlap);
158 }
159
160 template<class MatrixType>
161 static
162 bool
163 isSupported (const std::string& precType)
164 {
165 typedef typename MatrixType::scalar_type SC;
166 typedef typename MatrixType::local_ordinal_type LO;
167 typedef typename MatrixType::global_ordinal_type GO;
168 typedef typename MatrixType::node_type NT;
169
170 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
171 return factory.isSupported (precType);
172 }
173
174};
175
176} // namespace Ifpack2
177
178#endif // IFPACK2_FACTORY_DECL_HPP
"Factory" 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)
Create an instance of Ifpack2_Preconditioner given the string name of the preconditioner type.
Definition Ifpack2_Factory_decl.hpp:100
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:140
Interface for all Ifpack2 preconditioners.
Definition Ifpack2_Preconditioner.hpp:75
Preconditioners and smoothers for Tpetra sparse matrices.
Definition Ifpack2_AdditiveSchwarz_decl.hpp:41
bool supportsUnsymmetric(const std::string &prec_type)
\C true if the specified preconditioner type supports nonsymmetric matrices, else false.
Definition Ifpack2_Factory.cpp:22