43 #ifndef IFPACK2_FACTORY_DECL_HPP
44 #define IFPACK2_FACTORY_DECL_HPP
46 #include "Ifpack2_ConfigDefs.hpp"
48 #include "Ifpack2_Details_Factory.hpp"
53 #include "Ifpack2_Chebyshev.hpp"
54 #include "Ifpack2_RILUK.hpp"
55 #include "Ifpack2_Experimental_RBILUK.hpp"
57 #include <type_traits>
129 template<
class MatrixType>
132 typename MatrixType::local_ordinal_type,
133 typename MatrixType::global_ordinal_type,
134 typename MatrixType::node_type> >
136 const Teuchos::RCP<const MatrixType>& matrix)
139 using Teuchos::rcp_implicit_cast;
140 typedef typename MatrixType::scalar_type SC;
141 typedef typename MatrixType::local_ordinal_type LO;
142 typedef typename MatrixType::global_ordinal_type GO;
143 typedef typename MatrixType::node_type NT;
144 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
146 RCP<const row_matrix_type> A;
147 if (! matrix.is_null ()) {
148 A = rcp_implicit_cast<const row_matrix_type> (matrix);
150 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
151 return factory.create (precType, A);
169 template<
class MatrixType>
172 typename MatrixType::local_ordinal_type,
173 typename MatrixType::global_ordinal_type,
174 typename MatrixType::node_type> >
176 const Teuchos::RCP<const MatrixType>& matrix,
180 using Teuchos::rcp_implicit_cast;
181 typedef typename MatrixType::scalar_type SC;
182 typedef typename MatrixType::local_ordinal_type LO;
183 typedef typename MatrixType::global_ordinal_type GO;
184 typedef typename MatrixType::node_type NT;
185 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
187 RCP<const row_matrix_type> A;
188 if (! matrix.is_null ()) {
189 A = rcp_implicit_cast<const row_matrix_type> (matrix);
191 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
192 return factory.create (precType, A, overlap);
197 template<
class InputMatrixType,
class OutputMatrixType>
199 Teuchos::RCP<
Preconditioner<
typename OutputMatrixType::scalar_type,
200 typename OutputMatrixType::local_ordinal_type,
201 typename OutputMatrixType::global_ordinal_type,
202 typename OutputMatrixType::node_type> >
204 typename InputMatrixType::local_ordinal_type,
205 typename InputMatrixType::global_ordinal_type,
206 typename InputMatrixType::node_type> >& prec,
207 const Teuchos::RCP<const OutputMatrixType>& matrix,
208 const Teuchos::ParameterList& params = Teuchos::ParameterList ())
213 using Teuchos::rcp_dynamic_cast;
218 typedef typename InputMatrixType::scalar_type scalar_type;
219 typedef typename InputMatrixType::local_ordinal_type local_ordinal_type;
220 typedef typename InputMatrixType::global_ordinal_type global_ordinal_type;
221 typedef typename InputMatrixType::node_type old_node_type;
222 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
223 global_ordinal_type, old_node_type> input_row_matrix_type;
225 static_assert (std::is_same<typename OutputMatrixType::scalar_type, scalar_type>::value,
226 "Input and output scalar_type must be the same.");
227 static_assert (std::is_same<typename OutputMatrixType::local_ordinal_type, local_ordinal_type>::value,
228 "Input and output local_ordinal_type must be the same.");
229 static_assert (std::is_same<typename OutputMatrixType::global_ordinal_type, global_ordinal_type>::value,
230 "Input and output global_ordinal_type must be the same.");
231 typedef typename OutputMatrixType::node_type new_node_type;
233 global_ordinal_type, new_node_type> output_prec_type;
239 RCP<output_prec_type> new_prec;
240 RCP<Chebyshev<input_row_matrix_type> > chebyPrec =
242 if (! chebyPrec.is_null ()) {
243 new_prec = chebyPrec->
clone (matrix, params);
246 RCP<RILUK<input_row_matrix_type> > luPrec;
248 if (luPrec !=
null) {
249 new_prec = luPrec->
clone (matrix);
252 RCP<Experimental::RBILUK<input_row_matrix_type> > rbilukPrec;
254 if (rbilukPrec !=
null) {
255 new_prec = rbilukPrec->
clone (matrix);
258 TEUCHOS_TEST_FOR_EXCEPTION
259 (
true, std::logic_error,
"Ifpack2::Factory::clone: Not implemented for the "
260 "current preconditioner type. The only supported types thus far are "
261 "Chebyshev, RILUK, and RBILUK.");
267 #endif // IFPACK2_FACTORY_DECL_HPP