https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMNewtonNonlinearSolver.C
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
13#include "MFEMProblem.h"
14
16
19{
21 params.addClassDescription("MFEM native nonlinear solver using Newton's method.");
22 return params;
23}
24
26 : Moose::MFEM::NonlinearSolverBase(parameters)
27{
29}
30
31void
33{
34 auto solver = std::make_unique<mfem::NewtonSolver>(getMFEMProblem().getComm());
35 solver->iterative_mode = getParam<bool>("use_initial_guess");
36 solver->SetRelTol(getParam<mfem::real_t>("rel_tol"));
37 solver->SetAbsTol(getParam<mfem::real_t>("abs_tol"));
38 solver->SetMaxIter(getParam<unsigned int>("max_its"));
39 solver->SetPrintLevel(getParam<unsigned int>("print_level"));
40 _solver = std::move(solver);
41}
42
43void
45{
46 static_cast<mfem::NewtonSolver &>(GetSolver()).SetSolver(solver);
47}
48#endif
registerMooseObject("MooseApp", MFEMNewtonNonlinearSolver)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
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 &parameters)
static InputParameters validParams()
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
Definition MFEMObject.h:45
mfem::Solver & GetSolver()
Returns the wrapped MFEM solver.
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
void SetSolver(mfem::Solver *solver)
Set the wrapped MFEM solver.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...