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(
"preconditioner type",
168 dealii::Patterns::Selection(
"None|Chebyshev"),
169 "The preconditioner type for the linear solver.");
170 parameter_handler.enter_subsection(
"Chebyshev");
172 parameter_handler.declare_entry(
"smoothing range",
174 dealii::Patterns::Double(DBL_MIN, DBL_MAX),
175 "The smoothing range for eigenvalues.");
176 parameter_handler.declare_entry(
"smoother degree",
178 dealii::Patterns::Integer(1, INT_MAX),
179 "The smoother polynomial degree.");
180 parameter_handler.declare_entry(
181 "eigenvalue cg iterations",
183 dealii::Patterns::Integer(1, INT_MAX),
184 "The maximum number of CG iterations used to find the maximum eigenvalue.");
186 parameter_handler.leave_subsection();
188 parameter_handler.enter_subsection(
"Richardson");
190 parameter_handler.declare_entry(
"omega",
192 dealii::Patterns::Double(),
194 parameter_handler.declare_entry(
"use preconditioned residual",
196 dealii::Patterns::Bool(),
197 "Whether to use the preconditioned residual l2 "
198 "norm in the stopping criterion.");
200 parameter_handler.leave_subsection();
201 parameter_handler.enter_subsection(
"BiCGStab");
203 parameter_handler.declare_entry(
"exact residual",
205 dealii::Patterns::Bool(),
206 "Flag for exact computation of residual.");
207 parameter_handler.declare_entry(
"breakdown",
209 std::numeric_limits<double>::min()),
210 dealii::Patterns::Double(),
211 "Breakdown threshold.");
213 parameter_handler.leave_subsection();
214 parameter_handler.enter_subsection(
"GMRES");
216 parameter_handler.declare_entry(
219 dealii::Patterns::Integer(1, INT_MAX),
220 "The maximum size of the Krylov basis used in GMRES before restarting.");
221 parameter_handler.declare_entry(
222 "orthogonalization strategy",
223 "delayed_classical_gram_schmidt",
224 dealii::Patterns::Selection(
"classical_gram_schmidt|modified_gram_schmidt|"
225 "delayed_classical_gram_schmidt"),
226 "The orthogonalization strategy to use in GMRES.");
227 parameter_handler.declare_entry(
"right preconditioning",
229 dealii::Patterns::Bool(),
230 "Whether to use right preconditioning.");
231 parameter_handler.declare_entry(
232 "use default residual",
234 dealii::Patterns::Bool(),
235 "Whether to use the default residual computation in GMRES.");
236 parameter_handler.declare_entry(
237 "force re-orthogonalization",
239 dealii::Patterns::Bool(),
240 "Whether to force re-orthogonalization of the Krylov basis in GMRES.");
241 parameter_handler.declare_entry(
"batched mode",
243 dealii::Patterns::Bool(),
244 "Whether to use batched mode in GMRES.");
246 parameter_handler.leave_subsection();
248 parameter_handler.declare_entry(
"min mg level",
250 dealii::Patterns::Integer(0, INT_MAX),
251 "The minimum multigrid level.");
252 parameter_handler.declare_alias(
"tolerance value",
"tolerance");
253 parameter_handler.declare_alias(
"solver_ids",
"solve blocks");
254 parameter_handler.declare_alias(
"solver_ids",
"solve_blocks");
255 parameter_handler.declare_alias(
"solver_ids",
"solve block ids");
256 parameter_handler.declare_alias(
"solver_ids",
"solve_block_ids");
257 parameter_handler.declare_alias(
"solver type",
"solver_type");
258 parameter_handler.declare_alias(
"solver type",
"linear solver type");
259 parameter_handler.declare_alias(
"solver type",
"linear_solver_type");
260 parameter_handler.declare_alias(
"solver type",
"linear solver");
261 parameter_handler.declare_alias(
"solver type",
"linear_solver");
262 parameter_handler.declare_alias(
"solver type",
"type");
263 parameter_handler.declare_alias(
"preconditioner type",
"preconditioner_type");
264 parameter_handler.declare_alias(
"preconditioner type",
"preconditioner");
266 parameter_handler.leave_subsection();
272 unsigned int max_criteria)
274 for (
unsigned int criterion_id = 0; criterion_id < max_criteria; criterion_id++)
277 std::string subsection_text =
278 "linear solver parameters: " + std::to_string(criterion_id);
279 parameter_handler.enter_subsection(subsection_text);
281 std::vector<int> solver_ids = dealii::Utilities::string_to_int(
282 dealii::Utilities::split_string_list(parameter_handler.get(
"solver_ids")));
287 linear_solver_parameters.
solver_type = parameter_handler.get(
"solver type");
290 static const std::map<std::string, SolverToleranceType> tolerance_types = {
297 const std::string type_string = parameter_handler.get(
"tolerance type");
298 const auto &iter = tolerance_types.find(type_string);
299 if (iter != tolerance_types.end())
306 dealii::ExcMessage(
"Invalid tolerance type: " + type_string));
311 parameter_handler.get_double(
"tolerance value");
315 static_cast<unsigned int>(parameter_handler.get_integer(
"max iterations"));
318 static const std::map<std::string, PreconditionerType> preconditioner_map = {
328 preconditioner_map.at(parameter_handler.get(
"preconditioner type"));
330 parameter_handler.enter_subsection(
"Chebyshev");
333 static_cast<unsigned int>(parameter_handler.get_integer(
"smoother degree"));
336 parameter_handler.get_double(
"smoothing range");
339 static_cast<unsigned int>(
340 parameter_handler.get_integer(
"eigenvalue cg iterations"));
342 parameter_handler.leave_subsection();
343 parameter_handler.enter_subsection(
"Richardson");
346 parameter_handler.get_double(
"omega");
348 parameter_handler.get_bool(
"use preconditioned residual");
350 parameter_handler.leave_subsection();
351 parameter_handler.enter_subsection(
"BiCGStab");
354 parameter_handler.get_bool(
"exact residual");
356 parameter_handler.get_double(
"breakdown");
358 parameter_handler.leave_subsection();
359 parameter_handler.enter_subsection(
"GMRES");
361 using OStrat = dealii::LinearAlgebra::OrthogonalizationStrategy;
362 static const std::map<std::string, OStrat> orthogonalization_strategy_names = {
363 {
"classical_gram_schmidt", OStrat::classical_gram_schmidt },
364 {
"modified_gram_schmidt", OStrat::modified_gram_schmidt },
365 {
"delayed_classical_gram_schmidt", OStrat::delayed_classical_gram_schmidt}
368 orthogonalization_strategy_names.at(
369 parameter_handler.get(
"orthogonalization strategy"));
371 parameter_handler.get_bool(
"right preconditioning");
373 parameter_handler.get_bool(
"use default residual");
375 parameter_handler.get_bool(
"force re-orthogonalization");
377 parameter_handler.get_bool(
"batched mode");
379 parameter_handler.leave_subsection();
382 static_cast<unsigned int>(parameter_handler.get_integer(
"min mg level"));
383 for (
auto solver_id : solver_ids)
386 linear_solver_parameters;
389 parameter_handler.leave_subsection();