https://mooseframework.inl.gov
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
Moose::MFEM::EquationSystemProblemOperator Class Reference

Steady-state ProblemOperator that prepares and solves a single EquationSystem. More...

#include <EquationSystemProblemOperator.h>

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

Public Member Functions

 EquationSystemProblemOperator (MFEMProblem &problem)
 
virtual void SetGridFunctions () override
 
virtual void Solve () override
 
virtual EquationSystemGetEquationSystem () const override
 Returns a pointer to the operator's equation system. More...
 
void Mult (const mfem::Vector &, mfem::Vector &) const override
 
virtual void SetTrialVariablesFromTrueVectors ()
 
virtual void Init (mfem::BlockVector &X)
 

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 ()
 Form equation-system state used by Solve(). 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< EquationSystem_equation_system {nullptr}
 

Detailed Description

Steady-state ProblemOperator that prepares and solves a single EquationSystem.

On each call to Solve() this class:

  1. Forms equation-system data (kernels -> weak forms -> constrained linear part and nonlinear action forms).
  2. Calls SolveWithOperator() to pass either the EquationSystem itself or the assembled linear operator (and the bilinear form for LOR preconditioners) to the configured solver tree.
  3. Dispatches to the linear or nonlinear solve path via SolveWithOperator().
  4. Scatters the true-DoF solution back to the grid functions.
See also
EquationSystem for the class that owns the weak-form mathematics.
ProblemOperatorBase for the block-vector bookkeeping and solve-dispatch infrastructure.

Definition at line 34 of file EquationSystemProblemOperator.h.

Constructor & Destructor Documentation

◆ EquationSystemProblemOperator()

Moose::MFEM::EquationSystemProblemOperator::EquationSystemProblemOperator ( MFEMProblem problem)
inline

Definition at line 37 of file EquationSystemProblemOperator.h.

39  {
40  }
ProblemOperator(MFEMProblem &problem)
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system

Member Function Documentation

◆ FormEquationSystemOperator()

void Moose::MFEM::EquationSystemProblemOperator::FormEquationSystemOperator ( )
protected

Form equation-system state used by Solve().

Definition at line 36 of file EquationSystemProblemOperator.C.

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

37 {
39 }
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
void FormSystem(mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Build all weak-form components via BuildEquationSystem(), form the constrained linear part of the sys...

◆ GetEquationSystem()

virtual EquationSystem* Moose::MFEM::EquationSystemProblemOperator::GetEquationSystem ( ) const
inlineoverridevirtual

Returns a pointer to the operator's equation system.

Implements Moose::MFEM::EquationSystemInterface.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator, and Moose::MFEM::EigenproblemESProblemOperator.

Definition at line 45 of file EquationSystemProblemOperator.h.

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

46  {
47  mooseAssert(_equation_system, "No EquationSystem in EquationSystemProblemOperator.");
48  return _equation_system.get();
49  }

◆ Init()

void Moose::MFEM::ProblemOperatorBase::Init ( mfem::BlockVector &  X)
virtualinherited

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 49 of file ProblemOperatorBase.C.

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Init().

50 {
52  for (const auto i : index_range(_trial_variables))
53  X.GetBlock(i) = _trial_variables[i]->GetTrueVector();
54  // Sync the flags from the global vector with the sub-vectors (copies to global vector location)
55  X.SyncFromBlocks();
56 
57  // After initial assignment of X from the grid function, which may contain initial conditions,
58  // we alias the grid function to X
59  for (const auto i : index_range(_trial_variables))
60  _trial_variables[i]->MakeTRef(
61  _trial_variables[i]->ParFESpace(), X, _block_true_offsets_trial[i]);
63 }
mfem::Array< int > _block_true_offsets_trial
std::vector< mfem::ParGridFunction * > _trial_variables
auto index_range(const T &sizable)

◆ Mult()

void Moose::MFEM::ProblemOperator::Mult ( const mfem::Vector &  ,
mfem::Vector &   
) const
inlineoverrideinherited

Definition at line 28 of file ProblemOperator.h.

28 {}

◆ SetGridFunctions()

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

Reimplemented from Moose::MFEM::ProblemOperator.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator.

Definition at line 17 of file EquationSystemProblemOperator.C.

18 {
22 }
std::vector< std::string > _test_var_names
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
virtual void SetGridFunctions() override
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 Moose::MFEM::TimeDependentEquationSystemProblemOperator::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::EquationSystemProblemOperator::Solve ( )
overridevirtual

Reimplemented from Moose::MFEM::ProblemOperator.

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator, and Moose::MFEM::EigenproblemESProblemOperator.

Definition at line 25 of file EquationSystemProblemOperator.C.

26 {
28 
29  auto * const es = GetEquationSystem();
31 
32  es->SetTrialVariablesFromTrueVectors(_true_x);
33 }
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
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()
Form equation-system state used by Solve().

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

Definition at line 56 of file EquationSystemProblemOperator.h.

Referenced by GetEquationSystem().

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

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

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