https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 

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
 

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::TimeDependentEquationSystem > _equation_system
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_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.

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

40 {
41 mooseAssert(_equation_system,
42 "No TimeDependentEquationSystem in TimeDependentEquationSystemProblemOperator.");
43 return _equation_system.get();
44 }

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

63{
66
67 auto * const es = GetEquationSystem();
69
70 X_new.MakeRef(_true_x, 0);
71}
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 ( 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
virtual void Init(mfem::BlockVector &X)
MFEMProblem & _problem
Reference to the current problem.
std::unique_ptr< mfem::ODESolver > ode_solver

◆ SetGridFunctions()

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

Reimplemented from Moose::MFEM::TimeDependentProblemOperator.

Definition at line 17 of file TimeDependentEquationSystemProblemOperator.C.

18{
22}
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 66 of file ProblemOperatorBase.C.

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

Referenced by Solve().

◆ 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 & 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 77 of file ProblemOperatorBase.h.

78 {
79 return SolveWithOperator(system_operator, system_operator.GetGradient(x), rhs, x);
80 }

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

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

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

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.

51{nullptr};

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: