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 BuildEquationSystemOperator (mfem::real_t dt)
 Add kernels/bcs and assemble the linear part of the equation system. More...
 
void SolveWithOperator (EquationSystem &equation_system, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current equation system/operator using the configured nonlinear solver or linear solver for a purely linear problem. 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

◆ BuildEquationSystemOperator()

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

Add kernels/bcs and assemble the linear part of the equation system.

Definition at line 74 of file TimeDependentEquationSystemProblemOperator.C.

Referenced by ImplicitSolve().

75 {
79 }
void FormSystem(mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Assemble the linear part of the operator, assemble the right-hand side, apply essential and eliminate...
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
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 BuildEquationSystemOperator(), 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 BuildEquationSystemOperator(mfem::real_t dt)
Add kernels/bcs and assemble the linear part of the equation system.
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 SolveWithOperator(EquationSystem &equation_system, const mfem::Vector &rhs, mfem::Vector &x)
Solve the current equation system/operator using the configured nonlinear solver or linear solver for...

◆ 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 67 of file ProblemOperatorBase.C.

Referenced by Solve().

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

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( EquationSystem equation_system,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
protectedinherited

Solve the current equation system/operator using the configured nonlinear solver or linear solver for a purely linear problem.

Definition at line 79 of file ProblemOperatorBase.C.

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

82 {
83  const bool nonlinear = equation_system.Nonlinear();
84 
85  // `nonlinear` describes the assembled MFEM operator, not whether the user configured a
86  // nonlinear solver object. A linear problem may still intentionally be solved through the
87  // nonlinear solver machinery when one is provided.
88  if (nonlinear || _problem_data.nonlinear_solver)
89  {
90  if (nonlinear && !_problem_data.nonlinear_solver)
91  mooseError("A nonlinear MFEM solve requires a nonlinear solver, but none was provided.");
92 
93  auto & nonlinear_solver = *_problem_data.nonlinear_solver;
94  if (nonlinear_solver.RequiresExternalLinearSolver())
95  {
97  mooseError("The configured MFEM nonlinear solver requires an external linear solver, but "
98  "none was provided.");
99  auto & linear_solver = *_problem_data.jacobian_solver;
100  equation_system.PrepareLinearSolver(linear_solver);
101  nonlinear_solver.SetLinearSolver(linear_solver.GetSolver());
102  }
103 
104  nonlinear_solver.SetOperator(equation_system);
105  nonlinear_solver.Mult(rhs, x);
106  return;
107  }
108  else
109  {
110  //
111  // pure linear path
112  //
113 
115  mooseError("A linear MFEM solve requires a linear solver, but none was provided.");
116 
117  auto & linear_solver = *_problem_data.jacobian_solver;
118  equation_system.PrepareLinearSolver(linear_solver);
119  linear_solver.GetSolver().Mult(rhs, x);
120  }
121 }
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

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 45 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: