https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
Moose::MFEM::DampedNewtonSolver Class Reference

mfem::NewtonSolver applying a constant damping factor to the Newton update, optionally shortening it further with a backtracking line search on the residual norm. More...

#include <MFEMNewtonNonlinearSolver.h>

Inheritance diagram for Moose::MFEM::DampedNewtonSolver:
[legend]

Public Member Functions

 DampedNewtonSolver (MPI_Comm comm)
 
void SetOperator (const mfem::Operator &op) override
 
void SetDampingFactor (mfem::real_t damping_factor)
 Set the fraction of the full Newton update applied.
 
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_factor shorter than the last, accepting the first whose residual norm satisfies the sufficient decrease condition with coefficient sufficient_decrease.
 
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.
 

Protected Attributes

mfem::real_t _damping_factor = 1.0
 Fraction of the full Newton update applied, and the line search's initial trial step.
 
unsigned int _ls_max_its = 0
 Maximum number of trial steps taken by the line search; 0 disables backtracking.
 
mfem::real_t _ls_contraction_factor = 0.5
 Factor a rejected trial step is multiplied by to obtain the next one.
 
mfem::real_t _ls_sufficient_decrease = 1.0e-4
 Coefficient of the sufficient decrease (Armijo) condition on the residual norm.
 
mfem::Vector _ls_x_trial
 Trial iterate x - t c evaluated by the line search.
 
mfem::Vector _ls_r_trial
 Residual at the trial iterate.
 

Detailed Description

mfem::NewtonSolver applying a constant damping factor to the Newton update, optionally shortening it further with a backtracking line search on the residual norm.

Definition at line 22 of file MFEMNewtonNonlinearSolver.h.

Constructor & Destructor Documentation

◆ DampedNewtonSolver()

Moose::MFEM::DampedNewtonSolver::DampedNewtonSolver ( MPI_Comm  comm)
inline

Definition at line 25 of file MFEMNewtonNonlinearSolver.h.

25: mfem::NewtonSolver(comm) {}

Member Function Documentation

◆ ComputeScalingFactor()

mfem::real_t Moose::MFEM::DampedNewtonSolver::ComputeScalingFactor ( const mfem::Vector &  x,
const mfem::Vector &  b 
) const
override

Return the fraction of the Newton update to apply at the iterate x.

Without backtracking this is the constant damping factor. With backtracking it is the first trial step t, starting from the damping factor, satisfying ||F(x - t c) - b|| <= (1 - sufficient_decrease * t) * ||F(x) - b||, or 0 if no trial step satisfies it, which interrupts the Newton iteration.

Definition at line 42 of file MFEMNewtonNonlinearSolver.C.

43{
44 if (_ls_max_its == 0)
45 return _damping_factor;
46
47 // NewtonSolver::Mult leaves the residual F(x) - b in r and the Newton update in c.
48 const auto have_b = (b.Size() == Height());
49 const auto norm = Norm(r);
50
52 for (const auto it : make_range(_ls_max_its))
53 {
54 add(x, -scale, c, _ls_x_trial);
55 oper->Mult(_ls_x_trial, _ls_r_trial);
56 if (have_b)
57 _ls_r_trial -= b;
58 const auto trial_norm = Norm(_ls_r_trial);
59
60 if (print_options.iterations)
61 mfem::out << "Newton line search iteration " << it << " : damping factor = " << scale
62 << ", ||r|| = " << trial_norm << '\n';
63
64 // Sufficient decrease (Armijo) condition on the residual norm, as used by the PETSc
65 // backtracking line search SNESLINESEARCHBT.
66 if (trial_norm <= (1.0 - _ls_sufficient_decrease * scale) * norm)
67 return scale;
68
70 }
71
72 if (print_options.warnings)
73 mfem::out << "Newton line search: no trial step satisfied the sufficient decrease "
74 "condition!\n";
75
76 // Interrupts the Newton iteration, which then reports no convergence.
77 return 0.0;
78}
Real scale
Definition MortarUtils.C:62
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.
mfem::real_t _ls_sufficient_decrease
Coefficient of the sufficient decrease (Armijo) condition on the residual norm.
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.
auto norm(const T &a)
IntRange< T > make_range(T beg, T end)

◆ SetBacktracking()

void Moose::MFEM::DampedNewtonSolver::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_factor shorter than the last, accepting the first whose residual norm satisfies the sufficient decrease condition with coefficient sufficient_decrease.

Definition at line 32 of file MFEMNewtonNonlinearSolver.C.

35{
36 _ls_max_its = max_its;
37 _ls_contraction_factor = contraction_factor;
38 _ls_sufficient_decrease = sufficient_decrease;
39}

◆ SetDampingFactor()

void Moose::MFEM::DampedNewtonSolver::SetDampingFactor ( mfem::real_t  damping_factor)
inline

Set the fraction of the full Newton update applied.

The backtracking line search, when enabled, starts from this trial step.

Definition at line 31 of file MFEMNewtonNonlinearSolver.h.

31{ _damping_factor = damping_factor; }

◆ SetOperator()

void Moose::MFEM::DampedNewtonSolver::SetOperator ( const mfem::Operator &  op)
override

Definition at line 20 of file MFEMNewtonNonlinearSolver.C.

21{
22 mfem::NewtonSolver::SetOperator(op);
23
24 _ls_x_trial.SetSize(width);
25 _ls_x_trial.UseDevice(true);
26
27 _ls_r_trial.SetSize(height);
28 _ls_r_trial.UseDevice(true);
29}

Member Data Documentation

◆ _damping_factor

mfem::real_t Moose::MFEM::DampedNewtonSolver::_damping_factor = 1.0
protected

Fraction of the full Newton update applied, and the line search's initial trial step.

Definition at line 51 of file MFEMNewtonNonlinearSolver.h.

Referenced by ComputeScalingFactor(), and SetDampingFactor().

◆ _ls_contraction_factor

mfem::real_t Moose::MFEM::DampedNewtonSolver::_ls_contraction_factor = 0.5
protected

Factor a rejected trial step is multiplied by to obtain the next one.

Definition at line 55 of file MFEMNewtonNonlinearSolver.h.

Referenced by ComputeScalingFactor(), and SetBacktracking().

◆ _ls_max_its

unsigned int Moose::MFEM::DampedNewtonSolver::_ls_max_its = 0
protected

Maximum number of trial steps taken by the line search; 0 disables backtracking.

Definition at line 53 of file MFEMNewtonNonlinearSolver.h.

Referenced by ComputeScalingFactor(), and SetBacktracking().

◆ _ls_r_trial

mfem::Vector Moose::MFEM::DampedNewtonSolver::_ls_r_trial
mutableprotected

Residual at the trial iterate.

Definition at line 61 of file MFEMNewtonNonlinearSolver.h.

Referenced by ComputeScalingFactor(), and SetOperator().

◆ _ls_sufficient_decrease

mfem::real_t Moose::MFEM::DampedNewtonSolver::_ls_sufficient_decrease = 1.0e-4
protected

Coefficient of the sufficient decrease (Armijo) condition on the residual norm.

Definition at line 57 of file MFEMNewtonNonlinearSolver.h.

Referenced by ComputeScalingFactor(), and SetBacktracking().

◆ _ls_x_trial

mfem::Vector Moose::MFEM::DampedNewtonSolver::_ls_x_trial
mutableprotected

Trial iterate x - t c evaluated by the line search.

Definition at line 59 of file MFEMNewtonNonlinearSolver.h.

Referenced by ComputeScalingFactor(), and SetOperator().


The documentation for this class was generated from the following files: