10#ifdef MOOSE_MFEM_ENABLED
22 mfem::NewtonSolver::SetOperator(op);
33 mfem::real_t contraction_factor,
34 mfem::real_t sufficient_decrease)
48 const auto have_b = (b.Size() == Height());
49 const auto norm = Norm(r);
60 if (print_options.iterations)
61 mfem::out <<
"Newton line search iteration " << it <<
" : damping factor = " <<
scale
62 <<
", ||r|| = " << trial_norm <<
'\n';
72 if (print_options.warnings)
73 mfem::out <<
"Newton line search: no trial step satisfied the sufficient decrease "
86 MooseEnum line_search(
"none backtracking",
"none");
88 "line_search", line_search,
"Line search used to shorten the Newton update.");
92 "damping_factor > 0 & damping_factor <= 1",
93 "Fraction of the full Newton update applied on each "
94 "nonlinear iteration, and the first trial step taken when "
95 "'line_search' is 'backtracking'.");
97 "line_search_max_its",
99 "line_search_max_its > 0",
100 "Maximum number of trial steps taken by the backtracking line search.");
102 "line_search_contraction_factor",
104 "line_search_contraction_factor > 0 & line_search_contraction_factor < 1",
105 "Factor a rejected backtracking trial step is multiplied by to obtain the next one.");
107 "line_search_sufficient_decrease",
109 "line_search_sufficient_decrease >= 0 & line_search_sufficient_decrease < 1",
110 "Coefficient of the sufficient decrease condition the backtracking line search requires "
111 "of the residual norm.");
116 :
Moose::MFEM::NonlinearSolverBase(parameters)
124 auto solver = std::make_unique<Moose::MFEM::DampedNewtonSolver>(
getMFEMProblem().getComm());
125 solver->iterative_mode = getParam<bool>(
"use_initial_guess");
126 solver->SetRelTol(getParam<mfem::real_t>(
"rel_tol"));
127 solver->SetAbsTol(getParam<mfem::real_t>(
"abs_tol"));
128 solver->SetMaxIter(getParam<unsigned int>(
"max_its"));
129 solver->SetPrintLevel(getParam<unsigned int>(
"print_level"));
130 solver->SetDampingFactor(getParam<mfem::real_t>(
"damping_factor"));
132 if (getParam<MooseEnum>(
"line_search") ==
"backtracking")
133 solver->SetBacktracking(getParam<unsigned int>(
"line_search_max_its"),
134 getParam<mfem::real_t>(
"line_search_contraction_factor"),
135 getParam<mfem::real_t>(
"line_search_sufficient_decrease"));
137 for (
const auto & param : {
"line_search_max_its",
138 "line_search_contraction_factor",
139 "line_search_sufficient_decrease"})
141 paramError(param,
"Only used when 'line_search' is set to 'backtracking'.");
149 cast_ref<mfem::NewtonSolver &>(
GetSolver()).SetSolver(solver);
registerMooseObject("MooseApp", MFEMNewtonNonlinearSolver)
MooseObject wrapper for mfem::NewtonSolver-backed nonlinear solves.
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
void SetLinearSolver(mfem::Solver &solver) override
Configure the linear solver used inside the nonlinear solve.
MFEMNewtonNonlinearSolver(const InputParameters ¶meters)
static InputParameters validParams()
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
mfem::real_t ComputeScalingFactor(const mfem::Vector &x, const mfem::Vector &b) const override
Return the fraction of the Newton update to apply at the iterate x.
unsigned int _ls_max_its
Maximum number of trial steps taken by the line search; 0 disables backtracking.
mfem::Vector _ls_x_trial
Trial iterate x - t c evaluated by the line search.
void SetBacktracking(unsigned int max_its, mfem::real_t contraction_factor, mfem::real_t sufficient_decrease)
Enable a backtracking line search taking at most max_its trial steps, each a factor contraction_facto...
mfem::real_t _ls_sufficient_decrease
Coefficient of the sufficient decrease (Armijo) condition on the residual norm.
void SetOperator(const mfem::Operator &op) override
mfem::real_t _ls_contraction_factor
Factor a rejected trial step is multiplied by to obtain the next one.
mfem::real_t _damping_factor
Fraction of the full Newton update applied, and the line search's initial trial step.
mfem::Vector _ls_r_trial
Residual at the trial iterate.
static InputParameters validParams()
mfem::Solver & GetSolver()
Returns the wrapped MFEM solver.
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...