Belos Version of the Day
Loading...
Searching...
No Matches
Belos_Details_EBelosSolverType.cpp
Go to the documentation of this file.
1//@HEADER
2// ************************************************************************
3//
4// Belos: Block Linear Solvers Package
5// Copyright 2004 Sandia Corporation
6//
7// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8// the U.S. Government retains certain rights in this software.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ************************************************************************
40//@HEADER
41
43#include "Teuchos_ParameterList.hpp"
44
45namespace Belos {
46namespace Details {
47
48std::pair<std::string, bool>
49getCanonicalNameFromAlias (const std::string& candidateAlias)
50{
51 // NOTE (mfh 29 Nov 2011) Accessing the flexible capability requires
52 // setting a parameter in the solver's parameter list. This affects
53 // the SolverFactory's interface, since using the "Flexible GMRES"
54 // alias requires modifying the user's parameter list if necessary.
55 // This is a good idea because users may not know about the
56 // parameter, or may have forgotten.
57 //
58 // NOTE (mfh 12 Aug 2015) The keys and values need to be all uppercase.
59
60 if (candidateAlias == "GMRES") {
61 return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
62 }
63 else if (candidateAlias == "BLOCK GMRES") {
64 return std::make_pair (std::string ("BLOCK GMRES"), true);
65 }
66 else if (candidateAlias == "FLEXIBLE GMRES") {
67 return std::make_pair (std::string ("BLOCK GMRES"), true);
68 }
69 else if (candidateAlias == "CG") {
70 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
71 }
72 else if (candidateAlias == "PSEUDOBLOCKCG") {
73 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
74 }
75 else if (candidateAlias == "STOCHASTIC CG") {
76 return std::make_pair (std::string ("PSEUDOBLOCK STOCHASTIC CG"), true);
77 }
78 else if (candidateAlias == "RECYCLING CG") {
79 return std::make_pair (std::string ("RCG"), true);
80 }
81 else if (candidateAlias == "RECYCLING GMRES") {
82 return std::make_pair (std::string ("GCRODR"), true);
83 }
84 // For compatibility with Stratimikos' Belos adapter.
85 else if (candidateAlias == "PSEUDO BLOCK GMRES") {
86 return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
87 }
88 else if (candidateAlias == "PSEUDOBLOCKGMRES") {
89 return std::make_pair (std::string ("PSEUDOBLOCK GMRES"), true);
90 }
91 else if (candidateAlias == "PSEUDO BLOCK CG") {
92 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
93 }
94 else if (candidateAlias == "PSEUDOBLOCKCG") {
95 return std::make_pair (std::string ("PSEUDOBLOCK CG"), true);
96 }
97 else if (candidateAlias == "TRANSPOSE-FREE QMR") {
98 return std::make_pair (std::string ("TFQMR"), true);
99 }
100 else if (candidateAlias == "PSEUDO BLOCK TFQMR") {
101 return std::make_pair (std::string ("PSEUDOBLOCK TFQMR"), true);
102 }
103 else if (candidateAlias == "PSEUDO BLOCK TRANSPOSE-FREE QMR") {
104 return std::make_pair (std::string ("PSEUDOBLOCK TFQMR"), true);
105 }
106 else if (candidateAlias == "GMRESPOLY") {
107 return std::make_pair (std::string ("HYBRID BLOCK GMRES"), true);
108 }
109 else if (candidateAlias == "SEED GMRES") {
110 return std::make_pair (std::string ("HYBRID BLOCK GMRES"), true);
111 }
112 else if (candidateAlias == "CGPOLY") {
113 return std::make_pair (std::string ("PCPG"), true);
114 }
115 else if (candidateAlias == "SEED CG") {
116 return std::make_pair (std::string ("PCPG"), true);
117 }
118 else if (candidateAlias == "FIXED POINT") {
119 return std::make_pair (std::string ("FIXED POINT"), true);
120 }
121 else if (candidateAlias == "BICGSTAB") {
122 return std::make_pair (std::string ("BICGSTAB"), true);
123 }
124 else { // not a known alias
125 return std::make_pair (candidateAlias, false);
126 }
127}
128
129std::vector<std::string>
131{
132#ifdef HAVE_TEUCHOSCORE_CXX11
133 return {
134 {"GMRES"},
135 {"BLOCK GMRES"},
136 {"FLEXIBLE GMRES"},
137 {"CG"},
138 {"PSEUDOBLOCKCG"},
139 {"STOCHASTIC CG"},
140 {"RECYCLING CG"},
141 {"RECYCLING GMRES"},
142 {"PSEUDO BLOCK GMRES"},
143 {"PSEUDOBLOCKGMRES"},
144 {"PSEUDO BLOCK CG"},
145 {"PSEUDOBLOCKCG"},
146 {"TRANSPOSE-FREE QMR"},
147 {"PSEUDO BLOCK TFQMR"},
148 {"PSEUDO BLOCK TRANSPOSE-FREE QMR"},
149 {"GMRESPOLY"},
150 {"SEED GMRES"},
151 {"CGPOLY"},
152 {"SEED CG"},
153 {"FIXED POINT"},
154 {"BICGSTAB"}
155 };
156#else // NOT HAVE_TEUCHOSCORE_CXX11
157 std::vector<std::string> names;
158
159 names.push_back ("GMRES");
160 names.push_back ("BLOCK GMRES");
161 names.push_back ("FLEXIBLE GMRES");
162 names.push_back ("CG");
163 names.push_back ("PSEUDOBLOCKCG");
164 names.push_back ("STOCHASTIC CG");
165 names.push_back ("RECYCLING CG");
166 names.push_back ("RECYCLING GMRES");
167 names.push_back ("PSEUDO BLOCK GMRES");
168 names.push_back ("PSEUDOBLOCKGMRES");
169 names.push_back ("PSEUDO BLOCK CG");
170 names.push_back ("PSEUDOBLOCKCG");
171 names.push_back ("TRANSPOSE-FREE QMR");
172 names.push_back ("PSEUDO BLOCK TFQMR");
173 names.push_back ("PSEUDO BLOCK TRANSPOSE-FREE QMR");
174 names.push_back ("GMRESPOLY");
175 names.push_back ("SEED GMRES");
176 names.push_back ("CGPOLY");
177 names.push_back ("SEED CG");
178 names.push_back ("FIXED POINT");
179 names.push_back ("BICGSTAB");
180
181 return names;
182#endif // HAVE_TEUCHOSCORE_CXX11
183}
184
185std::vector<std::string>
187{
188 return {
189 {"BLOCK GMRES"},
190 {"PSEUDOBLOCK GMRES"},
191 {"BLOCK CG"},
192 {"PSEUDOBLOCK CG"},
193 {"PSEUDOBLOCK STOCHASTIC CG"},
194 {"GCRODR"},
195 {"RCG"},
196 {"MINRES"},
197 {"LSQR"},
198 {"TFQMR"},
199 {"PSEUDOBLOCK TFQMR"},
200 {"HYBRID BLOCK GMRES"},
201 {"PCPG"},
202 {"FIXED POINT"},
203 {"BICGSTAB"}
204 };
205}
206
207// TODO: Keep this method with new DII system?
209 return static_cast<int> (canonicalSolverNames().size());
210}
211
212void
213reviseParameterListForAlias (const std::string& aliasName,
214 Teuchos::ParameterList& solverParams)
215{
216 if (aliasName == "FLEXIBLE GMRES") {
217 // "Gmres" uses title case in this solver's parameter list. For
218 // our alias, we prefer the all-capitals "GMRES" that the
219 // algorithm's authors (Saad and Schultz) used.
220 solverParams.set ("Flexible Gmres", true);
221 }
222}
223
224} // namespace Details
225} // namespace Belos
226
Declaration of alias functions for solver names.
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.6