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

Steady-state ProblemOperator that prepares and solves a single EquationSystem. More...

#include <EquationSystemProblemOperator.h>

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

Public Member Functions

 EquationSystemProblemOperator (MFEMProblem &problem, const std::string &weak_form_name="")
 
virtual void SetGridFunctions () override
 
virtual void Solve () override
 
virtual EquationSystem * GetEquationSystem () const override
 Returns a pointer to the operator's equation system.
 
void Mult (const mfem::Vector &, mfem::Vector &) const override
 
virtual void SetTrialVariablesFromTrueVectors ()
 
virtual void Init ()
 
PerfGraph & perfGraph ()
 Get the PerfGraph.
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

mfem::Array< int > _block_true_offsets_test
 
mfem::Array< int > _block_true_offsets_trial
 
mfem::BlockVector _true_x
 
mfem::BlockVector _true_rhs
 
mfem::BlockVector _true_solution
 Persistent true-DoF solution vector backing this operator's trial grid functions after Init().
 

Protected Member Functions

void FormEquationSystemOperator ()
 Form equation-system state used by Solve().
 
void SolveWithOperator (mfem::Operator &system_operator, mfem::Operator &linear_operator, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current system operator using the configured nonlinear and linear solvers.
 
void SolveWithOperator (mfem::Operator &system_operator, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current system operator using system_operator.GetGradient(x) as the linear operator.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 Call to register a named section for timing.
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 Call to register a named section for timing.
 
std::string timedSectionName (const std::string &section_name) const
 

Protected Attributes

MFEMProblem & _problem
 Reference to the current problem.
 
MFEMProblemData & _problem_data
 
std::vector< std::string > _trial_var_names
 Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector during solve.
 
std::vector< std::string > _test_var_names
 
std::vector< mfem::ParGridFunction * > _trial_variables
 
std::vector< mfem::ParGridFunction * > _test_variables
 
mfem::Vector * _trial_true_vector = nullptr
 
MooseApp & _pg_moose_app
 The MooseApp that owns the PerfGraph.
 
const std::string _prefix
 A prefix to use for all sections.
 

Private Attributes

std::shared_ptr< EquationSystem > _equation_system {nullptr}
 

Detailed Description

Steady-state ProblemOperator that prepares and solves a single EquationSystem.

On each call to Solve() this class:

  1. Forms equation-system data (kernels -> weak forms -> constrained linear part and nonlinear action forms).
  2. Calls SolveWithOperator() to pass either the EquationSystem itself or the assembled linear operator (and the bilinear form for LOR preconditioners) to the configured solver tree.
  3. Dispatches to the linear or nonlinear solve path via SolveWithOperator().
  4. Scatters the true-DoF solution back to the grid functions.
See also
EquationSystem for the class that owns the weak-form mathematics.
ProblemOperatorBase for the block-vector bookkeeping and solve-dispatch infrastructure.

Definition at line 34 of file EquationSystemProblemOperator.h.

Constructor & Destructor Documentation

◆ EquationSystemProblemOperator()

Moose::MFEM::EquationSystemProblemOperator::EquationSystemProblemOperator ( MFEMProblem &  problem,
const std::string &  weak_form_name = "" 
)
Parameters
weak_form_nameName of the weak form supplying this operator's EquationSystem. If empty, the problem's sole EquationSystem is used.

Definition at line 17 of file EquationSystemProblemOperator.C.

19 : ProblemOperator(problem), _equation_system(problem.getEquationSystem(weak_form_name))
20{
21}
std::shared_ptr< Moose::MFEM::EquationSystem > getEquationSystem(const std::string &weak_form_name="") const
Return the EquationSystem built by the weak form named weak_form_name.
ProblemOperator(MFEMProblem &problem)

Member Function Documentation

◆ FormEquationSystemOperator()

void Moose::MFEM::EquationSystemProblemOperator::FormEquationSystemOperator ( )
protected

Form equation-system state used by Solve().

Definition at line 50 of file EquationSystemProblemOperator.C.

51{
53}
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator's equation system.
void FormSystem(mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Build all weak-form components via BuildEquationSystem(), form the constrained linear part of the sys...

Referenced by Moose::MFEM::ComplexEquationSystemProblemOperator::Solve(), and Solve().

◆ GetEquationSystem()

virtual EquationSystem * Moose::MFEM::EquationSystemProblemOperator::GetEquationSystem ( ) const
inlineoverridevirtual

Returns a pointer to the operator's equation system.

Implements Moose::MFEM::EquationSystemInterface.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator, and Moose::MFEM::EigenproblemESProblemOperator.

Definition at line 44 of file EquationSystemProblemOperator.h.

45 {
46 mooseAssert(_equation_system, "No EquationSystem in EquationSystemProblemOperator.");
47 return _equation_system.get();
48 }

Referenced by FormEquationSystemOperator(), Moose::MFEM::EigenproblemESProblemOperator::GetEquationSystem(), SetGridFunctions(), and Solve().

◆ Init()

void Moose::MFEM::ProblemOperatorBase::Init ( )
virtualinherited

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 50 of file ProblemOperatorBase.C.

51{
54 for (const auto i : index_range(_trial_variables))
55 _true_solution.GetBlock(i) = _trial_variables[i]->GetTrueVector();
56 // Sync the flags from the global vector with the sub-vectors (copies to global vector location)
57 _true_solution.SyncFromBlocks();
58
59 // After initial assignment of the true solution from the grid function, which may contain
60 // initial conditions, we alias the grid function to it
61 for (const auto i : index_range(_trial_variables))
62 _trial_variables[i]->MakeTRef(
65}
std::vector< mfem::ParGridFunction * > _trial_variables
mfem::BlockVector _true_solution
Persistent true-DoF solution vector backing this operator's trial grid functions after Init().
auto index_range(const T &sizable)

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Init().

◆ Mult()

void Moose::MFEM::ProblemOperator::Mult ( const mfem::Vector &  ,
mfem::Vector &   
) const
inlineoverrideinherited

Definition at line 28 of file ProblemOperator.h.

28{}

◆ perfGraph()

PerfGraph & PerfGraphInterface::perfGraph ( )
inherited

Get the PerfGraph.

Definition at line 86 of file PerfGraphInterface.C.

87{
88 return _pg_moose_app.perfGraph();
89}
PerfGraph & perfGraph()
Get the PerfGraph for this app.
Definition MooseApp.h:176
MooseApp & _pg_moose_app
The MooseApp that owns the PerfGraph.

Referenced by CommonOutputAction::act(), PerfGraphData::finalize(), PerfGraphReporter::finalize(), and PerfGraphOutput::output().

◆ registerTimedSection() [1/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
Returns
The ID of the section - use when starting timing

Definition at line 61 of file PerfGraphInterface.C.

63{
64 const auto timed_section_name = timedSectionName(section_name);
65 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
66 return moose::internal::getPerfGraphRegistry().registerSection(timed_section_name, level);
67 else
68 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
69}
std::string timedSectionName(const std::string &section_name) const
PerfID sectionID(const std::string &section_name) const
Given a name return the PerfID @section_name The name of the section.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.

◆ registerTimedSection() [2/2]

PerfID PerfGraphInterface::registerTimedSection ( const std::string &  section_name,
const unsigned int  level,
const std::string &  live_message,
const bool  print_dots = true 
) const
protectedinherited

Call to register a named section for timing.

Parameters
section_nameThe name of the code section to be timed
levelThe importance of the timer - lower is more important (0 will always come out)
live_messageThe message to be printed to the screen during execution
print_dotsWhether or not progress dots should be printed for this section
Returns
The ID of the section - use when starting timing

Definition at line 72 of file PerfGraphInterface.C.

76{
77 const auto timed_section_name = timedSectionName(section_name);
78 if (!moose::internal::getPerfGraphRegistry().sectionExists(timed_section_name))
80 timedSectionName(section_name), level, live_message, print_dots);
81 else
82 return moose::internal::getPerfGraphRegistry().sectionID(timed_section_name);
83}

◆ SetGridFunctions()

void Moose::MFEM::EquationSystemProblemOperator::SetGridFunctions ( )
overridevirtual

Reimplemented from Moose::MFEM::ProblemOperator.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator.

Definition at line 24 of file EquationSystemProblemOperator.C.

25{
29}
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
std::vector< std::string > _test_var_names
virtual void SetGridFunctions() override

◆ SetTrialVariablesFromTrueVectors()

void Moose::MFEM::ProblemOperatorBase::SetTrialVariablesFromTrueVectors ( )
virtualinherited

Definition at line 68 of file ProblemOperatorBase.C.

69{
70 mooseAssert(_trial_true_vector, "The true vector should already have been set");
71 for (const auto trial_var : _trial_variables)
72 {
73 // Sync the memory flags from the global true vector to the gridfunction aliases
74 trial_var->GetTrueVector().SyncMemory(*_trial_true_vector);
75 trial_var->SetFromTrueVector();
76 }
77}

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Solve().

◆ Solve()

void Moose::MFEM::EquationSystemProblemOperator::Solve ( )
overridevirtual

Reimplemented from Moose::MFEM::ProblemOperator.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator, and Moose::MFEM::EigenproblemESProblemOperator.

Definition at line 32 of file EquationSystemProblemOperator.C.

33{
34 auto * const es = GetEquationSystem();
35
36 {
37 TIME_SECTION("EquationSystemProblemOperator::FormSystem", 2, "Assembling MFEM System");
39 }
40
41 {
42 TIME_SECTION("EquationSystemProblemOperator::SolveSystem", 2, "Solving MFEM System");
44 }
45
46 es->SetTrialVariablesFromTrueVectors(_true_x);
47}
void FormEquationSystemOperator()
Form equation-system state used by Solve().
void SolveWithOperator(mfem::Operator &system_operator, mfem::Operator &linear_operator, const mfem::Vector &rhs, mfem::Vector &x)
Solve the current system operator using the configured nonlinear and linear solvers.

◆ SolveWithOperator() [1/2]

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( mfem::Operator &  system_operator,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
inlineprotectedinherited

Solve the current system operator using system_operator.GetGradient(x) as the linear operator.

Definition at line 88 of file ProblemOperatorBase.h.

89 {
90 return SolveWithOperator(system_operator, system_operator.GetGradient(x), rhs, x);
91 }

◆ SolveWithOperator() [2/2]

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( mfem::Operator &  system_operator,
mfem::Operator &  linear_operator,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
protectedinherited

Solve the current system operator using the configured nonlinear and linear solvers.

Definition at line 80 of file ProblemOperatorBase.C.

84{
85 // Nonlinear solver path for both linear and nonlinear problems. (as a linear problem may still
86 // intentionally be solved through the nonlinear solver machinery when one is provided)
88 {
89 auto & nonlinear_solver = *_problem_data.nonlinear_solver;
90 if (nonlinear_solver.RequiresExternalLinearSolver())
91 {
93 mooseError("The configured MFEM nonlinear solver requires an external linear solver, but "
94 "none was provided.");
95 auto & linear_solver = *_problem_data.jacobian_solver;
96 linear_solver.SetOperator(linear_operator);
97 nonlinear_solver.SetLinearSolver(linear_solver.GetSolver());
98 }
99
100 nonlinear_solver.SetOperator(system_operator);
101 nonlinear_solver.Mult(rhs, x);
102 }
103 // Linear solver path for linear problems.
104 else
105 {
107 mooseError("A linear MFEM solve requires a linear solver, but none was provided.");
108
109 auto & linear_solver = *_problem_data.jacobian_solver;
110 linear_solver.SetOperator(linear_operator);
111 linear_solver.Mult(rhs, x);
112 }
113}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
std::shared_ptr< Moose::MFEM::NonlinearSolverBase > nonlinear_solver

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::ImplicitSolve(), Moose::MFEM::ComplexEquationSystemProblemOperator::Solve(), Solve(), and Moose::MFEM::ProblemOperatorBase::SolveWithOperator().

◆ timedSectionName()

std::string PerfGraphInterface::timedSectionName ( const std::string &  section_name) const
protectedinherited
Returns
The name of the timed section with the name section_name.

Optionally adds a prefix if one is defined.

Definition at line 55 of file PerfGraphInterface.C.

56{
57 return _prefix.empty() ? section_name : _prefix + "::" + section_name;
58}
const std::string _prefix
A prefix to use for all sections.

Referenced by PerfGraphInterface::registerTimedSection(), and PerfGraphInterface::registerTimedSection().

◆ validParams()

InputParameters PerfGraphInterface::validParams ( )
staticinherited

Definition at line 16 of file PerfGraphInterface.C.

17{
19 return params;
20}
InputParameters emptyInputParameters()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.

Referenced by Convergence::validParams().

Member Data Documentation

◆ _block_true_offsets_test

mfem::Array<int> Moose::MFEM::ProblemOperatorBase::_block_true_offsets_test
inherited

◆ _block_true_offsets_trial

mfem::Array<int> Moose::MFEM::ProblemOperatorBase::_block_true_offsets_trial
inherited

◆ _equation_system

std::shared_ptr<EquationSystem> Moose::MFEM::EquationSystemProblemOperator::_equation_system {nullptr}
private

Definition at line 55 of file EquationSystemProblemOperator.h.

55{nullptr};

Referenced by GetEquationSystem().

◆ _pg_moose_app

MooseApp& PerfGraphInterface::_pg_moose_app
protectedinherited

The MooseApp that owns the PerfGraph.

Definition at line 135 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::perfGraph().

◆ _prefix

const std::string PerfGraphInterface::_prefix
protectedinherited

A prefix to use for all sections.

Definition at line 138 of file PerfGraphInterface.h.

Referenced by PerfGraphInterface::timedSectionName().

◆ _problem

MFEMProblem& Moose::MFEM::ProblemOperatorBase::_problem
protectedinherited

◆ _problem_data

MFEMProblemData& Moose::MFEM::ProblemOperatorBase::_problem_data
protectedinherited

◆ _test_var_names

std::vector<std::string> Moose::MFEM::ProblemOperatorBase::_test_var_names
protectedinherited

◆ _test_variables

std::vector<mfem::ParGridFunction *> Moose::MFEM::ProblemOperatorBase::_test_variables
protectedinherited

◆ _trial_true_vector

mfem::Vector* Moose::MFEM::ProblemOperatorBase::_trial_true_vector = nullptr
protectedinherited

◆ _trial_var_names

std::vector<std::string> Moose::MFEM::ProblemOperatorBase::_trial_var_names
protectedinherited

◆ _trial_variables

std::vector<mfem::ParGridFunction *> Moose::MFEM::ProblemOperatorBase::_trial_variables
protectedinherited

◆ _true_rhs

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_rhs
inherited

◆ _true_solution

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_solution
inherited

Persistent true-DoF solution vector backing this operator's trial grid functions after Init().

Each operator owns its own, because Init() aliases its trial grid functions into this vector; sharing one across operators would make each alias the same storage.

Definition at line 77 of file ProblemOperatorBase.h.

Referenced by Moose::MFEM::ProblemOperatorBase::Init().

◆ _true_x

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_x
inherited

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