43 #ifndef IFPACK2_DETAILS_ONELEVELFACTORY_DEF_HPP
44 #define IFPACK2_DETAILS_ONELEVELFACTORY_DEF_HPP
46 #include "Ifpack2_Factory.hpp"
48 #include "Ifpack2_Chebyshev.hpp"
49 #include "Ifpack2_Details_DenseSolver.hpp"
50 #include "Ifpack2_Diagonal.hpp"
51 #include "Ifpack2_IdentitySolver.hpp"
52 #include "Ifpack2_ILUT.hpp"
53 #include "Ifpack2_Relaxation.hpp"
54 #include "Ifpack2_RILUK.hpp"
55 #include "Ifpack2_Experimental_RBILUK.hpp"
56 #include "Ifpack2_BlockRelaxation.hpp"
57 #include "Ifpack2_BandedContainer.hpp"
58 #include "Ifpack2_DenseContainer.hpp"
59 #include "Ifpack2_SparseContainer.hpp"
60 #include "Ifpack2_TriDiContainer.hpp"
61 #include "Ifpack2_LocalSparseTriangularSolver.hpp"
63 #ifdef HAVE_IFPACK2_SHYLU_NODEFASTILU
64 #include "Ifpack2_Details_Fic.hpp"
65 #include "Ifpack2_Details_Fildl.hpp"
66 #include "Ifpack2_Details_Filu.hpp"
67 #endif // HAVE_IFPACK2_SHYLU_NODEFASTILU
69 #ifdef HAVE_IFPACK2_AMESOS2
70 # include "Ifpack2_Details_Amesos2Wrapper.hpp"
71 #endif // HAVE_IFPACK2_AMESOS2
76 template<
class MatrixType>
87 std::string precTypeUpper = canonicalize(precType);
89 if (precTypeUpper ==
"CHEBYSHEV") {
92 prec =
rcp (new ::Ifpack2::Chebyshev<row_matrix_type> (matrix));
94 else if (precTypeUpper ==
"DENSE" || precTypeUpper ==
"LAPACK") {
97 else if (precTypeUpper ==
"AMESOS2") {
98 #ifdef HAVE_IFPACK2_AMESOS2
102 true, std::invalid_argument,
"Ifpack2::Details::OneLevelFactory: "
103 "You may not ask for the preconditioner \"AMESOS2\" unless "
104 "you have built Trilinos with the Amesos2 package enabled.");
105 #endif // HAVE_IFPACK2_AMESOS2
107 else if (precTypeUpper ==
"DIAGONAL") {
108 prec =
rcp (
new Diagonal<row_matrix_type> (matrix));
110 else if (precTypeUpper ==
"ILUT") {
113 else if (precTypeUpper ==
"RELAXATION") {
116 else if (precTypeUpper ==
"RILUK") {
119 else if (precTypeUpper ==
"RBILUK") {
122 else if (precTypeUpper ==
"FAST_IC" || precTypeUpper ==
"FAST_ILU" || precTypeUpper ==
"FAST_ILDL") {
123 #ifdef HAVE_IFPACK2_SHYLU_NODEFASTILU
125 if(precTypeUpper ==
"FAST_IC")
127 else if(precTypeUpper ==
"FAST_ILU")
129 else if(precTypeUpper ==
"FAST_ILDL")
134 throw std::invalid_argument(
"The Ifpack2 FastIC, FastILU and FastILDL preconditioners require the FastILU subpackage of ShyLU to be enabled\n"
135 "To enable FastILU, set the CMake option Trilinos_ENABLE_ShyLU_NodeFastILU=ON");
139 else if (precTypeUpper ==
"KRYLOV") {
141 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
142 "been deprecated and removed. If you want a Krylov solver, use the "
145 else if (precTypeUpper ==
"BLOCK_RELAXATION" ||
146 precTypeUpper ==
"BLOCK RELAXATION" ||
147 precTypeUpper ==
"BLOCKRELAXATION" ||
148 precTypeUpper ==
"DENSE_BLOCK_RELAXATION" ||
149 precTypeUpper ==
"DENSE BLOCK RELAXATION" ||
150 precTypeUpper ==
"DENSEBLOCKRELAXATION" ) {
156 params.
set (
"relaxation: container",
"Dense");
159 else if (precTypeUpper ==
"SPARSE_BLOCK_RELAXATION" ||
160 precTypeUpper ==
"SPARSE BLOCK RELAXATION" ||
161 precTypeUpper ==
"SPARSEBLOCKRELAXATION" ) {
168 #ifdef HAVE_IFPACK2_AMESOS2
171 params.
set (
"relaxation: container",
"SparseAmesos2");
175 (
true, std::invalid_argument,
"Ifpack2::Details::OneLevelFactory: "
176 "\"SPARSE BLOCK RELAXATION\" requires building Trilinos with Amesos2 enabled.");
179 else if (precTypeUpper ==
"TRIDI_RELAXATION" ||
180 precTypeUpper ==
"TRIDI RELAXATION" ||
181 precTypeUpper ==
"TRIDIRELAXATION" ||
182 precTypeUpper ==
"TRIDIAGONAL_RELAXATION" ||
183 precTypeUpper ==
"TRIDIAGONAL RELAXATION" ||
184 precTypeUpper ==
"TRIDIAGONALRELAXATION") {
187 params.
set (
"relaxation: container",
"TriDi");
190 else if (precTypeUpper ==
"BANDED_RELAXATION" ||
191 precTypeUpper ==
"BANDED RELAXATION" ||
192 precTypeUpper ==
"BANDEDRELAXATION") {
195 params.
set (
"relaxation: container",
"Banded");
198 else if (precTypeUpper ==
"IDENTITY" || precTypeUpper ==
"IDENTITY_SOLVER") {
202 else if (precTypeUpper ==
"LOCAL SPARSE TRIANGULAR SOLVER" ||
203 precTypeUpper ==
"LOCAL_SPARSE_TRIANGULAR_SOLVER" ||
204 precTypeUpper ==
"LOCALSPARSETRIANGULARSOLVER" ||
205 precTypeUpper ==
"SPARSE TRIANGULAR SOLVER" ||
206 precTypeUpper ==
"SPARSE_TRIANGULAR_SOLVER" ||
207 precTypeUpper ==
"SPARSETRIANGULARSOLVER") {
212 true, std::invalid_argument,
"Ifpack2::Details::OneLevelFactory::create: "
213 "Invalid preconditioner type \"" << precType <<
"\".");
217 prec.is_null (), std::logic_error,
"Ifpack2::Details::OneLevelFactory::"
218 "create: Return value is null right before return. This should never "
219 "happen. Please report this bug to the Ifpack2 developers.");
223 template<
class MatrixType>
228 std::string precTypeUpper = canonicalize(precType);
229 std::vector<std::string> supportedNames = {
230 "CHEBYSHEV",
"DENSE",
"LAPACK",
231 #ifdef HAVE_IFPACK2_AMESOS2
234 "DIAGONAL",
"ILUT",
"RELAXATION",
"RILUK",
"RBILUK",
235 #ifdef HAVE_IFPACK2_SHYLU_NODEFASTILU
236 "FAST_IC",
"FAST_ILU",
"FAST_ILDL",
238 "BLOCK_RELAXATION",
"BLOCK RELAXATION",
"BLOCKRELAXATION",
"DENSE_BLOCK_RELAXATION",
"DENSE BLOCK RELAXATION",
"DENSEBLOCKRELAXATION",
239 #ifdef HAVE_IFPACK2_AMESOS2
240 "SPARSE_BLOCK_RELAXATION",
"SPARSE BLOCK RELAXATION",
"SPARSEBLOCKRELAXATION",
242 "TRIDI_RELAXATION",
"TRIDI RELAXATION",
"TRIDIRELAXATION",
"TRIDIAGONAL_RELAXATION",
"TRIDIAGONAL RELAXATION",
"TRIDIAGONALRELAXATION",
243 "BANDED_RELAXATION",
"BANDED RELAXATION",
"BANDEDRELAXATION",
244 "IDENTITY",
"IDENTITY_SOLVER",
245 "LOCAL SPARSE TRIANGULAR SOLVER",
"LOCAL_SPARSE_TRIANGULAR_SOLVER",
"LOCALSPARSETRIANGULARSOLVER",
"SPARSE TRIANGULAR SOLVER",
"SPARSE_TRIANGULAR_SOLVER",
"SPARSETRIANGULARSOLVER"
249 auto it = std::find(std::begin(supportedNames), std::end(supportedNames), precTypeUpper);
250 return it != std::end(supportedNames);
256 #define IFPACK2_DETAILS_ONELEVELFACTORY_INSTANT(S,LO,GO,N) \
257 template class Ifpack2::Details::OneLevelFactory< Tpetra::RowMatrix<S, LO, GO, N> >;
259 #endif // IFPACK2_DETAILS_ONELEVELFACTORY_DEF_HPP
Teuchos::RCP< prec_type > create(const std::string &precType, const Teuchos::RCP< const row_matrix_type > &matrix) const
Create an instance of Preconditioner given the string name of the preconditioner type.
Definition: Ifpack2_Details_OneLevelFactory_def.hpp:78
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ILU(k) factorization of a given Tpetra::RowMatrix.
Definition: Ifpack2_RILUK_decl.hpp:243
"Preconditioner" that uses LAPACK's dense LU.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:75
The Ifpack2 wrapper to the ILDL preconditioner of ShyLU FastILU.
Definition: Ifpack2_Details_Fildl_decl.hpp:62
The Ifpack2 wrapper to the ILU preconditioner of ShyLU FastILU.
Definition: Ifpack2_Details_Filu_decl.hpp:62
ILUT (incomplete LU factorization with threshold) of a Tpetra sparse matrix.
Definition: Ifpack2_ILUT_decl.hpp:91
Block relaxation preconditioners (or smoothers) for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse ma...
Definition: Ifpack2_BlockRelaxation_decl.hpp:83
"Identity" preconditioner.
Definition: Ifpack2_IdentitySolver_decl.hpp:60
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Wrapper class for direct solvers in Amesos2.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:102
"Preconditioner" that solves local sparse triangular systems.
Definition: Ifpack2_LocalSparseTriangularSolver_decl.hpp:77
File for utility functions.
ParameterList & setParameters(const ParameterList &source)
The Ifpack2 wrapper to the incomplete Chebyshev preconditioner of ShyLU FastILU.
Definition: Ifpack2_Details_Fic_decl.hpp:62
"Factory" for creating single-level preconditioners.
Definition: Ifpack2_Details_OneLevelFactory_decl.hpp:123
Relaxation preconditioners for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse matrices.
Definition: Ifpack2_Relaxation_decl.hpp:236
ILU(k) factorization of a given Tpetra::BlockCrsMatrix.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:128