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

Steady-state problem operator with an equation system. More...

#include <ComplexEquationSystemProblemOperator.h>

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

Public Member Functions

 ComplexEquationSystemProblemOperator (MFEMProblem &problem)
 
virtual void SetGridFunctions () override
 
virtual void Solve () override
 
virtual Moose::MFEM::ComplexEquationSystemGetEquationSystem () 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 BuildEquationSystemOperator ()
 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::ComplexEquationSystem_equation_system {nullptr}
 
std::vector< mfem::ParComplexGridFunction * > _cmplx_trial_variables
 
std::vector< mfem::ParComplexGridFunction * > _cmplx_test_variables
 

Detailed Description

Steady-state problem operator with an equation system.

Definition at line 19 of file ComplexEquationSystemProblemOperator.h.

Constructor & Destructor Documentation

◆ ComplexEquationSystemProblemOperator()

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

Definition at line 23 of file ComplexEquationSystemProblemOperator.h.

27  {
28  }
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system
std::shared_ptr< Moose::MFEM::ComplexEquationSystem > _equation_system

Member Function Documentation

◆ BuildEquationSystemOperator()

void Moose::MFEM::EquationSystemProblemOperator::BuildEquationSystemOperator ( )
protectedinherited

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

Definition at line 36 of file EquationSystemProblemOperator.C.

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

37 {
40 }
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
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.

◆ GetEquationSystem()

virtual Moose::MFEM::ComplexEquationSystem* Moose::MFEM::ComplexEquationSystemProblemOperator::GetEquationSystem ( ) const
inlineoverridevirtual

Returns a pointer to the operator's equation system.

Reimplemented from Moose::MFEM::EquationSystemProblemOperator.

Definition at line 33 of file ComplexEquationSystemProblemOperator.h.

Referenced by SetGridFunctions(), and Solve().

34  {
35  mooseAssert(_equation_system,
36  "No ComplexEquationSystem in ComplexEquationSystemProblemOperator.");
37  return _equation_system.get();
38  }
std::shared_ptr< Moose::MFEM::ComplexEquationSystem > _equation_system

◆ Init()

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

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 50 of file ProblemOperatorBase.C.

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

51 {
53  for (const auto i : index_range(_trial_variables))
54  X.GetBlock(i) = _trial_variables[i]->GetTrueVector();
55  // Sync the flags from the global vector with the sub-vectors (copies to global vector location)
56  X.SyncFromBlocks();
57 
58  // After initial assignment of X from the grid function, which may contain initial conditions,
59  // we alias the grid function to X
60  for (const auto i : index_range(_trial_variables))
61  _trial_variables[i]->MakeTRef(
62  _trial_variables[i]->ParFESpace(), X, _block_true_offsets_trial[i]);
64 }
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::ComplexEquationSystemProblemOperator::SetGridFunctions ( )
overridevirtual

Reimplemented from Moose::MFEM::EquationSystemProblemOperator.

Definition at line 17 of file ComplexEquationSystemProblemOperator.C.

18 {
21 
24 
25  // Set operator size and block structure for trial spaces
28  for (const auto ind : index_range(_cmplx_trial_variables))
29  {
30  _block_true_offsets_trial[ind + 1] =
31  2 * _cmplx_trial_variables.at(ind)->ParFESpace()->TrueVSize();
32  }
33  _block_true_offsets_trial.PartialSum();
34 
35  // Set operator size and block structure for test spaces
38  for (const auto ind : index_range(_cmplx_test_variables))
39  {
40  _block_true_offsets_test[ind + 1] =
41  2 * _cmplx_test_variables.at(ind)->ParFESpace()->TrueVSize();
42  }
43  _block_true_offsets_test.PartialSum();
44 
47 
50 }
virtual Moose::MFEM::ComplexEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
std::vector< std::string > _test_var_names
Moose::MFEM::ComplexGridFunctions cmplx_gridfunctions
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
mfem::Array< int > _block_true_offsets_test
mfem::Array< int > _block_true_offsets_trial
std::vector< mfem::ParComplexGridFunction * > _cmplx_test_variables
std::vector< mfem::ParComplexGridFunction * > _cmplx_trial_variables
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer...
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const
auto index_range(const T &sizable)

◆ SetTrialVariablesFromTrueVectors()

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

Definition at line 67 of file ProblemOperatorBase.C.

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::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::ComplexEquationSystemProblemOperator::Solve ( )
overridevirtual

Reimplemented from Moose::MFEM::EquationSystemProblemOperator.

Definition at line 53 of file ComplexEquationSystemProblemOperator.C.

54 {
56 
57  auto * const es = GetEquationSystem();
59 
60  es->SetTrialVariablesFromTrueVectors(_true_x);
61 }
virtual Moose::MFEM::ComplexEquationSystem * 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...
void BuildEquationSystemOperator()
Add kernels/bcs and assemble the linear part of the equation system.

◆ 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 Moose::MFEM::TimeDependentEquationSystemProblemOperator::ImplicitSolve(), Moose::MFEM::EquationSystemProblemOperator::Solve(), and 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

◆ _cmplx_test_variables

std::vector<mfem::ParComplexGridFunction *> Moose::MFEM::ComplexEquationSystemProblemOperator::_cmplx_test_variables
private

Definition at line 43 of file ComplexEquationSystemProblemOperator.h.

Referenced by SetGridFunctions().

◆ _cmplx_trial_variables

std::vector<mfem::ParComplexGridFunction *> Moose::MFEM::ComplexEquationSystemProblemOperator::_cmplx_trial_variables
private

Definition at line 42 of file ComplexEquationSystemProblemOperator.h.

Referenced by SetGridFunctions().

◆ _equation_system

std::shared_ptr<Moose::MFEM::ComplexEquationSystem> Moose::MFEM::ComplexEquationSystemProblemOperator::_equation_system {nullptr}
private

Definition at line 41 of file ComplexEquationSystemProblemOperator.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: