https://mooseframework.inl.gov
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 
31 void
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 
43 void
45 {
46  static_cast<mfem::NewtonSolver &>(GetSolver()).SetSolver(solver);
47 }
48 #endif
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
Definition: MFEMObject.h:45
mfem::Solver & GetSolver()
Returns the wrapped MFEM solver.
void SetLinearSolver(mfem::Solver &solver) override
Configure the linear solver used inside the nonlinear solve.
MFEMNewtonNonlinearSolver(const InputParameters &parameters)
void SetSolver(mfem::Solver *solver)
Set the wrapped MFEM solver.
std::unique_ptr< mfem::Solver > _solver
Solver to be used for the problem.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", MFEMNewtonNonlinearSolver)
MPI_Comm getComm()
Return the MPI communicator associated with this FE problem&#39;s mesh.
Definition: MFEMProblem.h:281
static InputParameters validParams()
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...
void ConstructSolver() override
Override in derived classes to construct and set the solver options.
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
MooseObject wrapper for mfem::NewtonSolver-backed nonlinear solves.