https://mooseframework.inl.gov
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)
 
virtual void SetGridFunctions () override
 
virtual void Init (mfem::BlockVector &X) override
 
virtual void ImplicitSolve (const mfem::real_t, const mfem::Vector &, mfem::Vector &) override
 
virtual void Solve () override
 
virtual Moose::MFEM::TimeDependentEquationSystemGetEquationSystem () const override
 Returns a pointer to the operator's equation system. More...
 
virtual void SetTrialVariablesFromTrueVectors ()
 

Public Attributes

mfem::Array< int_block_true_offsets_test
 
mfem::Array< int_block_true_offsets_trial
 
mfem::BlockVector _true_x
 
mfem::BlockVector _true_rhs
 

Protected Member Functions

void FormEquationSystemOperator (mfem::real_t dt)
 Form equation-system state for the current implicit time step. More...
 
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. More...
 
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. More...
 

Protected Attributes

MFEMProblem_problem
 Reference to the current problem. More...
 
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. More...
 
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
 

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)
inline

Definition at line 26 of file TimeDependentEquationSystemProblemOperator.h.

29  std::dynamic_pointer_cast<TimeDependentEquationSystem>(_problem_data.eqn_system))
30  {
31  }
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system
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 74 of file TimeDependentEquationSystemProblemOperator.C.

Referenced by ImplicitSolve().

75 {
78 }
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&#39;s equation system.

◆ 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 39 of file TimeDependentEquationSystemProblemOperator.h.

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

40  {
41  mooseAssert(_equation_system,
42  "No TimeDependentEquationSystem in TimeDependentEquationSystemProblemOperator.");
43  return _equation_system.get();
44  }
std::shared_ptr< Moose::MFEM::TimeDependentEquationSystem > _equation_system

◆ 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 60 of file TimeDependentEquationSystemProblemOperator.C.

63 {
66 
67  auto * const es = GetEquationSystem();
69 
70  X_new.MakeRef(_true_x, 0);
71 }
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.
Moose::MFEM::CoefficientManager coefficients
void setTime(const mfem::real_t time)
virtual Moose::MFEM::TimeDependentEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
void FormEquationSystemOperator(mfem::real_t dt)
Form equation-system state for the current implicit time step.

◆ Init()

void Moose::MFEM::TimeDependentEquationSystemProblemOperator::Init ( mfem::BlockVector &  X)
overridevirtual

Reimplemented from Moose::MFEM::ProblemOperatorBase.

Definition at line 25 of file TimeDependentEquationSystemProblemOperator.C.

26 {
28  // Set timestepper
29  auto & ode_solver = _problem_data.ode_solver;
30  ode_solver = std::make_unique<mfem::BackwardEulerSolver>();
31  ode_solver->Init(*(this));
32  SetTime(_problem.time());
33  SetImplicitVariableType(STATE);
34 }
virtual Real & time() const
std::unique_ptr< mfem::ODESolver > ode_solver
MFEMProblem & _problem
Reference to the current problem.
virtual void Init(mfem::BlockVector &X)

◆ SetGridFunctions()

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

Reimplemented from Moose::MFEM::TimeDependentProblemOperator.

Definition at line 17 of file TimeDependentEquationSystemProblemOperator.C.

18 {
22 }
std::vector< std::string > _test_var_names
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
virtual Moose::MFEM::TimeDependentEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const

◆ SetTrialVariablesFromTrueVectors()

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

Definition at line 66 of file ProblemOperatorBase.C.

Referenced by Solve().

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

◆ Solve()

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

Reimplemented from Moose::MFEM::TimeDependentProblemOperator.

Definition at line 37 of file TimeDependentEquationSystemProblemOperator.C.

38 {
39  auto & dt = _problem.dt();
40  auto & gfs = _problem_data.gridfunctions;
42 
43  // Initialise time derivative
44  for (const auto & trial_var_name : _trial_var_names)
45  gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) = gfs.GetRef(trial_var_name);
46 
47  // Advance time step of the MFEM problem. Time is also updated here, and
48  // _problem_operator->SetTime is called inside the ode_solver->Step method to
49  // update the time used by time dependent (function) coefficients.
51  // Synchonise time dependent GridFunctions with updated DoF data.
53 
54  // Set time derivatives
55  for (const auto & trial_var_name : _trial_var_names)
56  (gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) -= gfs.GetRef(trial_var_name)) /= -dt;
57 }
virtual Real & time() 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::unique_ptr< mfem::ODESolver > ode_solver
MFEMProblem & _problem
Reference to the current problem.
Moose::MFEM::GridFunctions gridfunctions
virtual Real & dt() const
Moose::MFEM::TimeDerivativeMap time_derivative_map

◆ SolveWithOperator() [1/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 78 of file ProblemOperatorBase.C.

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

82 {
83  // Nonlinear solver path for both linear and nonlinear problems. (as a linear problem may still
84  // intentionally be solved through the nonlinear solver machinery when one is provided)
86  {
87  auto & nonlinear_solver = *_problem_data.nonlinear_solver;
88  if (nonlinear_solver.RequiresExternalLinearSolver())
89  {
91  mooseError("The configured MFEM nonlinear solver requires an external linear solver, but "
92  "none was provided.");
93  auto & linear_solver = *_problem_data.jacobian_solver;
94  linear_solver.SetOperator(linear_operator);
95  nonlinear_solver.SetLinearSolver(linear_solver.GetSolver());
96  }
97 
98  nonlinear_solver.SetOperator(system_operator);
99  nonlinear_solver.Mult(rhs, x);
100  }
101  // Linear solver path for linear problems.
102  else
103  {
105  mooseError("A linear MFEM solve requires a linear solver, but none was provided.");
106 
107  auto & linear_solver = *_problem_data.jacobian_solver;
108  linear_solver.SetOperator(linear_operator);
109  linear_solver.Mult(rhs, x);
110  }
111 }
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

◆ SolveWithOperator() [2/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 77 of file ProblemOperatorBase.h.

78  {
79  return SolveWithOperator(system_operator, system_operator.GetGradient(x), rhs, x);
80  }
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.

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

Definition at line 51 of file TimeDependentEquationSystemProblemOperator.h.

Referenced by GetEquationSystem().

◆ _problem

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

Reference to the current problem.

Definition at line 83 of file ProblemOperatorBase.h.

Referenced by 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_x

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

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