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::TimeDependentEquationSystemProblemOperator Class Reference

Problem operator for time-dependent problems with an equation system. More...

#include <TimeDependentEquationSystemProblemOperator.h>

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

Public Member Functions

 TimeDependentEquationSystemProblemOperator (MFEMProblem &problem, const std::string &weak_form_name="")
 
virtual void SetGridFunctions () override
 
virtual void Init () override
 
virtual void ImplicitSolve (const mfem::real_t, const mfem::Vector &, mfem::Vector &) override
 
virtual void Solve () override
 
virtual Moose::MFEM::TimeDependentEquationSystem * GetEquationSystem () const override
 Returns a pointer to the operator's equation system.
 
virtual void SetTrialVariablesFromTrueVectors ()
 
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 (mfem::real_t dt)
 Form equation-system state for the current implicit time step.
 
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< Moose::MFEM::TimeDependentEquationSystem > _equation_system {nullptr}
 

Detailed Description

Problem operator for time-dependent problems with an equation system.

Definition at line 22 of file TimeDependentEquationSystemProblemOperator.h.

Constructor & Destructor Documentation

◆ TimeDependentEquationSystemProblemOperator()

Moose::MFEM::TimeDependentEquationSystemProblemOperator::TimeDependentEquationSystemProblemOperator ( MFEMProblem &  problem,
const std::string &  weak_form_name = "" 
)

Definition at line 17 of file TimeDependentEquationSystemProblemOperator.C.

20 _equation_system(std::dynamic_pointer_cast<TimeDependentEquationSystem>(
21 problem.getEquationSystem(weak_form_name)))
22{
24 mooseError("The weak form supplying this operator does not provide a "
25 "TimeDependentEquationSystem, which is required by "
26 "TimeDependentEquationSystemProblemOperator.");
27}
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::EquationSystem > getEquationSystem(const std::string &weak_form_name="") const
Return the EquationSystem built by the weak form named weak_form_name.
std::shared_ptr< Moose::MFEM::TimeDependentEquationSystem > _equation_system

Member Function Documentation

◆ FormEquationSystemOperator()

void Moose::MFEM::TimeDependentEquationSystemProblemOperator::FormEquationSystemOperator ( mfem::real_t  dt)
protected

Form equation-system state for the current implicit time step.

Definition at line 97 of file TimeDependentEquationSystemProblemOperator.C.

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

Referenced by ImplicitSolve().

◆ GetEquationSystem()

virtual Moose::MFEM::TimeDependentEquationSystem * Moose::MFEM::TimeDependentEquationSystemProblemOperator::GetEquationSystem ( ) const
inlineoverridevirtual

Returns a pointer to the operator's equation system.

Implements Moose::MFEM::EquationSystemInterface.

Definition at line 35 of file TimeDependentEquationSystemProblemOperator.h.

36 {
37 mooseAssert(_equation_system,
38 "No TimeDependentEquationSystem in TimeDependentEquationSystemProblemOperator.");
39 return _equation_system.get();
40 }

Referenced by FormEquationSystemOperator(), ImplicitSolve(), and SetGridFunctions().

◆ ImplicitSolve()

void Moose::MFEM::TimeDependentEquationSystemProblemOperator::ImplicitSolve ( const mfem::real_t  dt,
const mfem::Vector &  ,
mfem::Vector &  X_new 
)
overridevirtual

Reimplemented from Moose::MFEM::TimeDependentProblemOperator.

Definition at line 73 of file TimeDependentEquationSystemProblemOperator.C.

76{
78
79 {
80 TIME_SECTION(
81 "TimeDependentEquationSystemProblemOperator::FormSystem", 2, "Assembling MFEM System");
83 }
84
85 auto * const es = GetEquationSystem();
86
87 {
88 TIME_SECTION(
89 "TimeDependentEquationSystemProblemOperator::SolveSystem", 2, "Solving MFEM System");
91 }
92
93 X_new.MakeRef(_true_x, 0);
94}
void setTime(const mfem::real_t time)
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 FormEquationSystemOperator(mfem::real_t dt)
Form equation-system state for the current implicit time step.
Moose::MFEM::CoefficientManager coefficients

◆ Init()

void Moose::MFEM::TimeDependentEquationSystemProblemOperator::Init ( )
overridevirtual

Reimplemented from Moose::MFEM::ProblemOperatorBase.

Definition at line 38 of file TimeDependentEquationSystemProblemOperator.C.

39{
41 // Set timestepper
42 auto & ode_solver = _problem_data.ode_solver;
43 ode_solver = std::make_unique<mfem::BackwardEulerSolver>();
44 ode_solver->Init(*(this));
45 SetTime(_problem.time());
46 SetImplicitVariableType(STATE);
47}
virtual Real & time() const
MFEMProblem & _problem
Reference to the current problem.
std::unique_ptr< mfem::ODESolver > ode_solver

◆ 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::TimeDependentEquationSystemProblemOperator::SetGridFunctions ( )
overridevirtual

Reimplemented from Moose::MFEM::TimeDependentProblemOperator.

Definition at line 30 of file TimeDependentEquationSystemProblemOperator.C.

31{
35}
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

◆ 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}
std::vector< mfem::ParGridFunction * > _trial_variables

Referenced by Solve().

◆ Solve()

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

Reimplemented from Moose::MFEM::TimeDependentProblemOperator.

Definition at line 50 of file TimeDependentEquationSystemProblemOperator.C.

51{
52 auto & dt = _problem.dt();
53 auto & gfs = _problem_data.gridfunctions;
55
56 // Initialise time derivative
57 for (const auto & trial_var_name : _trial_var_names)
58 gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) = gfs.GetRef(trial_var_name);
59
60 // Advance time step of the MFEM problem. Time is also updated here, and
61 // _problem_operator->SetTime is called inside the ode_solver->Step method to
62 // update the time used by time dependent (function) coefficients.
64 // Synchonise time dependent GridFunctions with updated DoF data.
66
67 // Set time derivatives
68 for (const auto & trial_var_name : _trial_var_names)
69 (gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) -= gfs.GetRef(trial_var_name)) /= -dt;
70}
virtual Real & dt() const
Moose::MFEM::TimeDerivativeMap time_derivative_map
Moose::MFEM::GridFunctions gridfunctions

◆ 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}
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
std::shared_ptr< Moose::MFEM::NonlinearSolverBase > nonlinear_solver

Referenced by ImplicitSolve(), Moose::MFEM::ComplexEquationSystemProblemOperator::Solve(), Moose::MFEM::EquationSystemProblemOperator::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<Moose::MFEM::TimeDependentEquationSystem> Moose::MFEM::TimeDependentEquationSystemProblemOperator::_equation_system {nullptr}
private

◆ _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

Reference to the current problem.

Definition at line 94 of file ProblemOperatorBase.h.

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

◆ _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: