131 unsigned int max_criteria)
const
133 for (
unsigned int criterion_id = 0; criterion_id < max_criteria; criterion_id++)
136 std::string subsection_text =
137 "linear solver parameters: " + std::to_string(criterion_id);
138 parameter_handler.enter_subsection(subsection_text);
140 parameter_handler.declare_entry(
143 dealii::Patterns::Anything(),
144 "The ids of the solvers that will use these settings.");
145 parameter_handler.declare_entry(
148 dealii::Patterns::Selection(dealii::SolverSelector<>::get_solver_names()),
149 "The type of iterative solver to use for linear solves.");
150 parameter_handler.declare_entry(
153 dealii::Patterns::Selection(
"AbsoluteResidual|RMSEPerField|IntegratedPerField|"
154 "RMSETotal|IntegratedTotal"),
155 "The tolerance type for the linear solver.");
156 parameter_handler.declare_entry(
"tolerance value",
158 dealii::Patterns::Double(DBL_MIN, DBL_MAX),
159 "The value of for the linear solver tolerance.");
160 parameter_handler.declare_entry(
163 dealii::Patterns::Integer(1, INT_MAX),
164 "The maximum number of linear solver iterations before the loop "
166 parameter_handler.declare_entry(
167 "preconditioner type",
169 dealii::Patterns::Selection(
170 "|None|Chebyshev|GMG|none|chebyshev|gmg|MG|mg|multigrid"),
171 "The preconditioner type for the linear solver.");
172 parameter_handler.enter_subsection(
"Chebyshev");
174 parameter_handler.declare_entry(
"smoothing range",
176 dealii::Patterns::Double(DBL_MIN, DBL_MAX),
177 "The smoothing range for eigenvalues.");
178 parameter_handler.declare_entry(
"smoother degree",
180 dealii::Patterns::Integer(1, INT_MAX),
181 "The smoother polynomial degree.");
182 parameter_handler.declare_entry(
183 "eigenvalue cg iterations",
185 dealii::Patterns::Integer(1, INT_MAX),
186 "The maximum number of CG iterations used to find the maximum eigenvalue.");
188 parameter_handler.leave_subsection();
189 parameter_handler.enter_subsection(
"Richardson");
191 parameter_handler.declare_entry(
"omega",
193 dealii::Patterns::Double(),
195 parameter_handler.declare_entry(
"use preconditioned residual",
197 dealii::Patterns::Bool(),
198 "Whether to use the preconditioned residual l2 "
199 "norm in the stopping criterion.");
201 parameter_handler.leave_subsection();
202 parameter_handler.enter_subsection(
"BiCGStab");
204 parameter_handler.declare_entry(
"exact residual",
206 dealii::Patterns::Bool(),
207 "Flag for exact computation of residual.");
208 parameter_handler.declare_entry(
"breakdown",
210 std::numeric_limits<double>::min()),
211 dealii::Patterns::Double(),
212 "Breakdown threshold.");
214 parameter_handler.leave_subsection();
215 parameter_handler.enter_subsection(
"GMRES");
217 parameter_handler.declare_entry(
220 dealii::Patterns::Integer(1, INT_MAX),
221 "The maximum size of the Krylov basis used in GMRES before restarting.");
222 parameter_handler.declare_entry(
223 "orthogonalization strategy",
224 "delayed_classical_gram_schmidt",
225 dealii::Patterns::Selection(
"classical_gram_schmidt|modified_gram_schmidt|"
226 "delayed_classical_gram_schmidt"),
227 "The orthogonalization strategy to use in GMRES.");
228 parameter_handler.declare_entry(
"right preconditioning",
230 dealii::Patterns::Bool(),
231 "Whether to use right preconditioning.");
232 parameter_handler.declare_entry(
233 "use default residual",
235 dealii::Patterns::Bool(),
236 "Whether to use the default residual computation in GMRES.");
237 parameter_handler.declare_entry(
238 "force re-orthogonalization",
240 dealii::Patterns::Bool(),
241 "Whether to force re-orthogonalization of the Krylov basis in GMRES.");
242 parameter_handler.declare_entry(
"batched mode",
244 dealii::Patterns::Bool(),
245 "Whether to use batched mode in GMRES.");
247 parameter_handler.leave_subsection();
249 parameter_handler.declare_entry(
"mg depth",
251 dealii::Patterns::Integer(1, INT_MAX),
252 "The depth of the multigrid hierarchy.");
254 parameter_handler.declare_alias(
"tolerance value",
"tolerance");
255 parameter_handler.declare_alias(
"solver_ids",
"solve blocks");
256 parameter_handler.declare_alias(
"solver_ids",
"solve_blocks");
257 parameter_handler.declare_alias(
"solver_ids",
"solve block ids");
258 parameter_handler.declare_alias(
"solver_ids",
"solve_block_ids");
259 parameter_handler.declare_alias(
"solver type",
"solver_type");
260 parameter_handler.declare_alias(
"solver type",
"linear solver type");
261 parameter_handler.declare_alias(
"solver type",
"linear_solver_type");
262 parameter_handler.declare_alias(
"solver type",
"linear solver");
263 parameter_handler.declare_alias(
"solver type",
"linear_solver");
264 parameter_handler.declare_alias(
"solver type",
"type");
265 parameter_handler.declare_alias(
"preconditioner type",
"preconditioner_type");
266 parameter_handler.declare_alias(
"preconditioner type",
"preconditioner");
267 parameter_handler.declare_alias(
"mg depth",
"mg_depth");
269 parameter_handler.leave_subsection();
275 unsigned int max_criteria)
277 for (
unsigned int criterion_id = 0; criterion_id < max_criteria; criterion_id++)
280 std::string subsection_text =
281 "linear solver parameters: " + std::to_string(criterion_id);
282 parameter_handler.enter_subsection(subsection_text);
284 std::vector<int> solver_ids = dealii::Utilities::string_to_int(
285 dealii::Utilities::split_string_list(parameter_handler.get(
"solver_ids")));
290 linear_solver_parameters.
solver_type = parameter_handler.get(
"solver type");
293 static const std::map<std::string, SolverToleranceType> tolerance_types = {
300 const std::string type_string = parameter_handler.get(
"tolerance type");
301 const auto &iter = tolerance_types.find(type_string);
302 if (iter != tolerance_types.end())
309 dealii::ExcMessage(
"Invalid tolerance type: " + type_string));
314 parameter_handler.get_double(
"tolerance value");
318 static_cast<unsigned int>(parameter_handler.get_integer(
"max iterations"));
321 static const std::map<std::string, PreconditionerType> preconditioner_map = {
334 preconditioner_map.at(parameter_handler.get(
"preconditioner type"));
336 parameter_handler.enter_subsection(
"Chebyshev");
339 static_cast<unsigned int>(parameter_handler.get_integer(
"smoother degree"));
342 parameter_handler.get_double(
"smoothing range");
345 static_cast<unsigned int>(
346 parameter_handler.get_integer(
"eigenvalue cg iterations"));
348 parameter_handler.leave_subsection();
349 parameter_handler.enter_subsection(
"Richardson");
352 parameter_handler.get_double(
"omega");
354 parameter_handler.get_bool(
"use preconditioned residual");
356 parameter_handler.leave_subsection();
357 parameter_handler.enter_subsection(
"BiCGStab");
360 parameter_handler.get_bool(
"exact residual");
362 parameter_handler.get_double(
"breakdown");
364 parameter_handler.leave_subsection();
365 parameter_handler.enter_subsection(
"GMRES");
367 using OStrat = dealii::LinearAlgebra::OrthogonalizationStrategy;
368 static const std::map<std::string, OStrat> orthogonalization_strategy_names = {
369 {
"classical_gram_schmidt", OStrat::classical_gram_schmidt },
370 {
"modified_gram_schmidt", OStrat::modified_gram_schmidt },
371 {
"delayed_classical_gram_schmidt", OStrat::delayed_classical_gram_schmidt}
374 orthogonalization_strategy_names.at(
375 parameter_handler.get(
"orthogonalization strategy"));
377 parameter_handler.get_bool(
"right preconditioning");
379 parameter_handler.get_bool(
"use default residual");
381 parameter_handler.get_bool(
"force re-orthogonalization");
383 parameter_handler.get_bool(
"batched mode");
385 parameter_handler.leave_subsection();
388 static_cast<unsigned int>(parameter_handler.get_integer(
"mg depth"));
389 for (
auto solver_id : solver_ids)
392 linear_solver_parameters;
395 parameter_handler.leave_subsection();