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::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.
 
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().
 
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::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.

26 std::dynamic_pointer_cast<Moose::MFEM::ComplexEquationSystem>(_problem_data.eqn_system)}
27 {
28 }
std::shared_ptr< Moose::MFEM::ComplexEquationSystem > _equation_system
std::shared_ptr< Moose::MFEM::EquationSystem > eqn_system

Member Function Documentation

◆ FormEquationSystemOperator()

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

Form equation-system state used by Solve().

Definition at line 36 of file EquationSystemProblemOperator.C.

37{
39}
virtual EquationSystem * GetEquationSystem() const override
Returns a pointer to the operator'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...

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

◆ 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.

34 {
35 mooseAssert(_equation_system,
36 "No ComplexEquationSystem in ComplexEquationSystemProblemOperator.");
37 return _equation_system.get();
38 }

Referenced by SetGridFunctions(), and Solve().

◆ Init()

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

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 49 of file ProblemOperatorBase.C.

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}
std::vector< mfem::ParGridFunction * > _trial_variables
auto index_range(const T &sizable)

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

◆ 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 {
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 {
41 2 * _cmplx_test_variables.at(ind)->ParFESpace()->TrueVSize();
42 }
43 _block_true_offsets_test.PartialSum();
44
47
50}
std::vector< mfem::ParComplexGridFunction * > _cmplx_trial_variables
virtual Moose::MFEM::ComplexEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator's equation system.
std::vector< mfem::ParComplexGridFunction * > _cmplx_test_variables
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const
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.
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
Moose::MFEM::ComplexGridFunctions cmplx_gridfunctions

◆ 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}

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

◆ 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}
void FormEquationSystemOperator()
Form equation-system state used by Solve().
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.

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

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

41{nullptr};

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: