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

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

#include <TimeDependentProblemOperator.h>

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

Public Member Functions

 TimeDependentProblemOperator (MFEMProblem &problem)
 
virtual void SetGridFunctions () override
 
virtual void Solve () override
 
virtual void ImplicitSolve (const mfem::real_t, const mfem::Vector &, mfem::Vector &) 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 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.
 

Detailed Description

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

The user will need to subclass this since the solve is not implemented.

Definition at line 21 of file TimeDependentProblemOperator.h.

Constructor & Destructor Documentation

◆ TimeDependentProblemOperator()

Moose::MFEM::TimeDependentProblemOperator::TimeDependentProblemOperator ( MFEMProblem &  problem)
inline

Definition at line 24 of file TimeDependentProblemOperator.h.

24: ProblemOperatorBase(problem) {}
ProblemOperatorBase(MFEMProblem &problem)

Member Function Documentation

◆ ImplicitSolve()

virtual void Moose::MFEM::TimeDependentProblemOperator::ImplicitSolve ( const mfem::real_t  ,
const mfem::Vector &  ,
mfem::Vector &   
)
inlineoverridevirtual

◆ 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().

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

◆ 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()

virtual void Moose::MFEM::TimeDependentProblemOperator::Solve ( )
inlineoverridevirtual

◆ 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 }
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() [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(), 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

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