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> 132 template<
class MatrixType>
135 typename MatrixType::local_ordinal_type,
136 typename MatrixType::global_ordinal_type,
137 typename MatrixType::node_type> >
139 const Teuchos::RCP<const MatrixType>& matrix)
142 using Teuchos::rcp_implicit_cast;
143 typedef typename MatrixType::scalar_type SC;
144 typedef typename MatrixType::local_ordinal_type LO;
145 typedef typename MatrixType::global_ordinal_type GO;
146 typedef typename MatrixType::node_type NT;
147 typedef Tpetra::RowMatrix<SC, LO, GO, NT> row_matrix_type;
149 RCP<const row_matrix_type> A;
150 if (! matrix.is_null ()) {
151 A = rcp_implicit_cast<
const row_matrix_type> (matrix);
153 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
154 return factory.create (precType, A);
172 template<
class MatrixType>
175 typename MatrixType::local_ordinal_type,
176 typename MatrixType::global_ordinal_type,
177 typename MatrixType::node_type> >
179 const Teuchos::RCP<const MatrixType>& matrix,
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;
190 RCP<const row_matrix_type> A;
191 if (! matrix.is_null ()) {
192 A = rcp_implicit_cast<
const row_matrix_type> (matrix);
194 Ifpack2::Details::Factory<SC, LO, GO, NT> factory;
195 return factory.create (precType, A, overlap);
200 template<
class InputMatrixType,
class OutputMatrixType>
202 Teuchos::RCP<
Preconditioner<
typename OutputMatrixType::scalar_type,
203 typename OutputMatrixType::local_ordinal_type,
204 typename OutputMatrixType::global_ordinal_type,
205 typename OutputMatrixType::node_type> >
207 typename InputMatrixType::local_ordinal_type,
208 typename InputMatrixType::global_ordinal_type,
209 typename InputMatrixType::node_type> >& prec,
210 const Teuchos::RCP<const OutputMatrixType>& matrix,
211 const Teuchos::ParameterList& params = Teuchos::ParameterList ())
216 using Teuchos::rcp_dynamic_cast;
221 typedef typename InputMatrixType::scalar_type scalar_type;
222 typedef typename InputMatrixType::local_ordinal_type local_ordinal_type;
223 typedef typename InputMatrixType::global_ordinal_type global_ordinal_type;
224 typedef typename InputMatrixType::node_type old_node_type;
225 typedef Tpetra::RowMatrix<scalar_type, local_ordinal_type,
226 global_ordinal_type, old_node_type> input_row_matrix_type;
228 static_assert (std::is_same<typename OutputMatrixType::scalar_type, scalar_type>::value,
229 "Input and output scalar_type must be the same.");
230 static_assert (std::is_same<typename OutputMatrixType::local_ordinal_type, local_ordinal_type>::value,
231 "Input and output local_ordinal_type must be the same.");
232 static_assert (std::is_same<typename OutputMatrixType::global_ordinal_type, global_ordinal_type>::value,
233 "Input and output global_ordinal_type must be the same.");
234 typedef typename OutputMatrixType::node_type new_node_type;
236 global_ordinal_type, new_node_type> output_prec_type;
242 RCP<output_prec_type> new_prec;
243 RCP<Chebyshev<input_row_matrix_type> > chebyPrec =
245 if (! chebyPrec.is_null ()) {
246 new_prec = chebyPrec->
clone (matrix, params);
249 RCP<RILUK<input_row_matrix_type> > luPrec;
251 if (luPrec != null) {
252 new_prec = luPrec->
clone (matrix);
255 RCP<Experimental::RBILUK<input_row_matrix_type> > rbilukPrec;
257 if (rbilukPrec != null) {
258 new_prec = rbilukPrec->
clone (matrix);
261 TEUCHOS_TEST_FOR_EXCEPTION
262 (
true, std::logic_error,
"Ifpack2::Factory::clone: Not implemented for the " 263 "current preconditioner type. The only supported types thus far are " 264 "Chebyshev, RILUK, and RBILUK.");
270 #endif // IFPACK2_FACTORY_DECL_HPP ILU(k) factorization of a given Tpetra::RowMatrix.
Definition: Ifpack2_RILUK_decl.hpp:254
Teuchos::RCP< Chebyshev< Tpetra::RowMatrix< typename NewMatrixType::scalar_type, typename NewMatrixType::local_ordinal_type, typename NewMatrixType::global_ordinal_type, typename NewMatrixType::node_type > > > clone(const Teuchos::RCP< const NewMatrixType > &A_newnode, const Teuchos::ParameterList ¶ms) const
Clone this object to one with a different Node type.
Definition: Ifpack2_Chebyshev_decl.hpp:758
static Teuchos::RCP< Preconditioner< typename OutputMatrixType::scalar_type, typename OutputMatrixType::local_ordinal_type, typename OutputMatrixType::global_ordinal_type, typename OutputMatrixType::node_type > > clone(const Teuchos::RCP< Preconditioner< typename InputMatrixType::scalar_type, typename InputMatrixType::local_ordinal_type, typename InputMatrixType::global_ordinal_type, typename InputMatrixType::node_type > > &prec, const Teuchos::RCP< const OutputMatrixType > &matrix, const Teuchos::ParameterList ¶ms=Teuchos::ParameterList())
Clones a preconditioner for a different node type from an Ifpack2 RILUK or Chebyshev preconditioner...
Definition: Ifpack2_Factory_decl.hpp:206
bool supportsUnsymmetric(const std::string &prec_type)
true if the specified preconditioner type supports nonsymmetric matrices, else false.
Definition: Ifpack2_Factory.cpp:55
Diagonally scaled Chebyshev iteration for Tpetra sparse matrices.
Definition: Ifpack2_Chebyshev_decl.hpp:199
Interface for all Ifpack2 preconditioners.
Definition: Ifpack2_Preconditioner.hpp:107
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:138
Teuchos::RCP< RILUK< NewMatrixType > > clone(const Teuchos::RCP< const NewMatrixType > &A_newnode) const
Clone preconditioner to a new node type.
Definition: Ifpack2_RILUK_decl.hpp:677
"Factory" for creating Ifpack2 preconditioners.
Definition: Ifpack2_Factory_decl.hpp:120
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:178
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:72
ILU(k) factorization of a given Tpetra::Experimental::BlockCrsMatrix.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:128