PRISMS-PF Manual
Loading...
Searching...
No Matches
nonlinear_solve_parameters.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2025 PRISMS Center at the University of Michigan
2// SPDX-License-Identifier: GNU Lesser General Public Version 2.1
3
4#pragma once
5
7
9
10#include <prismspf/config.h>
11
13
18{
19 // Nonlinear step length
20 mutable double step_length = 1.0;
21
22 // Max number of iterations for the nonlinear solve
24
25 // Tolerance value for the nonlinear solve
27};
28
33{
37 void
38 validate();
39
43 void
45
46 // Map of nonlinear solve parameters for fields that require them
47 std::map<Types::Index, NonlinearSolverParameters> newton_solvers;
48};
49
50inline void
52{
53 for (const auto &[index, nonlinear_solver_parameters] : newton_solvers)
54 {
56 nonlinear_solver_parameters.step_length > 0.0 &&
57 nonlinear_solver_parameters.step_length <= 1.0,
58 dealii::ExcMessage(
59 "Step length must be greater than 0.0 and less than or equal to 1.0"));
60
61 AssertThrow(nonlinear_solver_parameters.tolerance_value > 0,
62 dealii::ExcMessage("Tolerance must be greater than 0.0"));
63 }
64}
65
66inline void
68{
69 if (!newton_solvers.empty())
70 {
72 << "================================================\n"
73 << " Nonlinear Solve Parameters\n"
74 << "================================================\n";
75
76 for (const auto &[index, nonlinear_solver_parameters] : newton_solvers)
77 {
79 << "Index: " << index << "\n"
80 << " Max iterations: " << nonlinear_solver_parameters.max_iterations << "\n"
81 << " Step length: " << nonlinear_solver_parameters.step_length << "\n";
82 }
83
84 ConditionalOStreams::pout_summary() << "\n" << std::flush;
85 }
86}
87
static dealii::ConditionalOStream & pout_summary()
Log output stream for writing a summary.log file.
Definition conditional_ostreams.cc:34
@ Value
Use value of the variable as a criterion for refinement.
Definition grid_refiner_criterion.h:31
static const unsigned int iterations
Default iterations.
Definition types.h:67
static const double tolerance
Default tolerance.
Definition types.h:57
Definition conditional_ostreams.cc:20
Struct that holds nonlinear solver parameters.
Definition nonlinear_solve_parameters.h:33
void validate()
Validate parameters.
Definition nonlinear_solve_parameters.h:51
std::map< Types::Index, NonlinearSolverParameters > newton_solvers
Definition nonlinear_solve_parameters.h:47
void print_parameter_summary() const
Print parameters to summary.log.
Definition nonlinear_solve_parameters.h:67
Struct that stores relevant nonlinear solve information of a certain field.
Definition nonlinear_solve_parameters.h:18
double step_length
Definition nonlinear_solve_parameters.h:20
double tolerance_value
Definition nonlinear_solve_parameters.h:26
unsigned int max_iterations
Definition nonlinear_solve_parameters.h:23