Belos Version of the Day
Loading...
Searching...
No Matches
Belos_Details_EBelosSolverType.cpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Belos: Block Linear Solvers Package
4//
5// Copyright 2004-2016 NTESS and the Belos contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
11#include "Teuchos_ParameterList.hpp"
12
13namespace Belos {
14namespace Details {
15
16std::pair<std::string, bool>
18{
19 // NOTE (mfh 29 Nov 2011) Accessing the flexible capability requires
20 // setting a parameter in the solver's parameter list. This affects
21 // the SolverFactory's interface, since using the "Flexible GMRES"
22 // alias requires modifying the user's parameter list if necessary.
23 // This is a good idea because users may not know about the
24 // parameter, or may have forgotten.
25 //
26 // NOTE (mfh 12 Aug 2015) The keys and values need to be all uppercase.
27
28 if (candidateAlias == "GMRES") {
29 return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
30 }
31 else if (candidateAlias == "BLOCK GMRES") {
32 return std::make_pair (std::string ("BLOCK GMRES"), true);
33 }
34 else if (candidateAlias == "FLEXIBLE GMRES") {
35 return std::make_pair (std::string ("BLOCK GMRES"), true);
36 }
37 else if (candidateAlias == "CG") {
38 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
39 }
40 else if (candidateAlias == "SINGLE-REDUCE CG") {
41 return std::make_pair (std::string ("BLOCK CG"), true);
42 }
43 else if (candidateAlias == "PSEUDOBLOCKCG") {
44 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
45 }
46 else if (candidateAlias == "STOCHASTIC CG") {
47 return std::make_pair (std::string ("PSEUDOBLOCK STOCHASTIC CG"), true);
48 }
49 else if (candidateAlias == "RECYCLING CG") {
50 return std::make_pair (std::string ("RCG"), true);
51 }
52 else if (candidateAlias == "RECYCLING GMRES") {
53 return std::make_pair (std::string ("GCRODR"), true);
54 }
55 // For compatibility with Stratimikos' Belos adapter.
56 else if (candidateAlias == "PSEUDO BLOCK GMRES") {
57 return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
58 }
59 else if (candidateAlias == "PSEUDOBLOCKGMRES") {
60 return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
61 }
62 else if (candidateAlias == "PSEUDO BLOCK CG") {
63 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
64 }
65 else if (candidateAlias == "PSEUDOBLOCKCG") {
66 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
67 }
68 else if (candidateAlias == "TRANSPOSE-FREE QMR") {
69 return std::make_pair (std::string ("TFQMR"), true);
70 }
71 else if (candidateAlias == "PSEUDO BLOCK TFQMR") {
72 return std::make_pair (std::string ("PSEUDOBLOCK TFQMR"), true);
73 }
74 else if (candidateAlias == "PSEUDO BLOCK TRANSPOSE-FREE QMR") {
75 return std::make_pair (std::string ("PSEUDOBLOCK TFQMR"), true);
76 }
77 else if (candidateAlias == "GMRESPOLY") {
78 return std::make_pair (std::string ("HYBRID BLOCK GMRES"), true);
79 }
80 else if (candidateAlias == "SEED GMRES") {
81 return std::make_pair (std::string ("HYBRID BLOCK GMRES"), true);
82 }
83 else if (candidateAlias == "CGPOLY") {
84 return std::make_pair (std::string ("PCPG"), true);
85 }
86 else if (candidateAlias == "SEED CG") {
87 return std::make_pair (std::string ("PCPG"), true);
88 }
89 else if (candidateAlias == "FIXED POINT") {
90 return std::make_pair (std::string ("FIXED POINT"), true);
91 }
92 else if (candidateAlias == "BICGSTAB") {
93 return std::make_pair (std::string ("BICGSTAB"), true);
94 }
95 else { // not a known alias
96 return std::make_pair (candidateAlias, false);
97 }
98}
99
100std::vector<std::string>
102{
103#ifdef HAVE_TEUCHOSCORE_CXX11
104 return {
105 {"GMRES"},
106 {"BLOCK GMRES"},
107 {"FLEXIBLE GMRES"},
108 {"CG"},
109 {"PSEUDOBLOCKCG"},
110 {"STOCHASTIC CG"},
111 {"RECYCLING CG"},
112 {"RECYCLING GMRES"},
113 {"PSEUDO BLOCK GMRES"},
114 {"PSEUDOBLOCKGMRES"},
115 {"PSEUDO BLOCK CG"},
116 {"PSEUDOBLOCKCG"},
117 {"TRANSPOSE-FREE QMR"},
118 {"PSEUDO BLOCK TFQMR"},
119 {"PSEUDO BLOCK TRANSPOSE-FREE QMR"},
120 {"GMRESPOLY"},
121 {"SEED GMRES"},
122 {"CGPOLY"},
123 {"SEED CG"},
124 {"FIXED POINT"},
125 {"BICGSTAB"}
126 };
127#else // NOT HAVE_TEUCHOSCORE_CXX11
128 std::vector<std::string> names;
129
130 names.push_back ("GMRES");
131 names.push_back ("BLOCK GMRES");
132 names.push_back ("FLEXIBLE GMRES");
133 names.push_back ("CG");
134 names.push_back ("PSEUDOBLOCKCG");
135 names.push_back ("STOCHASTIC CG");
136 names.push_back ("RECYCLING CG");
137 names.push_back ("RECYCLING GMRES");
138 names.push_back ("PSEUDO BLOCK GMRES");
139 names.push_back ("PSEUDOBLOCKGMRES");
140 names.push_back ("PSEUDO BLOCK CG");
141 names.push_back ("PSEUDOBLOCKCG");
142 names.push_back ("TRANSPOSE-FREE QMR");
143 names.push_back ("PSEUDO BLOCK TFQMR");
144 names.push_back ("PSEUDO BLOCK TRANSPOSE-FREE QMR");
145 names.push_back ("GMRESPOLY");
146 names.push_back ("SEED GMRES");
147 names.push_back ("CGPOLY");
148 names.push_back ("SEED CG");
149 names.push_back ("FIXED POINT");
150 names.push_back ("BICGSTAB");
151
152 return names;
153#endif // HAVE_TEUCHOSCORE_CXX11
154}
155
156std::vector<std::string>
158{
159 return {
160 {"BLOCK GMRES"},
161 {"PSEUDOBLOCK GMRES"},
162 {"BLOCK CG"},
163 {"PSEUDOBLOCK CG"},
164 {"PSEUDOBLOCK STOCHASTIC CG"},
165 {"GCRODR"},
166 {"RCG"},
167 {"MINRES"},
168 {"LSQR"},
169 {"TFQMR"},
170 {"PSEUDOBLOCK TFQMR"},
171 {"HYBRID BLOCK GMRES"},
172 {"PCPG"},
173 {"FIXED POINT"},
174 {"BICGSTAB"}
175 };
176}
177
178// TODO: Keep this method with new DII system?
180 return static_cast<int> (canonicalSolverNames().size());
181}
182
183void
185 Teuchos::ParameterList& solverParams)
186{
187 if (aliasName == "FLEXIBLE GMRES") {
188 // "Gmres" uses title case in this solver's parameter list. For
189 // our alias, we prefer the all-capitals "GMRES" that the
190 // algorithm's authors (Saad and Schultz) used.
191 solverParams.set ("Flexible Gmres", true);
192 } else if (aliasName == "SINGLE-REDUCE CG") {
193 solverParams.set ("Use Single Reduction", true);
194 }
195}
196
197} // namespace Details
198} // namespace Belos
Declaration of alias functions for solver names.
Alternative run-time polymorphic interface for operators.
std::pair< std::string, bool > getCanonicalNameFromAlias(const std::string &candidateAlias)
Get the candidate canonical name for a given candidate alias.
void reviseParameterListForAlias(const std::string &aliasName, Teuchos::ParameterList &solverParams)
Modify the input ParameterList appropriately for the given solver alias.
std::vector< std::string > solverNameAliases()
List of supported aliases (to canonical solver names).
int numSupportedSolvers()
Number of Belos solvers supported for any linear algebra implementation ("generically").
std::vector< std::string > canonicalSolverNames()
List of canonical solver names.

Generated for Belos by doxygen 1.9.8