Belos  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
12 
13 namespace Belos {
14 namespace Details {
15 
16 std::pair<std::string, bool>
17 getCanonicalNameFromAlias (const std::string& candidateAlias)
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 == "PSEUDOBLOCKCG") {
41  return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
42  }
43  else if (candidateAlias == "STOCHASTIC CG") {
44  return std::make_pair (std::string ("PSEUDOBLOCK STOCHASTIC CG"), true);
45  }
46  else if (candidateAlias == "RECYCLING CG") {
47  return std::make_pair (std::string ("RCG"), true);
48  }
49  else if (candidateAlias == "RECYCLING GMRES") {
50  return std::make_pair (std::string ("GCRODR"), true);
51  }
52  // For compatibility with Stratimikos' Belos adapter.
53  else if (candidateAlias == "PSEUDO BLOCK GMRES") {
54  return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
55  }
56  else if (candidateAlias == "PSEUDOBLOCKGMRES") {
57  return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
58  }
59  else if (candidateAlias == "PSEUDO BLOCK CG") {
60  return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
61  }
62  else if (candidateAlias == "PSEUDOBLOCKCG") {
63  return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
64  }
65  else if (candidateAlias == "TRANSPOSE-FREE QMR") {
66  return std::make_pair (std::string ("TFQMR"), true);
67  }
68  else if (candidateAlias == "PSEUDO BLOCK TFQMR") {
69  return std::make_pair (std::string ("PSEUDOBLOCK TFQMR"), true);
70  }
71  else if (candidateAlias == "PSEUDO BLOCK TRANSPOSE-FREE QMR") {
72  return std::make_pair (std::string ("PSEUDOBLOCK TFQMR"), true);
73  }
74  else if (candidateAlias == "GMRESPOLY") {
75  return std::make_pair (std::string ("HYBRID BLOCK GMRES"), true);
76  }
77  else if (candidateAlias == "SEED GMRES") {
78  return std::make_pair (std::string ("HYBRID BLOCK GMRES"), true);
79  }
80  else if (candidateAlias == "CGPOLY") {
81  return std::make_pair (std::string ("PCPG"), true);
82  }
83  else if (candidateAlias == "SEED CG") {
84  return std::make_pair (std::string ("PCPG"), true);
85  }
86  else if (candidateAlias == "FIXED POINT") {
87  return std::make_pair (std::string ("FIXED POINT"), true);
88  }
89  else if (candidateAlias == "BICGSTAB") {
90  return std::make_pair (std::string ("BICGSTAB"), true);
91  }
92  else { // not a known alias
93  return std::make_pair (candidateAlias, false);
94  }
95 }
96 
97 std::vector<std::string>
99 {
100 #ifdef HAVE_TEUCHOSCORE_CXX11
101  return {
102  {"GMRES"},
103  {"BLOCK GMRES"},
104  {"FLEXIBLE GMRES"},
105  {"CG"},
106  {"PSEUDOBLOCKCG"},
107  {"STOCHASTIC CG"},
108  {"RECYCLING CG"},
109  {"RECYCLING GMRES"},
110  {"PSEUDO BLOCK GMRES"},
111  {"PSEUDOBLOCKGMRES"},
112  {"PSEUDO BLOCK CG"},
113  {"PSEUDOBLOCKCG"},
114  {"TRANSPOSE-FREE QMR"},
115  {"PSEUDO BLOCK TFQMR"},
116  {"PSEUDO BLOCK TRANSPOSE-FREE QMR"},
117  {"GMRESPOLY"},
118  {"SEED GMRES"},
119  {"CGPOLY"},
120  {"SEED CG"},
121  {"FIXED POINT"},
122  {"BICGSTAB"}
123  };
124 #else // NOT HAVE_TEUCHOSCORE_CXX11
125  std::vector<std::string> names;
126 
127  names.push_back ("GMRES");
128  names.push_back ("BLOCK GMRES");
129  names.push_back ("FLEXIBLE GMRES");
130  names.push_back ("CG");
131  names.push_back ("PSEUDOBLOCKCG");
132  names.push_back ("STOCHASTIC CG");
133  names.push_back ("RECYCLING CG");
134  names.push_back ("RECYCLING GMRES");
135  names.push_back ("PSEUDO BLOCK GMRES");
136  names.push_back ("PSEUDOBLOCKGMRES");
137  names.push_back ("PSEUDO BLOCK CG");
138  names.push_back ("PSEUDOBLOCKCG");
139  names.push_back ("TRANSPOSE-FREE QMR");
140  names.push_back ("PSEUDO BLOCK TFQMR");
141  names.push_back ("PSEUDO BLOCK TRANSPOSE-FREE QMR");
142  names.push_back ("GMRESPOLY");
143  names.push_back ("SEED GMRES");
144  names.push_back ("CGPOLY");
145  names.push_back ("SEED CG");
146  names.push_back ("FIXED POINT");
147  names.push_back ("BICGSTAB");
148 
149  return names;
150 #endif // HAVE_TEUCHOSCORE_CXX11
151 }
152 
153 std::vector<std::string>
155 {
156  return {
157  {"BLOCK GMRES"},
158  {"PSEUDOBLOCK GMRES"},
159  {"BLOCK CG"},
160  {"PSEUDOBLOCK CG"},
161  {"PSEUDOBLOCK STOCHASTIC CG"},
162  {"GCRODR"},
163  {"RCG"},
164  {"MINRES"},
165  {"LSQR"},
166  {"TFQMR"},
167  {"PSEUDOBLOCK TFQMR"},
168  {"HYBRID BLOCK GMRES"},
169  {"PCPG"},
170  {"FIXED POINT"},
171  {"BICGSTAB"}
172  };
173 }
174 
175 // TODO: Keep this method with new DII system?
177  return static_cast<int> (canonicalSolverNames().size());
178 }
179 
180 void
181 reviseParameterListForAlias (const std::string& aliasName,
182  Teuchos::ParameterList& solverParams)
183 {
184  if (aliasName == "FLEXIBLE GMRES") {
185  // "Gmres" uses title case in this solver's parameter list. For
186  // our alias, we prefer the all-capitals "GMRES" that the
187  // algorithm's authors (Saad and Schultz) used.
188  solverParams.set ("Flexible Gmres", true);
189  }
190 }
191 
192 } // namespace Details
193 } // namespace Belos
194 
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Declaration of alias functions for solver names.
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 (&quot;generically&quot;).
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 > canonicalSolverNames()
List of canonical solver names.

Generated on Mon Jul 15 2024 09:24:23 for Belos by doxygen 1.8.5