36 auto const anderson_config =
39 int anderson_depth = 0;
44 anderson_config->getConfigParameter<
int>(
"depth");
46 if (anderson_depth < 0)
49 "Anderson acceleration depth must be non-negative, got "
56 "Anderson acceleration with a depth of {:d} has no effect: "
57 "mixing fewer than {:d} stored steps reproduces the plain "
58 "Picard update. Use a depth >= {:d} to accelerate, or drop "
59 "the <anderson> subtree to disable the acceleration "
65 if (damping <= 0.0 || damping > 1.0)
68 "The damping factor for the Picard method must be in (0, 1], "
75 return std::make_pair(
76 std::make_unique<ConcreteNLS>(linear_solver, max_iter,
77 anderson_depth, damping),
82 auto const recompute_jacobian =
91 "The damping factor for the Newton method must be positive, "
96 auto const damping_reduction =
99 std::unique_ptr<NewtonStepStrategy> standard_newton;
100 if (damping_reduction)
102 standard_newton = std::make_unique<DampingReductionStrategy>(
103 damping, *damping_reduction);
107 standard_newton = std::make_unique<FixedDampingStrategy>(damping);
111 auto solver = std::make_unique<ConcreteNLS>(linear_solver, max_iter,
112 std::move(standard_newton),
114 auto const tikhonov_config =
119 auto const tikhonov_lambda =
121 tikhonov_config->getConfigParameter<
double>(
"lambda");
122 auto const tikhonov_starting_iteration =
124 tikhonov_config->getConfigParameter<
int>(
"starting_iteration",
126 solver->setTikhonovLambda(tikhonov_lambda,
127 tikhonov_starting_iteration);
128 DBUG(
"Newton solver: Tikhonov regularization lambda = {:g}",
131 return std::make_pair(std::move(solver), tag);
134 if (boost::iequals(type,
"PETScSNES"))
141 return std::make_pair(std::make_unique<ConcreteNLS>(
142 linear_solver, max_iter, std::move(prefix)),
145 static constexpr std::array valid_types = {
"PETScSNES",
"Newton",
"Picard"};
147 static constexpr std::array valid_types = {
"Newton",
"Picard"};
150 OGS_FATAL(
"Invalid non-linear solver type '{}'. Supported values: {}.",
151 type, fmt::join(valid_types,
", "));