10 #ifndef IFPACK2_DETAILS_ONELEVELFACTORY_DEF_HPP
11 #define IFPACK2_DETAILS_ONELEVELFACTORY_DEF_HPP
13 #include "Ifpack2_Factory.hpp"
15 #include "Ifpack2_Chebyshev.hpp"
16 #include "Ifpack2_Details_DenseSolver.hpp"
17 #include "Ifpack2_Diagonal.hpp"
18 #include "Ifpack2_IdentitySolver.hpp"
19 #include "Ifpack2_ILUT.hpp"
20 #include "Ifpack2_MDF.hpp"
21 #include "Ifpack2_Relaxation.hpp"
22 #include "Ifpack2_RILUK.hpp"
23 #include "Ifpack2_Experimental_RBILUK.hpp"
24 #include "Ifpack2_BlockRelaxation.hpp"
25 #include "Ifpack2_BandedContainer.hpp"
26 #include "Ifpack2_DenseContainer.hpp"
27 #include "Ifpack2_DatabaseSchwarz.hpp"
28 #include "Ifpack2_SparseContainer.hpp"
29 #include "Ifpack2_TriDiContainer.hpp"
30 #include "Ifpack2_LocalSparseTriangularSolver.hpp"
31 #include "Ifpack2_Hiptmair.hpp"
33 #ifdef HAVE_IFPACK2_SHYLU_NODEFASTILU
34 #include "Ifpack2_Details_Fic.hpp"
35 #include "Ifpack2_Details_Fildl.hpp"
36 #include "Ifpack2_Details_Filu.hpp"
37 #endif // HAVE_IFPACK2_SHYLU_NODEFASTILU
39 #ifdef HAVE_IFPACK2_AMESOS2
40 # include "Ifpack2_Details_Amesos2Wrapper.hpp"
41 #endif // HAVE_IFPACK2_AMESOS2
43 #ifdef HAVE_IFPACK2_HYPRE
44 # include "Ifpack2_Hypre.hpp"
45 #endif // HAVE_IFPACK2_HYPRE
51 template<
class MatrixType>
62 std::string precTypeUpper = canonicalize(precType);
64 if (precTypeUpper ==
"CHEBYSHEV") {
67 prec =
rcp (new ::Ifpack2::Chebyshev<row_matrix_type> (matrix));
69 else if (precTypeUpper ==
"DENSE" || precTypeUpper ==
"LAPACK") {
72 else if (precTypeUpper ==
"AMESOS2") {
73 #ifdef HAVE_IFPACK2_AMESOS2
77 true, std::invalid_argument,
"Ifpack2::Details::OneLevelFactory: "
78 "You may not ask for the preconditioner \"AMESOS2\" unless "
79 "you have built Trilinos with the Amesos2 package enabled.");
80 #endif // HAVE_IFPACK2_AMESOS2
82 else if (precTypeUpper ==
"DIAGONAL") {
83 prec =
rcp (
new Diagonal<row_matrix_type> (matrix));
85 else if (precTypeUpper ==
"ILUT") {
88 else if (precTypeUpper ==
"RELAXATION") {
91 else if (precTypeUpper ==
"RILUK") {
94 else if (precTypeUpper ==
"MDF") {
97 else if (precTypeUpper ==
"RBILUK") {
100 else if (precTypeUpper ==
"FAST_IC" || precTypeUpper ==
"FAST_ILU" || precTypeUpper ==
"FAST_ILU_B" || precTypeUpper ==
"FAST_ILDL") {
101 #ifdef HAVE_IFPACK2_SHYLU_NODEFASTILU
103 if(precTypeUpper ==
"FAST_IC")
105 else if(precTypeUpper ==
"FAST_ILU")
107 else if(precTypeUpper ==
"FAST_ILU_B")
109 else if(precTypeUpper ==
"FAST_ILDL")
114 throw std::invalid_argument(
"The Ifpack2 FastIC, FastILU and FastILDL preconditioners require the FastILU subpackage of ShyLU to be enabled\n"
115 "To enable FastILU, set the CMake option Trilinos_ENABLE_ShyLU_NodeFastILU=ON");
119 else if (precTypeUpper ==
"KRYLOV") {
121 (
true, std::invalid_argument,
"The \"KRYLOV\" preconditioner option has "
122 "been deprecated and removed. If you want a Krylov solver, use the "
125 else if (precTypeUpper ==
"BLOCK_RELAXATION" ||
126 precTypeUpper ==
"BLOCK RELAXATION" ||
127 precTypeUpper ==
"BLOCKRELAXATION" ||
128 precTypeUpper ==
"DENSE_BLOCK_RELAXATION" ||
129 precTypeUpper ==
"DENSE BLOCK RELAXATION" ||
130 precTypeUpper ==
"DENSEBLOCKRELAXATION" ) {
136 params.
set (
"relaxation: container",
"Dense");
139 else if (precTypeUpper ==
"DATABASE SCHWARZ") {
142 else if (precTypeUpper ==
"SPARSE_BLOCK_RELAXATION" ||
143 precTypeUpper ==
"SPARSE BLOCK RELAXATION" ||
144 precTypeUpper ==
"SPARSEBLOCKRELAXATION" ) {
151 #ifdef HAVE_IFPACK2_AMESOS2
154 params.
set (
"relaxation: container",
"SparseAmesos2");
158 (
true, std::invalid_argument,
"Ifpack2::Details::OneLevelFactory: "
159 "\"SPARSE BLOCK RELAXATION\" requires building Trilinos with Amesos2 enabled.");
162 else if (precTypeUpper ==
"TRIDI_RELAXATION" ||
163 precTypeUpper ==
"TRIDI RELAXATION" ||
164 precTypeUpper ==
"TRIDIRELAXATION" ||
165 precTypeUpper ==
"TRIDIAGONAL_RELAXATION" ||
166 precTypeUpper ==
"TRIDIAGONAL RELAXATION" ||
167 precTypeUpper ==
"TRIDIAGONALRELAXATION") {
170 params.
set (
"relaxation: container",
"TriDi");
173 else if (precTypeUpper ==
"BANDED_RELAXATION" ||
174 precTypeUpper ==
"BANDED RELAXATION" ||
175 precTypeUpper ==
"BANDEDRELAXATION") {
178 params.
set (
"relaxation: container",
"Banded");
181 else if (precTypeUpper ==
"IDENTITY" || precTypeUpper ==
"IDENTITY_SOLVER") {
185 else if (precTypeUpper ==
"LOCAL SPARSE TRIANGULAR SOLVER" ||
186 precTypeUpper ==
"LOCAL_SPARSE_TRIANGULAR_SOLVER" ||
187 precTypeUpper ==
"LOCALSPARSETRIANGULARSOLVER" ||
188 precTypeUpper ==
"SPARSE TRIANGULAR SOLVER" ||
189 precTypeUpper ==
"SPARSE_TRIANGULAR_SOLVER" ||
190 precTypeUpper ==
"SPARSETRIANGULARSOLVER") {
193 else if(precTypeUpper ==
"HIPTMAIR") {
196 #ifdef HAVE_IFPACK2_HYPRE
197 else if (precTypeUpper ==
"HYPRE") {
198 prec =
rcp (
new Hypre<row_matrix_type> (matrix));
203 true, std::invalid_argument,
"Ifpack2::Details::OneLevelFactory::create: "
204 "Invalid preconditioner type \"" << precType <<
"\".");
208 prec.is_null (), std::logic_error,
"Ifpack2::Details::OneLevelFactory::"
209 "create: Return value is null right before return. This should never "
210 "happen. Please report this bug to the Ifpack2 developers.");
214 template<
class MatrixType>
219 std::string precTypeUpper = canonicalize(precType);
220 std::vector<std::string> supportedNames = {
221 "CHEBYSHEV",
"DENSE",
"LAPACK",
222 #ifdef HAVE_IFPACK2_AMESOS2
225 "DIAGONAL",
"ILUT",
"RELAXATION",
"RILUK",
"RBILUK",
"MDF",
226 #ifdef HAVE_IFPACK2_SHYLU_NODEFASTILU
227 "FAST_IC",
"FAST_ILU",
"FAST_ILU_B",
"FAST_ILDL",
229 "BLOCK_RELAXATION",
"BLOCK RELAXATION",
"BLOCKRELAXATION",
"DENSE_BLOCK_RELAXATION",
"DENSE BLOCK RELAXATION",
"DENSEBLOCKRELAXATION",
231 #ifdef HAVE_IFPACK2_AMESOS2
232 "SPARSE_BLOCK_RELAXATION",
"SPARSE BLOCK RELAXATION",
"SPARSEBLOCKRELAXATION",
234 #ifdef HAVE_IFPACK2_HYPRE
237 "TRIDI_RELAXATION",
"TRIDI RELAXATION",
"TRIDIRELAXATION",
"TRIDIAGONAL_RELAXATION",
"TRIDIAGONAL RELAXATION",
"TRIDIAGONALRELAXATION",
238 "BANDED_RELAXATION",
"BANDED RELAXATION",
"BANDEDRELAXATION",
239 "IDENTITY",
"IDENTITY_SOLVER",
240 "LOCAL SPARSE TRIANGULAR SOLVER",
"LOCAL_SPARSE_TRIANGULAR_SOLVER",
"LOCALSPARSETRIANGULARSOLVER",
"SPARSE TRIANGULAR SOLVER",
"SPARSE_TRIANGULAR_SOLVER",
"SPARSETRIANGULARSOLVER",
245 auto it = std::find(std::begin(supportedNames), std::end(supportedNames), precTypeUpper);
246 return it != std::end(supportedNames);
252 #define IFPACK2_DETAILS_ONELEVELFACTORY_INSTANT(S,LO,GO,N) \
253 template class Ifpack2::Details::OneLevelFactory< Tpetra::RowMatrix<S, LO, GO, N> >;
255 #endif // IFPACK2_DETAILS_ONELEVELFACTORY_DEF_HPP
MDF (incomplete LU factorization with minimum discarded fill reordering) of a Tpetra sparse matrix...
Definition: Ifpack2_MDF_decl.hpp:50
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:53
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ILU(k) factorization of a given Tpetra::RowMatrix.
Definition: Ifpack2_RILUK_decl.hpp:213
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
"Preconditioner" that uses LAPACK's dense LU.
Definition: Ifpack2_Details_DenseSolver_decl.hpp:42
The Ifpack2 wrapper to the ILDL preconditioner of ShyLU FastILU.
Definition: Ifpack2_Details_Fildl_decl.hpp:29
The Ifpack2 wrapper to the ILU preconditioner of ShyLU FastILU.
Definition: Ifpack2_Details_Filu_decl.hpp:29
ILUT (incomplete LU factorization with threshold) of a Tpetra sparse matrix.
Definition: Ifpack2_ILUT_decl.hpp:60
Block relaxation preconditioners (or smoothers) for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse ma...
Definition: Ifpack2_BlockRelaxation_decl.hpp:49
"Identity" preconditioner.
Definition: Ifpack2_IdentitySolver_decl.hpp:27
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Wrapper for Hiptmair smoothers.
Definition: Ifpack2_Hiptmair_decl.hpp:38
Wrapper class for direct solvers in Amesos2.
Definition: Ifpack2_Details_Amesos2Wrapper_decl.hpp:69
"Preconditioner" that solves local sparse triangular systems.
Definition: Ifpack2_LocalSparseTriangularSolver_decl.hpp:46
File for utility functions.
ParameterList & setParameters(const ParameterList &source)
Overlapping Schwarz where redundant patches are not stored explicitly.
Definition: Ifpack2_DatabaseSchwarz_decl.hpp:63
The Ifpack2 wrapper to the incomplete Chebyshev preconditioner of ShyLU FastILU.
Definition: Ifpack2_Details_Fic_decl.hpp:29
"Factory" for creating single-level preconditioners.
Definition: Ifpack2_Details_OneLevelFactory_decl.hpp:92
Relaxation preconditioners for Tpetra::RowMatrix and Tpetra::CrsMatrix sparse matrices.
Definition: Ifpack2_Relaxation_decl.hpp:206
ILU(k) factorization of a given Tpetra::BlockCrsMatrix.
Definition: Ifpack2_Experimental_RBILUK_decl.hpp:95