https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMNewtonNonlinearSolver.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
12#pragma once
13
15
16namespace Moose::MFEM
17{
22class DampedNewtonSolver : public mfem::NewtonSolver
23{
24public:
25 DampedNewtonSolver(MPI_Comm comm) : mfem::NewtonSolver(comm) {}
26
27 void SetOperator(const mfem::Operator & op) override;
28
31 void SetDampingFactor(mfem::real_t damping_factor) { _damping_factor = damping_factor; }
32
36 void SetBacktracking(unsigned int max_its,
37 mfem::real_t contraction_factor,
38 mfem::real_t sufficient_decrease);
39
47 mfem::real_t ComputeScalingFactor(const mfem::Vector & x, const mfem::Vector & b) const override;
48
49protected:
51 mfem::real_t _damping_factor = 1.0;
53 unsigned int _ls_max_its = 0;
55 mfem::real_t _ls_contraction_factor = 0.5;
57 mfem::real_t _ls_sufficient_decrease = 1.0e-4;
59 mutable mfem::Vector _ls_x_trial;
61 mutable mfem::Vector _ls_r_trial;
62};
63} // namespace Moose::MFEM
64
69{
70public:
72
74
75 void ConstructSolver() override;
76
77 void SetLinearSolver(mfem::Solver & solver) override;
78 bool RequiresGradient() const override { return true; }
79 bool RequiresExternalLinearSolver() const override { return true; }
80};
81
82#endif
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
bool RequiresGradient() const override
Return whether this nonlinear solver requires Jacobian/gradient information from the operator.
bool RequiresExternalLinearSolver() const override
Return whether this nonlinear solver requires an externally configured MFEM linear solver.
static InputParameters validParams()
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
mfem::NewtonSolver applying a constant damping factor to the Newton update, optionally shortening it ...
void SetDampingFactor(mfem::real_t damping_factor)
Set the fraction of the full Newton update applied.
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.
MooseObject base for nonlinear MFEM solve strategies configured in the input file.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).