https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Moose::MFEM::ComplexEquationSystem Class Reference

#include <ComplexEquationSystem.h>

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

Public Member Functions

 ComplexEquationSystem ()=default
 
 ~ComplexEquationSystem ()=default
 
virtual void Init (GridFunctions &gridfunctions, ComplexGridFunctions &cmplx_gridfunctions, mfem::AssemblyLevel assembly_level) override
 Initialise.
 
virtual void Mult (const mfem::Vector &x, mfem::Vector &y) const override
 Nonlinear Mult (Used by Newton-solver not necessarily nonlinear)
 
virtual void BuildLinearForms () override
 Build linear forms and eliminate constrained DoFs.
 
virtual void BuildBilinearForms () override
 Build bilinear forms (diagonal Jacobian contributions)
 
virtual void BuildMixedBilinearForms () override
 Build mixed bilinear forms (off-diagonal Jacobian contributions)
 
virtual void ApplyEssentialBCs () override
 Update all essentially constrained true DoF markers and values on boundaries.
 
virtual void ApplyComplexEssentialBC (const std::string &var_name, mfem::ParComplexGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
 Applies complex BCs to a single trial variable.
 
void AddComplexKernel (std::shared_ptr< MFEMComplexKernel > kernel)
 Add complex kernels.
 
void AddComplexIntegratedBC (std::shared_ptr< MFEMComplexIntegratedBC > bc)
 Add complex integrated BCs.
 
void AddComplexEssentialBCs (std::shared_ptr< MFEMComplexEssentialBC > bc)
 Add complex essential BCs.
 
void EliminateCoupledVariables () override
 Perform trivial eliminations of coupled variables lacking corresponding test variables.
 
virtual void FormSystemOperator (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS) override
 Form matrix-free representation of system operator.
 
virtual void FormSystemMatrix (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS) override
 Form matrix representation of system operator as a HypreParMatrix.
 
virtual void SetTrialVariablesFromTrueVectors (const mfem::BlockVector &trueX) const override
 Update variable from solution vector after solve.
 
template<class FormType >
void ApplyDomainBLFIntegrators (const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &kernels_map)
 Template method for applying BilinearFormIntegrators on domains from kernels to a SesquilinearForm.
 
void ApplyDomainLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParComplexLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &kernels_map)
 Method for applying LinearFormIntegrators on domains from kernels to a ParComplexLinearForm.
 
template<class FormType >
void ApplyBoundaryBLFIntegrators (const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &integrated_bc_map)
 Template method for applying BilinearFormIntegrators on boudaries from kernels to a SesquilinearForm.
 
void ApplyBoundaryLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParComplexLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &integrated_bc_map)
 Method for applying LinearFormIntegrators on boundaries from kernels to a ParComplexLinearForm.
 
bool IsComplex () const override
 
virtual void AddKernel (std::shared_ptr< MFEMKernel > kernel)
 Add kernels.
 
virtual void AddIntegratedBC (std::shared_ptr< MFEMIntegratedBC > kernel)
 
virtual void AddEssentialBC (std::shared_ptr< MFEMEssentialBC > bc)
 Add BC associated with essentially constrained DoFs on boundaries.
 
void FormSystem (mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 Build all weak-form components via BuildEquationSystem(), form the constrained linear part of the system, and populate the true-DoF vectors used by the solve.
 
virtual void ComputeNonlinearResidual (const mfem::Vector &u, mfem::Vector &residual) const
 Compute the contribution to the residual from nonlinear forms only.
 
mfem::Operator & GetGradient (const mfem::Vector &u) const override
 Get Jacobian at the provided vector of true DoFs of trial variables.
 
mfem::OperatorHandle & GetLinearOperator () const
 Get operator handle for linear component of system operator.
 
void SetGradientRequired (bool requires_gradient)
 Set whether an external object (such as a nonlinear solver) requires Jacobian information for this EquationSystem.
 
void SetCoefficientManager (CoefficientManager &coefficients)
 Set the coefficient manager to notify when trial variables are updated, so that stored projections of solution-dependent coefficients are invalidated.
 
const std::vector< std::string > & GetTrialVarNames () const
 
const std::vector< std::string > & GetTestVarNames () const
 
const mfem::Array< int > & GetBlockOffsets () const
 Getter for block true offsets associated with the EquationSystem operator.
 
mfem::ParBilinearForm & GetBilinearForm (const std::string &test_var_name)
 
mfem::ParGridFunction & GetGridFunction (const std::string &trial_var_name)
 
bool Nonlinear () const
 
const mfem::Vector & GetLinearizationPoint () const
 The true-DoF vector used for the most recent Jacobian linearization.
 
std::shared_ptr< mfem::ParBilinearForm > BuildBilinearFormForFESpace (const std::string &var_name, mfem::ParFiniteElementSpace &fespace, mfem::AssemblyLevel assembly_level)
 Build a fresh ParBilinearForm on the given FESpace using the same kernels as the main system's bilinear form for var_name.
 
std::shared_ptr< mfem::ParNonlinearForm > BuildNonlinearFormForFESpace (const std::string &var_name, mfem::ParFiniteElementSpace &fespace, mfem::AssemblyLevel assembly_level)
 Build a fresh ParNonlinearForm on the given FESpace using the same kernels as the main system's nonlinear form for var_name.
 
mfem::Array< int > & GetEssentialBoundaryMarkers (const std::string &var_name)
 Return the essential boundary attribute marker array for a given trial variable.
 
virtual bool IsEigen () const
 
virtual bool IsTimeDependent () const
 
bool IsMultivariate () const
 
bool IsNonlinear () const
 
virtual void BuildEquationSystem ()
 Build all forms comprising this EquationSystem.
 

Protected Member Functions

virtual void AddCoupledVariableNameIfMissing (const std::string &coupled_var_name)
 Add coupled variable to EquationSystem.
 
virtual void AddEliminatedVariableNameIfMissing (const std::string &eliminated_var_name)
 Add eliminated variable to EquationSystem.
 
virtual void AddTestVariableNameIfMissing (const std::string &test_var_name)
 Add test variable to EquationSystem.
 
virtual void SetTrialVariableNames ()
 Set trial variable names from subset of coupled variables that have an associated test variable.
 
void DeleteHBlocks ()
 Deletes the HypreParMatrix associated with any pointer stored in _h_blocks, and then proceeds to delete all dynamically allocated memory for _h_blocks itself, resetting all dimensions to zero.
 
void DeleteJacobianBlocks ()
 Deletes the HypreParMatrix associated with any pointer stored in _jacobian_blocks, and then proceeds to delete all dynamically allocated memory for _jacobian_blocks itself, resetting all dimensions to zero.
 
bool VectorContainsName (const std::vector< std::string > &the_vector, const std::string &name) const
 
virtual void ApplyEssentialBC (const std::string &var_name, mfem::ParGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
 Apply essential BC(s) associated with var_name to set true DoFs of trial_gf and update markers of all essential boundaries.
 
virtual void BuildNonlinearForms ()
 Build non-linear action forms.
 
virtual void FormLinearSystem (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 Form linear components of system based on on- and off-diagonal bilinear form contributions, populate solution and RHS vectors of true DoFs, and apply constraints.
 
void FormJacobianMatrix (const mfem::Vector &u)
 Compute Jacobian matrix at the provided vector of true DoFs of trial variables.
 
template<class FormType >
void ApplyDomainBLFIntegrators (const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &kernels_map, std::optional< mfem::real_t > scale_factor=std::nullopt)
 Template method for applying BilinearFormIntegrators on domains from kernels to a BilinearForm, or MixedBilinearForm.
 
void ApplyDomainLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &kernels_map)
 Apply domain LinearFormIntegrators from kernels to the linear form associated with the supplied test variable.
 
void ApplyDomainNLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParNonlinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &kernels_map, std::optional< mfem::real_t > scale_factor=std::nullopt)
 Apply domain NonlinearFormIntegrators from kernels to the nonlinear form associated with the supplied test variable.
 
template<class FormType >
void ApplyBoundaryBLFIntegrators (const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &integrated_bc_map, std::optional< mfem::real_t > scale_factor=std::nullopt)
 Template method for applying BilinearFormIntegrators on boundaries from integrated boundary conditions to a BilinearForm, or MixedBilinearForm.
 
void ApplyBoundaryLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &integrated_bc_map)
 Apply boundary LinearFormIntegrators from integrated boundary conditions to the linear form associated with the supplied test variable.
 
void ApplyBoundaryNLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParNonlinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &integrated_bc_map, std::optional< mfem::real_t > scale_factor=std::nullopt)
 Apply boundary NonlinearFormIntegrators from integrated boundary conditions to the nonlinear form associated with the supplied test variable.
 

Protected Attributes

NamedFieldsMap< mfem::ParSesquilinearForm > _slfs
 
NamedFieldsMap< mfem::ParComplexLinearForm > _clfs
 
NamedFieldsMap< NamedFieldsMap< mfem::ParMixedSesquilinearForm > > _mslfs
 
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > _cmplx_kernels_map
 
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > _cmplx_integrated_bc_map
 
NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexEssentialBC > > > _cmplx_essential_bc_map
 
ComplexGridFunctions _cmplx_eliminated_variables
 Pointers to coupled variables not part of the reduced ComplexEquationSystem.
 
std::vector< std::unique_ptr< mfem::ParComplexGridFunction > > _cmplx_var_ess_constraints
 Complex Gridfunctions holding essential constraints from Dirichlet BCs.
 
Moose::MFEM::ComplexGridFunctions_complex_gfuncs
 
std::vector< std::string > _coupled_var_names
 Names of all trial variables of kernels and boundary conditions added to this EquationSystem.
 
std::vector< std::string > _trial_var_names
 Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom that comprise the state vector of this EquationSystem.
 
std::vector< std::string > _eliminated_var_names
 Names of all coupled variables without a corresponding test variable.
 
Moose::MFEM::GridFunctions _eliminated_variables
 Pointers to coupled variables not part of the reduced EquationSystem.
 
std::vector< std::string > _test_var_names
 Names of all test variables corresponding to linear forms in this equation system.
 
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
 Pointers to finite element spaces associated with test variables.
 
std::vector< mfem::ParFiniteElementSpace * > _coupled_pfespaces
 Pointers to finite element spaces associated with coupled variables.
 
NamedFieldsMap< mfem::ParBilinearForm > _blfs
 
NamedFieldsMap< mfem::ParLinearForm > _lfs
 
NamedFieldsMap< mfem::ParNonlinearForm > _nlfs
 
NamedFieldsMap< NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
 
std::vector< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
 Gridfunctions holding essential constraints from Dirichlet BCs.
 
std::vector< mfem::Array< int > > _ess_tdof_lists
 
std::vector< mfem::Array< int > > _ess_markers
 
mfem::Array2D< const mfem::HypreParMatrix * > _h_blocks
 
mfem::Array2D< const mfem::HypreParMatrix * > _jacobian_blocks
 
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
 Arrays to store kernels to act on each component of weak form.
 
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > _integrated_bc_map
 Arrays to store integrated BCs to act on each component of weak form.
 
NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialBC > > > _essential_bc_map
 Arrays to store essential BCs to act on each component of weak form.
 
mfem::OperatorHandle _jacobian
 
mfem::OperatorHandle _linear_operator
 
mfem::AssemblyLevel _assembly_level
 
Moose::MFEM::GridFunctions_gfuncs
 
mfem::Array< int_block_true_offsets
 
const mfem::Vector * _linearization_point = nullptr
 
bool _non_linear = false
 
bool _gradient_required = false
 
CoefficientManager_coefficient_manager = nullptr
 

Detailed Description

Definition at line 20 of file ComplexEquationSystem.h.

Constructor & Destructor Documentation

◆ ComplexEquationSystem()

Moose::MFEM::ComplexEquationSystem::ComplexEquationSystem ( )
default

◆ ~ComplexEquationSystem()

Moose::MFEM::ComplexEquationSystem::~ComplexEquationSystem ( )
default

Member Function Documentation

◆ AddComplexEssentialBCs()

void Moose::MFEM::ComplexEquationSystem::AddComplexEssentialBCs ( std::shared_ptr< MFEMComplexEssentialBC bc)

Add complex essential BCs.

Definition at line 234 of file ComplexEquationSystem.C.

235{
236 const auto & test_var_name = bc->getTestVariableName();
237 AddTestVariableNameIfMissing(test_var_name);
238 // Register new complex essential bc map if not present for the test variable
239 if (!_cmplx_essential_bc_map.Has(test_var_name))
240 {
241 auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMComplexEssentialBC>>>();
242 _cmplx_essential_bc_map.Register(test_var_name, std::move(bcs));
243 }
244 _cmplx_essential_bc_map.GetRef(test_var_name).push_back(std::move(bc));
245}
NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexEssentialBC > > > _cmplx_essential_bc_map
virtual void AddTestVariableNameIfMissing(const std::string &test_var_name)
Add test variable to EquationSystem.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ AddComplexIntegratedBC()

void Moose::MFEM::ComplexEquationSystem::AddComplexIntegratedBC ( std::shared_ptr< MFEMComplexIntegratedBC bc)

Add complex integrated BCs.

Definition at line 211 of file ComplexEquationSystem.C.

212{
213 const auto & trial_var_name = bc->getTrialVariableName();
214 const auto & test_var_name = bc->getTestVariableName();
215 AddCoupledVariableNameIfMissing(trial_var_name);
216 AddTestVariableNameIfMissing(test_var_name);
217 // Register new complex integrated bc map if not present for the test variable
218 if (!_cmplx_integrated_bc_map.Has(test_var_name))
219 {
220 auto integrated_bc_field_map =
221 std::make_shared<NamedFieldsMap<std::vector<std::shared_ptr<MFEMComplexIntegratedBC>>>>();
222 _cmplx_integrated_bc_map.Register(test_var_name, std::move(integrated_bc_field_map));
223 }
224 // Register new complex integrated bc map if not present for the test/trial variable pair
225 if (!_cmplx_integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
226 {
227 auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMComplexIntegratedBC>>>();
228 _cmplx_integrated_bc_map.Get(test_var_name)->Register(trial_var_name, std::move(bcs));
229 }
230 _cmplx_integrated_bc_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(bc));
231}
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > _cmplx_integrated_bc_map
virtual void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name)
Add coupled variable to EquationSystem.

◆ AddComplexKernel()

void Moose::MFEM::ComplexEquationSystem::AddComplexKernel ( std::shared_ptr< MFEMComplexKernel kernel)

Add complex kernels.

Definition at line 188 of file ComplexEquationSystem.C.

189{
190 const auto & trial_var_name = kernel->getTrialVariableName();
191 const auto & test_var_name = kernel->getTestVariableName();
192 AddCoupledVariableNameIfMissing(trial_var_name);
193 AddTestVariableNameIfMissing(test_var_name);
194 // Register new complex kernels map if not present for the test variable
195 if (!_cmplx_kernels_map.Has(test_var_name))
196 {
197 auto kernel_field_map =
198 std::make_shared<NamedFieldsMap<std::vector<std::shared_ptr<MFEMComplexKernel>>>>();
199 _cmplx_kernels_map.Register(test_var_name, std::move(kernel_field_map));
200 }
201 // Register new complex kernels map if not present for the test/trial variable pair
202 if (!_cmplx_kernels_map.Get(test_var_name)->Has(trial_var_name))
203 {
204 auto kernels = std::make_shared<std::vector<std::shared_ptr<MFEMComplexKernel>>>();
205 _cmplx_kernels_map.Get(test_var_name)->Register(trial_var_name, std::move(kernels));
206 }
207 _cmplx_kernels_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(kernel));
208}
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > _cmplx_kernels_map

◆ AddCoupledVariableNameIfMissing()

void Moose::MFEM::EquationSystem::AddCoupledVariableNameIfMissing ( const std::string &  coupled_var_name)
protectedvirtualinherited

Add coupled variable to EquationSystem.

Definition at line 57 of file EquationSystem.C.

58{
59 if (!VectorContainsName(_coupled_var_names, coupled_var_name))
60 _coupled_var_names.push_back(coupled_var_name);
61}
std::vector< std::string > _coupled_var_names
Names of all trial variables of kernels and boundary conditions added to this EquationSystem.
bool VectorContainsName(const std::vector< std::string > &the_vector, const std::string &name) const

Referenced by AddComplexIntegratedBC(), AddComplexKernel(), Moose::MFEM::EquationSystem::AddIntegratedBC(), and Moose::MFEM::EquationSystem::AddKernel().

◆ AddEliminatedVariableNameIfMissing()

void Moose::MFEM::EquationSystem::AddEliminatedVariableNameIfMissing ( const std::string &  eliminated_var_name)
protectedvirtualinherited

Add eliminated variable to EquationSystem.

Definition at line 64 of file EquationSystem.C.

65{
66 if (!VectorContainsName(_eliminated_var_names, eliminated_var_name))
67 _eliminated_var_names.push_back(eliminated_var_name);
68}
std::vector< std::string > _eliminated_var_names
Names of all coupled variables without a corresponding test variable.

Referenced by Moose::MFEM::TimeDependentEquationSystem::AddKernel().

◆ AddEssentialBC()

void Moose::MFEM::EquationSystem::AddEssentialBC ( std::shared_ptr< MFEMEssentialBC bc)
virtualinherited

Add BC associated with essentially constrained DoFs on boundaries.

Definition at line 139 of file EquationSystem.C.

140{
141 const auto & test_var_name = bc->getTestVariableName();
142 AddTestVariableNameIfMissing(test_var_name);
143 // Register new essential bc map if not present for the test variable
144 if (!_essential_bc_map.Has(test_var_name))
145 {
146 auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMEssentialBC>>>();
147 _essential_bc_map.Register(test_var_name, std::move(bcs));
148 }
149 _essential_bc_map.GetRef(test_var_name).push_back(std::move(bc));
150}
NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialBC > > > _essential_bc_map
Arrays to store essential BCs to act on each component of weak form.

◆ AddIntegratedBC()

void Moose::MFEM::EquationSystem::AddIntegratedBC ( std::shared_ptr< MFEMIntegratedBC kernel)
virtualinherited

Definition at line 116 of file EquationSystem.C.

117{
118 const auto & trial_var_name = bc->getTrialVariableName();
119 const auto & test_var_name = bc->getTestVariableName();
120 AddCoupledVariableNameIfMissing(trial_var_name);
121 AddTestVariableNameIfMissing(test_var_name);
122 // Register new integrated bc map if not present for the test variable
123 if (!_integrated_bc_map.Has(test_var_name))
124 {
125 auto integrated_bc_field_map = std::make_shared<
127 _integrated_bc_map.Register(test_var_name, std::move(integrated_bc_field_map));
128 }
129 // Register new integrated bc map if not present for the test/trial variable pair
130 if (!_integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
131 {
132 auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMIntegratedBC>>>();
133 _integrated_bc_map.Get(test_var_name)->Register(trial_var_name, std::move(bcs));
134 }
135 _integrated_bc_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(bc));
136}
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > _integrated_bc_map
Arrays to store integrated BCs to act on each component of weak form.
Lightweight adaptor over an std::map from strings to pointer to T.

◆ AddKernel()

void Moose::MFEM::EquationSystem::AddKernel ( std::shared_ptr< MFEMKernel kernel)
virtualinherited

Add kernels.

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 93 of file EquationSystem.C.

94{
95 const auto & trial_var_name = kernel->getTrialVariableName();
96 const auto & test_var_name = kernel->getTestVariableName();
97 AddCoupledVariableNameIfMissing(trial_var_name);
98 AddTestVariableNameIfMissing(test_var_name);
99 // Register new kernels map if not present for the test variable
100 if (!_kernels_map.Has(test_var_name))
101 {
102 auto kernel_field_map =
103 std::make_shared<Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>>();
104 _kernels_map.Register(test_var_name, std::move(kernel_field_map));
105 }
106 // Register new kernels map if not present for the test/trial variable pair
107 if (!_kernels_map.Get(test_var_name)->Has(trial_var_name))
108 {
109 auto kernels = std::make_shared<std::vector<std::shared_ptr<MFEMKernel>>>();
110 _kernels_map.Get(test_var_name)->Register(trial_var_name, std::move(kernels));
111 }
112 _kernels_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(kernel));
113}
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
Arrays to store kernels to act on each component of weak form.

Referenced by Moose::MFEM::TimeDependentEquationSystem::AddKernel().

◆ AddTestVariableNameIfMissing()

void Moose::MFEM::EquationSystem::AddTestVariableNameIfMissing ( const std::string &  test_var_name)
protectedvirtualinherited

Add test variable to EquationSystem.

Definition at line 71 of file EquationSystem.C.

72{
73 if (!VectorContainsName(_test_var_names, test_var_name))
74 _test_var_names.push_back(test_var_name);
75}
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.

Referenced by AddComplexEssentialBCs(), AddComplexIntegratedBC(), AddComplexKernel(), Moose::MFEM::EquationSystem::AddEssentialBC(), Moose::MFEM::EquationSystem::AddIntegratedBC(), Moose::MFEM::EquationSystem::AddKernel(), and Moose::MFEM::TimeDependentEquationSystem::AddKernel().

◆ ApplyBoundaryBLFIntegrators() [1/2]

template<class FormType >
void Moose::MFEM::ComplexEquationSystem::ApplyBoundaryBLFIntegrators ( const std::string &  trial_var_name,
const std::string &  test_var_name,
std::shared_ptr< FormType >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &  integrated_bc_map 
)

Template method for applying BilinearFormIntegrators on boudaries from kernels to a SesquilinearForm.

Definition at line 191 of file ComplexEquationSystem.h.

197{
198 if (integrated_bc_map.Has(test_var_name) &&
199 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
200 {
201 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
202 for (auto & bc : bcs)
203 {
204 mfem::BilinearFormIntegrator * integ_real = bc->getRealBFIntegrator();
205 mfem::BilinearFormIntegrator * integ_imag = bc->getImagBFIntegrator();
206
207 if (integ_real || integ_imag)
208 {
209 bc->isBoundaryRestricted()
210 ? form->AddBoundaryIntegrator(
211 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
212 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
213 }
214 }
215 }
216}

◆ ApplyBoundaryBLFIntegrators() [2/2]

template<class FormType >
void Moose::MFEM::EquationSystem::ApplyBoundaryBLFIntegrators ( const std::string &  trial_var_name,
const std::string &  test_var_name,
std::shared_ptr< FormType >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &  integrated_bc_map,
std::optional< mfem::real_t >  scale_factor = std::nullopt 
)
protectedinherited

Template method for applying BilinearFormIntegrators on boundaries from integrated boundary conditions to a BilinearForm, or MixedBilinearForm.

Definition at line 386 of file EquationSystem.h.

393{
394 if (integrated_bc_map.Has(test_var_name) &&
395 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
396 {
397 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
398 for (auto & bc : bcs)
399 {
400 mfem::BilinearFormIntegrator * integ = bc->createBFIntegrator();
401
402 if (integ)
403 {
404 if (scale_factor.has_value())
405 integ = new ScaleIntegrator(integ, scale_factor.value(), true);
406 bc->isDGBC() ? bc->isBoundaryRestricted()
407 ? form->AddBdrFaceIntegrator(std::move(integ), bc->getBoundaryMarkers())
408 : form->AddBdrFaceIntegrator(std::move(integ))
409 : bc->isBoundaryRestricted()
410 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
411 : form->AddBoundaryIntegrator(std::move(integ));
412 }
413 }
414 }
415}

◆ ApplyBoundaryLFIntegrators() [1/2]

void Moose::MFEM::ComplexEquationSystem::ApplyBoundaryLFIntegrators ( const std::string &  test_var_name,
std::shared_ptr< mfem::ParComplexLinearForm >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &  integrated_bc_map 
)
inline

Method for applying LinearFormIntegrators on boundaries from kernels to a ParComplexLinearForm.

Definition at line 219 of file ComplexEquationSystem.h.

224{
225 if (integrated_bc_map.Has(test_var_name))
226 {
227 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
228 for (auto & bc : bcs)
229 {
230 mfem::LinearFormIntegrator * integ_real = bc->getRealLFIntegrator();
231 mfem::LinearFormIntegrator * integ_imag = bc->getImagLFIntegrator();
232
233 if (integ_real || integ_imag)
234 {
235 bc->isBoundaryRestricted()
236 ? form->AddBoundaryIntegrator(
237 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
238 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
239 }
240 }
241 }
242}

Referenced by BuildLinearForms().

◆ ApplyBoundaryLFIntegrators() [2/2]

void Moose::MFEM::EquationSystem::ApplyBoundaryLFIntegrators ( const std::string &  test_var_name,
std::shared_ptr< mfem::ParLinearForm >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &  integrated_bc_map 
)
protectedinherited

Apply boundary LinearFormIntegrators from integrated boundary conditions to the linear form associated with the supplied test variable.

Definition at line 649 of file EquationSystem.C.

654{
655 if (integrated_bc_map.Has(test_var_name) &&
656 integrated_bc_map.Get(test_var_name)->Has(test_var_name))
657 {
658 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
659 for (auto & bc : bcs)
660 {
661 mfem::LinearFormIntegrator * integ = bc->createLFIntegrator();
662
663 if (integ)
664 {
665 bc->isDGBC() ? bc->isBoundaryRestricted()
666 ? form->AddBdrFaceIntegrator(std::move(integ), bc->getBoundaryMarkers())
667 : form->AddBdrFaceIntegrator(std::move(integ))
668 : bc->isBoundaryRestricted()
669 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
670 : form->AddBoundaryIntegrator(std::move(integ));
671 }
672 }
673 }
674}

Referenced by Moose::MFEM::EquationSystem::BuildLinearForms().

◆ ApplyBoundaryNLFIntegrators()

void Moose::MFEM::EquationSystem::ApplyBoundaryNLFIntegrators ( const std::string &  test_var_name,
std::shared_ptr< mfem::ParNonlinearForm >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &  integrated_bc_map,
std::optional< mfem::real_t >  scale_factor = std::nullopt 
)
protectedinherited

Apply boundary NonlinearFormIntegrators from integrated boundary conditions to the nonlinear form associated with the supplied test variable.

Definition at line 677 of file EquationSystem.C.

683{
684 if (integrated_bc_map.Has(test_var_name))
685 for (const auto & [trial_var_name, bcs] : integrated_bc_map.GetRef(test_var_name))
686 for (auto & bc : *bcs)
687 if (auto * integ = bc->createNLIntegrator())
688 {
689 if (_gradient_required && (test_var_name != trial_var_name))
691 "Support for Off-diagonal MFEM nonlinear boundary integrators in conjunction with "
692 "a nonlinear solver that requires a gradient is not currently "
693 "implemented. Boundary condition '",
694 bc->name(),
695 "' contributes to test variable '",
696 test_var_name,
697 "' from trial variable '",
698 trial_var_name,
699 "'.");
700
701 _non_linear = true;
702 if (scale_factor.has_value())
703 integ = new NLScaleIntegrator(integ, scale_factor.value(), true);
704 bc->isBoundaryRestricted()
705 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
706 : form->AddBoundaryIntegrator(std::move(integ));
707 }
708}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
for(PetscInt i=0;i< nvars;++i)
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD

Referenced by Moose::MFEM::EquationSystem::BuildNonlinearFormForFESpace(), Moose::MFEM::EquationSystem::BuildNonlinearForms(), and Moose::MFEM::TimeDependentEquationSystem::BuildNonlinearForms().

◆ ApplyComplexEssentialBC()

void Moose::MFEM::ComplexEquationSystem::ApplyComplexEssentialBC ( const std::string &  var_name,
mfem::ParComplexGridFunction &  trial_gf,
mfem::Array< int > &  global_ess_markers 
)
virtual

Applies complex BCs to a single trial variable.

Definition at line 146 of file ComplexEquationSystem.C.

149{
150 if (_cmplx_essential_bc_map.Has(var_name))
151 for (auto & bc : _cmplx_essential_bc_map.GetRef(var_name))
152 {
153 // Set constrained DoFs values on essential boundaries
154 bc->ApplyBC(trial_gf);
155 // Fetch marker array labelling essential boundaries of current BC
156 mfem::Array<int> ess_bdrs(bc->getBoundaryMarkers());
157 // Add these boundary markers to the set of markers labelling all essential boundaries
158 for (const auto i : make_range(ess_bdrs.Size()))
159 global_ess_markers[i] |= ess_bdrs[i];
160 }
161}
IntRange< T > make_range(T beg, T end)

Referenced by ApplyEssentialBCs().

◆ ApplyDomainBLFIntegrators() [1/2]

template<class FormType >
void Moose::MFEM::ComplexEquationSystem::ApplyDomainBLFIntegrators ( const std::string &  trial_var_name,
const std::string &  test_var_name,
std::shared_ptr< FormType >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &  kernels_map 
)

Template method for applying BilinearFormIntegrators on domains from kernels to a SesquilinearForm.

Definition at line 139 of file ComplexEquationSystem.h.

144{
145 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
146 {
147 auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
148 for (auto & kernel : kernels)
149 {
150 mfem::BilinearFormIntegrator * integ_real = kernel->getRealBFIntegrator();
151 mfem::BilinearFormIntegrator * integ_imag = kernel->getImagBFIntegrator();
152
153 if (integ_real || integ_imag)
154 {
155 kernel->isSubdomainRestricted()
156 ? form->AddDomainIntegrator(
157 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
158 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
159 }
160 }
161 }
162}

◆ ApplyDomainBLFIntegrators() [2/2]

template<class FormType >
void Moose::MFEM::EquationSystem::ApplyDomainBLFIntegrators ( const std::string &  trial_var_name,
const std::string &  test_var_name,
std::shared_ptr< FormType >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &  kernels_map,
std::optional< mfem::real_t >  scale_factor = std::nullopt 
)
protectedinherited

Template method for applying BilinearFormIntegrators on domains from kernels to a BilinearForm, or MixedBilinearForm.

Definition at line 357 of file EquationSystem.h.

363{
364 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
365 {
366 auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
367 for (auto & kernel : kernels)
368 {
369 mfem::BilinearFormIntegrator * integ = kernel->createBFIntegrator();
370
371 if (integ)
372 {
373 if (scale_factor.has_value())
374 integ = new ScaleIntegrator(integ, scale_factor.value(), true);
375 kernel->isDGKernel() ? form->AddInteriorFaceIntegrator(std::move(integ))
376 : kernel->isSubdomainRestricted()
377 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
378 : form->AddDomainIntegrator(std::move(integ));
379 }
380 }
381 }
382}

◆ ApplyDomainLFIntegrators() [1/2]

void Moose::MFEM::ComplexEquationSystem::ApplyDomainLFIntegrators ( const std::string &  test_var_name,
std::shared_ptr< mfem::ParComplexLinearForm >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &  kernels_map 
)
inline

Method for applying LinearFormIntegrators on domains from kernels to a ParComplexLinearForm.

Definition at line 165 of file ComplexEquationSystem.h.

169{
170 if (kernels_map.Has(test_var_name))
171 {
172 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
173 for (auto & kernel : kernels)
174 {
175 mfem::LinearFormIntegrator * integ_real = kernel->getRealLFIntegrator();
176 mfem::LinearFormIntegrator * integ_imag = kernel->getImagLFIntegrator();
177
178 if (integ_real || integ_imag)
179 {
180 kernel->isSubdomainRestricted()
181 ? form->AddDomainIntegrator(
182 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
183 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
184 }
185 }
186 }
187}

Referenced by BuildLinearForms().

◆ ApplyDomainLFIntegrators() [2/2]

void Moose::MFEM::EquationSystem::ApplyDomainLFIntegrators ( const std::string &  test_var_name,
std::shared_ptr< mfem::ParLinearForm >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &  kernels_map 
)
protectedinherited

Apply domain LinearFormIntegrators from kernels to the linear form associated with the supplied test variable.

Definition at line 594 of file EquationSystem.C.

598{
599 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(test_var_name))
600 {
601 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
602 for (auto & kernel : kernels)
603 {
604 mfem::LinearFormIntegrator * integ = kernel->createLFIntegrator();
605
606 if (integ)
607 {
608 kernel->isSubdomainRestricted()
609 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
610 : form->AddDomainIntegrator(std::move(integ));
611 }
612 }
613 }
614}

Referenced by Moose::MFEM::EquationSystem::BuildLinearForms().

◆ ApplyDomainNLFIntegrators()

void Moose::MFEM::EquationSystem::ApplyDomainNLFIntegrators ( const std::string &  test_var_name,
std::shared_ptr< mfem::ParNonlinearForm >  form,
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &  kernels_map,
std::optional< mfem::real_t >  scale_factor = std::nullopt 
)
protectedinherited

Apply domain NonlinearFormIntegrators from kernels to the nonlinear form associated with the supplied test variable.

Definition at line 617 of file EquationSystem.C.

622{
623 if (kernels_map.Has(test_var_name))
624 for (const auto & [trial_var_name, kernels] : kernels_map.GetRef(test_var_name))
625 for (auto & kernel : *kernels)
626 if (auto * integ = kernel->createNLIntegrator())
627 {
628 if (_gradient_required && (trial_var_name != test_var_name))
629 mooseError("Support for off-diagonal MFEM nonlinear domain integrators in conjunction "
630 "with a nonlinear solver that requires a gradient is not currently "
631 "implemented. Kernel '",
632 kernel->name(),
633 "' contributes to test variable '",
634 test_var_name,
635 "' from trial variable '",
636 trial_var_name,
637 "'.");
638
639 _non_linear = true;
640 if (scale_factor.has_value())
641 integ = new NLScaleIntegrator(integ, scale_factor.value(), true);
642 kernel->isSubdomainRestricted()
643 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
644 : form->AddDomainIntegrator(std::move(integ));
645 }
646}

Referenced by Moose::MFEM::EquationSystem::BuildNonlinearFormForFESpace(), Moose::MFEM::EquationSystem::BuildNonlinearForms(), and Moose::MFEM::TimeDependentEquationSystem::BuildNonlinearForms().

◆ ApplyEssentialBC()

void Moose::MFEM::EquationSystem::ApplyEssentialBC ( const std::string &  var_name,
mfem::ParGridFunction &  trial_gf,
mfem::Array< int > &  global_ess_markers 
)
protectedvirtualinherited

Apply essential BC(s) associated with var_name to set true DoFs of trial_gf and update markers of all essential boundaries.

Definition at line 204 of file EquationSystem.C.

207{
208 if (_essential_bc_map.Has(var_name))
209 for (auto & bc : _essential_bc_map.GetRef(var_name))
210 {
211 // Set constrained DoFs values on essential boundaries
212 bc->ApplyBC(trial_gf);
213 // Fetch marker array labelling essential boundaries of current BC
214 mfem::Array<int> ess_bdrs(bc->getBoundaryMarkers());
215 // Add these boundary markers to the set of markers labelling all essential boundaries
216 for (const auto i : make_range(ess_bdrs.Size()))
217 global_ess_markers[i] |= ess_bdrs[i];
218 }
219}

Referenced by Moose::MFEM::EquationSystem::ApplyEssentialBCs().

◆ ApplyEssentialBCs()

void Moose::MFEM::ComplexEquationSystem::ApplyEssentialBCs ( )
overridevirtual

Update all essentially constrained true DoF markers and values on boundaries.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 164 of file ComplexEquationSystem.C.

165{
166 _ess_tdof_lists.resize(_trial_var_names.size());
167 _ess_markers.resize(_trial_var_names.size());
168 for (const auto i : index_range(_trial_var_names))
169 {
170 const auto & trial_var_name = _trial_var_names.at(i);
171 mfem::ParComplexGridFunction & trial_gf = *_cmplx_var_ess_constraints.at(i);
172
173 // Make sure we update the size, if this mesh has changed recently for instance
174 trial_gf.Update();
175
176 // Initial guess for iterative solvers (initial condition or the previous time step solution)
177 cast_ref<mfem::Vector &>(trial_gf) = _complex_gfuncs->GetRef(trial_var_name);
178
179 _ess_markers.at(i).SetSize(trial_gf.ParFESpace()->GetParMesh()->bdr_attributes.Max(), 0);
180 // Set strongly constrained DoFs of trial_gf on essential boundaries and add markers for all
181 // essential boundaries to the _ess_markers array
182 ApplyComplexEssentialBC(trial_var_name, trial_gf, _ess_markers.at(i));
183 trial_gf.ParFESpace()->GetEssentialTrueDofs(_ess_markers.at(i), _ess_tdof_lists.at(i));
184 }
185}
std::vector< std::unique_ptr< mfem::ParComplexGridFunction > > _cmplx_var_ess_constraints
Complex Gridfunctions holding essential constraints from Dirichlet BCs.
Moose::MFEM::ComplexGridFunctions * _complex_gfuncs
virtual void ApplyComplexEssentialBC(const std::string &var_name, mfem::ParComplexGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
Applies complex BCs to a single trial variable.
std::vector< mfem::Array< int > > _ess_tdof_lists
std::vector< std::string > _trial_var_names
Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom ...
std::vector< mfem::Array< int > > _ess_markers
auto index_range(const T &sizable)

Referenced by BuildLinearForms().

◆ BuildBilinearFormForFESpace()

std::shared_ptr< mfem::ParBilinearForm > Moose::MFEM::EquationSystem::BuildBilinearFormForFESpace ( const std::string &  var_name,
mfem::ParFiniteElementSpace &  fespace,
mfem::AssemblyLevel  assembly_level 
)
inherited

Build a fresh ParBilinearForm on the given FESpace using the same kernels as the main system's bilinear form for var_name.

Caller owns the returned form.

Definition at line 719 of file EquationSystem.C.

722{
723 auto blf = std::make_shared<mfem::ParBilinearForm>(&fespace);
724 blf->SetAssemblyLevel(assembly_level);
725 ApplyBoundaryBLFIntegrators<mfem::ParBilinearForm>(var_name, var_name, blf, _integrated_bc_map);
726 ApplyDomainBLFIntegrators<mfem::ParBilinearForm>(var_name, var_name, blf, _kernels_map);
727 blf->Assemble();
728 return blf;
729}

◆ BuildBilinearForms()

void Moose::MFEM::ComplexEquationSystem::BuildBilinearForms ( )
overridevirtual

Build bilinear forms (diagonal Jacobian contributions)

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 82 of file ComplexEquationSystem.C.

83{
84 // Register bilinear forms
85 for (const auto i : index_range(_test_var_names))
86 {
87 auto test_var_name = _test_var_names.at(i);
88 _slfs.Register(test_var_name,
89 std::make_shared<mfem::ParSesquilinearForm>(_test_pfespaces.at(i)));
90
91 // Apply kernels
92 auto slf = _slfs.GetShared(test_var_name);
93 slf->SetAssemblyLevel(_assembly_level);
94 ApplyBoundaryBLFIntegrators<mfem::ParSesquilinearForm>(
95 test_var_name, test_var_name, slf, _cmplx_integrated_bc_map);
96 ApplyDomainBLFIntegrators<mfem::ParSesquilinearForm>(
97 test_var_name, test_var_name, slf, _cmplx_kernels_map);
98 // Assemble
99 slf->Assemble();
100 }
101}
NamedFieldsMap< mfem::ParSesquilinearForm > _slfs
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
mfem::AssemblyLevel _assembly_level
std::shared_ptr< T > GetShared(const std::string &field_name) const
Returns a shared pointer to the field. This is guaranteed to return a non-null shared pointer.

◆ BuildEquationSystem()

void Moose::MFEM::EquationSystem::BuildEquationSystem ( )
virtualinherited

Build all forms comprising this EquationSystem.

Definition at line 585 of file EquationSystem.C.

586{
591}
virtual void BuildBilinearForms()
Build bilinear forms (diagonal Jacobian contributions)
virtual void BuildNonlinearForms()
Build non-linear action forms.
virtual void BuildMixedBilinearForms()
Build mixed bilinear forms (off-diagonal Jacobian contributions)
virtual void BuildLinearForms()
Build linear forms and eliminate constrained DoFs.

Referenced by Moose::MFEM::EigenproblemESProblemOperator::FormEquationSystemOperator(), and Moose::MFEM::EquationSystem::FormSystem().

◆ BuildLinearForms()

void Moose::MFEM::ComplexEquationSystem::BuildLinearForms ( )
overridevirtual

Build linear forms and eliminate constrained DoFs.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 54 of file ComplexEquationSystem.C.

55{
56 // Register linear forms
57 for (const auto i : index_range(_test_var_names))
58 {
59 auto test_var_name = _test_var_names.at(i);
60 _clfs.Register(test_var_name,
61 std::make_shared<mfem::ParComplexLinearForm>(_test_pfespaces.at(i)));
62 _clfs.GetRef(test_var_name) = 0.0;
63 }
64
65 for (auto & test_var_name : _test_var_names)
66 {
67 // Apply kernels
68 auto clf = _clfs.GetShared(test_var_name);
71 clf->Assemble();
72 }
73
74 // Apply boundary conditions
76
77 // Eliminate trivially eliminated variables by subtracting contributions from linear forms
79}
void EliminateCoupledVariables() override
Perform trivial eliminations of coupled variables lacking corresponding test variables.
void ApplyBoundaryLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParComplexLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &integrated_bc_map)
Method for applying LinearFormIntegrators on boundaries from kernels to a ParComplexLinearForm.
virtual void ApplyEssentialBCs() override
Update all essentially constrained true DoF markers and values on boundaries.
void ApplyDomainLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParComplexLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &kernels_map)
Method for applying LinearFormIntegrators on domains from kernels to a ParComplexLinearForm.
NamedFieldsMap< mfem::ParComplexLinearForm > _clfs

◆ BuildMixedBilinearForms()

void Moose::MFEM::ComplexEquationSystem::BuildMixedBilinearForms ( )
overridevirtual

Build mixed bilinear forms (off-diagonal Jacobian contributions)

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 104 of file ComplexEquationSystem.C.

105{
106 // Register mixed sesquilinear forms. Note that not all combinations may
107 // have a kernel.
108
109 // Create mslf for each test/coupled variable pair with an added kernel.
110 // Mixed sesquilinear forms with coupled variables that are not trial variables are
111 // associated with contributions from eliminated variables.
112 for (const auto i : index_range(_test_var_names))
113 {
114 auto test_var_name = _test_var_names.at(i);
115 auto test_mslfs =
116 std::make_shared<Moose::MFEM::NamedFieldsMap<mfem::ParMixedSesquilinearForm>>();
117 for (const auto j : index_range(_coupled_var_names))
118 {
119 const auto & coupled_var_name = _coupled_var_names.at(j);
120 auto mslf = std::make_shared<mfem::ParMixedSesquilinearForm>(_coupled_pfespaces.at(j),
121 _test_pfespaces.at(i));
122 // Register MixedSesquilinearForm if kernels exist for it, and assemble
123 // kernels
124 if (_cmplx_kernels_map.Has(test_var_name) &&
125 _cmplx_kernels_map.Get(test_var_name)->Has(coupled_var_name) &&
126 test_var_name != coupled_var_name)
127 {
128 mslf->SetAssemblyLevel(_assembly_level);
129 // Apply all mixed kernels with this test/trial pair
130 ApplyDomainBLFIntegrators<mfem::ParMixedSesquilinearForm>(
131 coupled_var_name, test_var_name, mslf, _cmplx_kernels_map);
132 // Assemble mixed bilinear forms
133 mslf->Assemble();
134 // Register mixed bilinear forms associated with a single trial variable
135 // for the current test variable
136 test_mslfs->Register(coupled_var_name, mslf);
137 }
138 }
139 // Register all mixed bilinear form sets associated with a single test
140 // variable
141 _mslfs.Register(test_var_name, test_mslfs);
142 }
143}
NamedFieldsMap< NamedFieldsMap< mfem::ParMixedSesquilinearForm > > _mslfs
std::vector< mfem::ParFiniteElementSpace * > _coupled_pfespaces
Pointers to finite element spaces associated with coupled variables.

◆ BuildNonlinearFormForFESpace()

std::shared_ptr< mfem::ParNonlinearForm > Moose::MFEM::EquationSystem::BuildNonlinearFormForFESpace ( const std::string &  var_name,
mfem::ParFiniteElementSpace &  fespace,
mfem::AssemblyLevel  assembly_level 
)
inherited

Build a fresh ParNonlinearForm on the given FESpace using the same kernels as the main system's nonlinear form for var_name.

Caller owns the returned form.

Definition at line 732 of file EquationSystem.C.

735{
736 auto nlf = std::make_shared<mfem::ParNonlinearForm>(&fespace);
737 ApplyDomainNLFIntegrators(var_name, nlf, _kernels_map, std::nullopt);
738 ApplyBoundaryNLFIntegrators(var_name, nlf, _integrated_bc_map, std::nullopt);
739 return nlf;
740}
void ApplyDomainNLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParNonlinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > &kernels_map, std::optional< mfem::real_t > scale_factor=std::nullopt)
Apply domain NonlinearFormIntegrators from kernels to the nonlinear form associated with the supplied...
void ApplyBoundaryNLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParNonlinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > &integrated_bc_map, std::optional< mfem::real_t > scale_factor=std::nullopt)
Apply boundary NonlinearFormIntegrators from integrated boundary conditions to the nonlinear form ass...

◆ BuildNonlinearForms()

void Moose::MFEM::EquationSystem::BuildNonlinearForms ( )
protectedvirtualinherited

Build non-linear action forms.

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 509 of file EquationSystem.C.

510{
511 // Register non-linear Action forms
512 for (const auto i : index_range(_test_var_names))
513 {
514 auto test_var_name = _test_var_names.at(i);
515 _nlfs.Register(test_var_name, std::make_shared<mfem::ParNonlinearForm>(_test_pfespaces.at(i)));
516 // Apply kernels
517 auto nlf = _nlfs.GetShared(test_var_name);
518 nlf->SetEssentialTrueDofs(_ess_tdof_lists.at(i));
519 ApplyDomainNLFIntegrators(test_var_name, nlf, _kernels_map, std::nullopt);
520 ApplyBoundaryNLFIntegrators(test_var_name, nlf, _integrated_bc_map, std::nullopt);
521 }
522}
NamedFieldsMap< mfem::ParNonlinearForm > _nlfs

Referenced by Moose::MFEM::EquationSystem::BuildEquationSystem().

◆ ComputeNonlinearResidual()

void Moose::MFEM::EquationSystem::ComputeNonlinearResidual ( const mfem::Vector &  u,
mfem::Vector &  residual 
) const
virtualinherited

Compute the contribution to the residual from nonlinear forms only.

Definition at line 400 of file EquationSystem.C.

401{
402 mooseAssert(_non_linear, "Should not be calling this method if our forms are not nonlinear");
403 residual = 0.0;
404
405 const mfem::BlockVector block_solution(const_cast<mfem::Vector &>(sol), _block_true_offsets);
406 SetTrialVariablesFromTrueVectors(block_solution);
407
408 mfem::BlockVector block_residual(residual, _block_true_offsets);
409 for (unsigned int i = 0; i < _test_var_names.size(); i++)
410 {
411 auto & test_var_name = _test_var_names.at(i);
412 auto nlf = _nlfs.GetShared(test_var_name);
413 nlf->Mult(block_solution.GetBlock(i), block_residual.GetBlock(i));
414 block_residual.GetBlock(i).SyncAliasMemory(block_residual);
415 }
416}
mfem::Array< int > _block_true_offsets
virtual void SetTrialVariablesFromTrueVectors(const mfem::BlockVector &trueX) const
Update variable from solution vector after solve.

Referenced by Moose::MFEM::EquationSystem::Mult().

◆ DeleteHBlocks()

void Moose::MFEM::EquationSystem::DeleteHBlocks ( )
protectedinherited

Deletes the HypreParMatrix associated with any pointer stored in _h_blocks, and then proceeds to delete all dynamically allocated memory for _h_blocks itself, resetting all dimensions to zero.

Definition at line 27 of file EquationSystem.C.

28{
29 for (const auto i : make_range(_h_blocks.NumRows()))
30 for (const auto j : make_range(_h_blocks.NumCols()))
31 {
32 if (_jacobian_blocks.NumRows() && _jacobian_blocks(i, j) == _h_blocks(i, j))
33 _jacobian_blocks(i, j) = nullptr;
34 delete _h_blocks(i, j);
35 }
36 _h_blocks.DeleteAll();
37}
mfem::Array2D< const mfem::HypreParMatrix * > _h_blocks
mfem::Array2D< const mfem::HypreParMatrix * > _jacobian_blocks

Referenced by Moose::MFEM::EquationSystem::FormSystemMatrix(), FormSystemMatrix(), and Moose::MFEM::EquationSystem::~EquationSystem().

◆ DeleteJacobianBlocks()

void Moose::MFEM::EquationSystem::DeleteJacobianBlocks ( )
protectedinherited

Deletes the HypreParMatrix associated with any pointer stored in _jacobian_blocks, and then proceeds to delete all dynamically allocated memory for _jacobian_blocks itself, resetting all dimensions to zero.

Definition at line 40 of file EquationSystem.C.

41{
42 for (const auto i : make_range(_jacobian_blocks.NumRows()))
43 for (const auto j : make_range(_jacobian_blocks.NumCols()))
44 if (!_h_blocks.NumRows() || _jacobian_blocks(i, j) != _h_blocks(i, j))
45 delete _jacobian_blocks(i, j);
46 _jacobian_blocks.DeleteAll();
47}

Referenced by Moose::MFEM::EquationSystem::FormJacobianMatrix(), and Moose::MFEM::EquationSystem::~EquationSystem().

◆ EliminateCoupledVariables()

void Moose::MFEM::ComplexEquationSystem::EliminateCoupledVariables ( )
overridevirtual

Perform trivial eliminations of coupled variables lacking corresponding test variables.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 248 of file ComplexEquationSystem.C.

249{
250 for (const auto & test_var_name : _test_var_names)
251 for (const auto & eliminated_var_name : _eliminated_var_names)
252 if (_mslfs.Has(test_var_name) && _mslfs.Get(test_var_name)->Has(eliminated_var_name) &&
253 !VectorContainsName(_test_var_names, eliminated_var_name))
254 {
255 auto & mslf = *_mslfs.Get(test_var_name)->Get(eliminated_var_name);
256 auto & clf = *_clfs.Get(test_var_name);
257 const mfem::real_t scale = -1.0;
258 const mfem::real_t conv =
259 (mslf.GetConvention() == mfem::ComplexOperator::HERMITIAN) ? 1.0 : -1.0;
260
261 // y += scale * (A_r + i * A_i) * (x_r + i * x_i)
262 // and take the complex conjugate of the result if convention is BLOCK_SYMMETRIC
263 mslf.real().AddMult(
264 _cmplx_eliminated_variables.Get(eliminated_var_name)->real(), clf.real(), scale);
265 mslf.real().AddMult(
266 _cmplx_eliminated_variables.Get(eliminated_var_name)->imag(), clf.imag(), conv * scale);
267 mslf.imag().AddMult(
268 _cmplx_eliminated_variables.Get(eliminated_var_name)->imag(), clf.real(), -scale);
269 mslf.imag().AddMult(
270 _cmplx_eliminated_variables.Get(eliminated_var_name)->real(), clf.imag(), conv * scale);
271 clf.SyncAlias();
272 }
273}
Real scale
Definition MortarUtils.C:62
ComplexGridFunctions _cmplx_eliminated_variables
Pointers to coupled variables not part of the reduced ComplexEquationSystem.
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.

Referenced by BuildLinearForms().

◆ FormJacobianMatrix()

void Moose::MFEM::EquationSystem::FormJacobianMatrix ( const mfem::Vector &  u)
protectedinherited

Compute Jacobian matrix at the provided vector of true DoFs of trial variables.

Definition at line 419 of file EquationSystem.C.

420{
422 _jacobian_blocks.SetSize(_test_var_names.size(), _trial_var_names.size());
423 _jacobian_blocks = nullptr;
424
425 const mfem::BlockVector update_vector(const_cast<mfem::Vector &>(u), _block_true_offsets);
426 for (const auto i : index_range(_test_var_names))
427 {
428 auto test_var_name = _test_var_names.at(i);
429 if (_nlfs.Has(test_var_name))
430 {
431 auto nlf = _nlfs.Get(test_var_name);
432 mfem::HypreParMatrix * nlf_jac =
433 dynamic_cast<mfem::HypreParMatrix *>(&nlf->GetGradient(update_vector.GetBlock(i)));
434 mooseAssert(nlf_jac,
435 "Jacobian contribution of nonlinear form associated with " + test_var_name +
436 " is not castable into a HypreParMatrix");
437 _jacobian_blocks(i, i) = mfem::ParAdd(_h_blocks(i, i), nlf_jac);
438 }
439 else
440 _jacobian_blocks(i, i) = _h_blocks(i, i);
441 for (const auto j : index_range(_trial_var_names))
442 if (i != j) // nlf->GetGradient only contributes to on-diagonal blocks
443 _jacobian_blocks(i, j) = _h_blocks(i, j);
444 }
445 // Create monolithic matrix
446 _jacobian.Reset(mfem::HypreParMatrixFromBlocks(_jacobian_blocks));
447}
mfem::OperatorHandle _jacobian
void DeleteJacobianBlocks()
Deletes the HypreParMatrix associated with any pointer stored in _jacobian_blocks,...

Referenced by Moose::MFEM::EquationSystem::GetGradient().

◆ FormLinearSystem()

void Moose::MFEM::EquationSystem::FormLinearSystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
protectedvirtualinherited

Form linear components of system based on on- and off-diagonal bilinear form contributions, populate solution and RHS vectors of true DoFs, and apply constraints.

Definition at line 259 of file EquationSystem.C.

262{
263 mooseAssert(_test_var_names.size() == _trial_var_names.size(),
264 "Number of test and trial variables must be the same for block matrix assembly.");
265
266 if (_assembly_level == mfem::AssemblyLevel::LEGACY)
267 FormSystemMatrix(op, trueX, trueRHS);
268 else
269 FormSystemOperator(op, trueX, trueRHS);
270}
virtual void FormSystemOperator(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Form matrix-free representation of linear components of system operator.
virtual void FormSystemMatrix(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Form matrix representation of linear components of system operator as a HypreParMatrix.

Referenced by Moose::MFEM::EquationSystem::FormSystem().

◆ FormSystem()

void Moose::MFEM::EquationSystem::FormSystem ( mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
inherited

Build all weak-form components via BuildEquationSystem(), form the constrained linear part of the system, and populate the true-DoF vectors used by the solve.

For nonlinear problems, nonlinear forms are registered here but are not folded into the assembled linear operator. Their residual action is evaluated by Mult(), and any Jacobian contribution is formed at the current nonlinear iterate by GetGradient().

This is the single public entry point for callers that want the equation system prepared for a solve. Subclasses customize the form-building step by overriding BuildEquationSystem().

Definition at line 367 of file EquationSystem.C.

368{
370 height = trueX.Size();
371 width = trueRHS.Size();
372 // Store block offsets
373 _block_true_offsets.SetSize(trueX.NumBlocks() + 1);
374 _block_true_offsets[0] = 0;
375 for (unsigned i = 0; i < _trial_var_names.size(); i++)
376 _block_true_offsets[i + 1] = trueX.BlockSize(i);
377 _block_true_offsets.PartialSum();
378 FormLinearSystem(_linear_operator, trueX, trueRHS);
379}
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
mfem::OperatorHandle _linear_operator
virtual void FormLinearSystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Form linear components of system based on on- and off-diagonal bilinear form contributions,...

Referenced by Moose::MFEM::EquationSystemProblemOperator::FormEquationSystemOperator(), and Moose::MFEM::TimeDependentEquationSystemProblemOperator::FormEquationSystemOperator().

◆ FormSystemMatrix()

void Moose::MFEM::ComplexEquationSystem::FormSystemMatrix ( mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
overridevirtual

Form matrix representation of system operator as a HypreParMatrix.

Used when EquationSystem assembly level is set to 'LEGACY'.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 303 of file ComplexEquationSystem.C.

306{
307
308 // Allocate block operator
310 _h_blocks.SetSize(_test_var_names.size(), _trial_var_names.size());
311 _h_blocks = nullptr;
312 // Zero out RHS and sync memory
313 trueRHS = 0.0;
314 trueRHS.SyncToBlocks();
315
316 for (const auto i : index_range(_test_var_names))
317 {
318 auto test_var_name = _test_var_names.at(i);
319 for (const auto j : index_range(_trial_var_names))
320 {
321 auto trial_var_name = _trial_var_names.at(j);
322
323 mfem::Vector aux_x, aux_rhs;
324 mfem::ParComplexLinearForm aux_lf(_test_pfespaces.at(i));
325 std::unique_ptr<mfem::OperatorHandle> aux_a = std::make_unique<mfem::OperatorHandle>();
326 aux_lf = 0.0;
327 if (test_var_name == trial_var_name)
328 {
329 mooseAssert(i == j, "Trial and test variables must have the same ordering.");
330 auto slf = _slfs.Get(test_var_name);
331 auto clf = _clfs.Get(test_var_name);
332 slf->FormLinearSystem(_ess_tdof_lists.at(j),
334 *clf,
335 *aux_a,
336 aux_x,
337 aux_rhs,
338 /*copy_interior=*/true);
339 trueX.GetBlock(i) = aux_x;
340 }
341 else if (_mslfs.Has(test_var_name) && _mslfs.Get(test_var_name)->Has(trial_var_name))
342 {
343 auto mslf = _mslfs.Get(test_var_name)->Get(trial_var_name);
344 mslf->FormRectangularLinearSystem(_ess_tdof_lists.at(j),
345 _ess_tdof_lists.at(i),
347 aux_lf,
348 *aux_a,
349 aux_x,
350 aux_rhs);
351 }
352 else
353 continue;
354
355 trueRHS.GetBlock(i) += aux_rhs;
356 _h_blocks(i, j) = aux_a->As<mfem::ComplexHypreParMatrix>()->GetSystemMatrix();
357 }
358 }
359
360 // Sync memory
361 trueX.SyncFromBlocks();
362 trueRHS.SyncFromBlocks();
363
364 // Create monolithic matrix
365 op.Reset(mfem::HypreParMatrixFromBlocks(_h_blocks));
366}
void DeleteHBlocks()
Deletes the HypreParMatrix associated with any pointer stored in _h_blocks, and then proceeds to dele...

◆ FormSystemOperator()

void Moose::MFEM::ComplexEquationSystem::FormSystemOperator ( mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
overridevirtual

Form matrix-free representation of system operator.

Used when EquationSystem assembly level is set to 'FULL', 'ELEMENT', 'PARTIAL', or 'NONE'.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 276 of file ComplexEquationSystem.C.

279{
280 auto & test_var_name = _test_var_names.at(0);
281 mfem::Vector aux_x, aux_rhs;
282 mfem::OperatorPtr aux_a;
283
284 auto slf = _slfs.Get(test_var_name);
285 slf->FormLinearSystem(_ess_tdof_lists.at(0),
287 *_clfs.Get(test_var_name),
288 aux_a,
289 aux_x,
290 aux_rhs,
291 /*copy_interior=*/true);
292
293 trueX.GetBlock(0) = aux_x;
294 trueRHS.GetBlock(0) = aux_rhs;
295 trueX.SyncFromBlocks();
296 trueRHS.SyncFromBlocks();
297
298 op.Reset(aux_a.Ptr());
299 aux_a.SetOperatorOwner(false);
300}

◆ GetBilinearForm()

mfem::ParBilinearForm & Moose::MFEM::EquationSystem::GetBilinearForm ( const std::string &  test_var_name)
inlineinherited
Returns
a reference to the MFEM ParBilinearForm corresponding to test_var_name

Definition at line 106 of file EquationSystem.h.

107 {
108 return _blfs.GetRef(test_var_name);
109 }
NamedFieldsMap< mfem::ParBilinearForm > _blfs

◆ GetBlockOffsets()

const mfem::Array< int > & Moose::MFEM::EquationSystem::GetBlockOffsets ( ) const
inlineinherited

Getter for block true offsets associated with the EquationSystem operator.

Definition at line 101 of file EquationSystem.h.

101{ return _block_true_offsets; }

◆ GetEssentialBoundaryMarkers()

mfem::Array< int > & Moose::MFEM::EquationSystem::GetEssentialBoundaryMarkers ( const std::string &  var_name)
inherited

Return the essential boundary attribute marker array for a given trial variable.

The returned array has size == pmesh.bdr_attributes.Max() with 1 at essential boundaries.

Definition at line 743 of file EquationSystem.C.

744{
745 for (const auto i : index_range(_trial_var_names))
746 if (_trial_var_names.at(i) == var_name)
747 return _ess_markers.at(i);
748
749 mooseError("No essential boundary markers found for variable '", var_name, "'.");
750}

◆ GetGradient()

mfem::Operator & Moose::MFEM::EquationSystem::GetGradient ( const mfem::Vector &  u) const
overrideinherited

Get Jacobian at the provided vector of true DoFs of trial variables.

Definition at line 450 of file EquationSystem.C.

451{
453
454 if (_non_linear)
455 {
456 if (_assembly_level != mfem::AssemblyLevel::LEGACY)
457 mooseError("MFEM nonlinear solvers that require GetGradient() currently require legacy "
458 "assembly in EquationSystem.");
459 const_cast<EquationSystem *>(this)->FormJacobianMatrix(u);
460 }
461 else
463
464 return *_jacobian;
465}
void FormJacobianMatrix(const mfem::Vector &u)
Compute Jacobian matrix at the provided vector of true DoFs of trial variables.
const mfem::Vector * _linearization_point

◆ GetGridFunction()

mfem::ParGridFunction & Moose::MFEM::EquationSystem::GetGridFunction ( const std::string &  trial_var_name)
inlineinherited
Returns
a reference to the MFEM ParGridFunction corresponding to trial_var_name

Definition at line 114 of file EquationSystem.h.

115 {
116 return _gfuncs->GetRef(trial_var_name);
117 }
Moose::MFEM::GridFunctions * _gfuncs

◆ GetLinearizationPoint()

const mfem::Vector & Moose::MFEM::EquationSystem::GetLinearizationPoint ( ) const
inherited

The true-DoF vector used for the most recent Jacobian linearization.

Definition at line 711 of file EquationSystem.C.

712{
714 mooseError("EquationSystem::GetLinearizationPoint() called before GetGradient().");
715 return *_linearization_point;
716}

◆ GetLinearOperator()

mfem::OperatorHandle & Moose::MFEM::EquationSystem::GetLinearOperator ( ) const
inlineinherited

Get operator handle for linear component of system operator.

Definition at line 80 of file EquationSystem.h.

80{ return _linear_operator; };

◆ GetTestVarNames()

const std::vector< std::string > & Moose::MFEM::EquationSystem::GetTestVarNames ( ) const
inlineinherited

◆ GetTrialVarNames()

const std::vector< std::string > & Moose::MFEM::EquationSystem::GetTrialVarNames ( ) const
inlineinherited

◆ Init()

void Moose::MFEM::ComplexEquationSystem::Init ( GridFunctions gridfunctions,
ComplexGridFunctions cmplx_gridfunctions,
mfem::AssemblyLevel  assembly_level 
)
overridevirtual

Initialise.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 11 of file ComplexEquationSystem.C.

14{
15 _assembly_level = assembly_level;
16
17 if (gridfunctions.size())
18 mooseError("Mixing real and complex variables is currently not supported.");
19
20 for (auto & test_var_name : _test_var_names)
21 {
22 if (!cmplx_gridfunctions.Has(test_var_name))
23 {
24 mooseError("MFEM complex variable ",
25 test_var_name,
26 " requested by equation system during initialization was "
27 "not found in gridfunctions");
28 }
29 // Store pointers to test FESpaces
30 _test_pfespaces.push_back(cmplx_gridfunctions.Get(test_var_name)->ParFESpace());
31 // Create auxiliary gridfunctions for storing essential constraints from Dirichlet conditions
32 _cmplx_var_ess_constraints.emplace_back(std::make_unique<mfem::ParComplexGridFunction>(
33 cmplx_gridfunctions.Get(test_var_name)->ParFESpace()));
34 }
35
36 // Store pointers to FESpaces of all coupled variables
37 for (auto & coupled_var_name : _coupled_var_names)
38 _coupled_pfespaces.push_back(cmplx_gridfunctions.Get(coupled_var_name)->ParFESpace());
39
40 // Extract which coupled variables are to be trivially eliminated and which are trial variables
42
43 // Store pointers to coupled variable ComplexGridFunctions that are to be eliminated prior to
44 // forming the jacobian
45 for (auto & eliminated_var_name : _eliminated_var_names)
46 _cmplx_eliminated_variables.Register(eliminated_var_name,
47 cmplx_gridfunctions.GetShared(eliminated_var_name));
48
49 // Get a reference to the complex GridFunctions
50 _complex_gfuncs = &cmplx_gridfunctions;
51}
virtual void SetTrialVariableNames()
Set trial variable names from subset of coupled variables that have an associated test variable.

◆ IsComplex()

bool Moose::MFEM::ComplexEquationSystem::IsComplex ( ) const
inlineoverridevirtual
Returns
Whether this EquationSystem includes complex components

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 110 of file ComplexEquationSystem.h.

110{ return true; }

◆ IsEigen()

virtual bool Moose::MFEM::EquationSystem::IsEigen ( ) const
inlinevirtualinherited
Returns
Whether this EquationSystem represents an eigenproblem

Reimplemented in Moose::MFEM::EigenproblemEquationSystem.

Definition at line 154 of file EquationSystem.h.

154{ return false; }

◆ IsMultivariate()

bool Moose::MFEM::EquationSystem::IsMultivariate ( ) const
inlineinherited
Returns
Whether this is a multivariate (maybe mixed) equation system

Definition at line 158 of file EquationSystem.h.

158{ return _test_var_names.size() > 1; }

◆ IsNonlinear()

bool Moose::MFEM::EquationSystem::IsNonlinear ( ) const
inlineinherited
Returns
Whether nonlinear integrators are present in the equation system

Definition at line 160 of file EquationSystem.h.

160{ return _non_linear; }

◆ IsTimeDependent()

virtual bool Moose::MFEM::EquationSystem::IsTimeDependent ( ) const
inlinevirtualinherited
Returns
Whether this EquationSystem has time-dependent components

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 156 of file EquationSystem.h.

156{ return false; }

◆ Mult()

void Moose::MFEM::ComplexEquationSystem::Mult ( const mfem::Vector &  x,
mfem::Vector &  y 
) const
overridevirtual

Nonlinear Mult (Used by Newton-solver not necessarily nonlinear)

Definition at line 370 of file ComplexEquationSystem.C.

371{
372 _linear_operator->Mult(x, residual);
373 x.HostRead();
374 residual.HostRead();
375}

◆ Nonlinear()

bool Moose::MFEM::EquationSystem::Nonlinear ( ) const
inlineinherited
Returns
Whether nonlinear integrators are present

Definition at line 122 of file EquationSystem.h.

122{ return _non_linear; }

◆ SetCoefficientManager()

void Moose::MFEM::EquationSystem::SetCoefficientManager ( CoefficientManager coefficients)
inlineinherited

Set the coefficient manager to notify when trial variables are updated, so that stored projections of solution-dependent coefficients are invalidated.

Definition at line 90 of file EquationSystem.h.

91 {
92 _coefficient_manager = &coefficients;
93 }
CoefficientManager * _coefficient_manager

◆ SetGradientRequired()

void Moose::MFEM::EquationSystem::SetGradientRequired ( bool  requires_gradient)
inlineinherited

Set whether an external object (such as a nonlinear solver) requires Jacobian information for this EquationSystem.

Definition at line 86 of file EquationSystem.h.

86{ _gradient_required = requires_gradient; }

◆ SetTrialVariableNames()

void Moose::MFEM::EquationSystem::SetTrialVariableNames ( )
protectedvirtualinherited

Set trial variable names from subset of coupled variables that have an associated test variable.

Definition at line 78 of file EquationSystem.C.

79{
80 // If a coupled variable has an equation associated with it,
81 // add it to the set of trial variables.
82 for (const auto & test_var_name : _test_var_names)
84 _trial_var_names.push_back(test_var_name);
85
86 // Otherwise, add it to the set of eliminated variables.
87 for (const auto & coupled_var_name : _coupled_var_names)
88 if (!VectorContainsName(_test_var_names, coupled_var_name))
89 _eliminated_var_names.push_back(coupled_var_name);
90}

Referenced by Moose::MFEM::EquationSystem::Init(), and Init().

◆ SetTrialVariablesFromTrueVectors()

void Moose::MFEM::ComplexEquationSystem::SetTrialVariablesFromTrueVectors ( const mfem::BlockVector &  trueX) const
overridevirtual

Update variable from solution vector after solve.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 378 of file ComplexEquationSystem.C.

379{
380 for (const auto i : index_range(_trial_var_names))
381 {
382 auto & trial_var_name = _trial_var_names.at(i);
383 trueX.GetBlock(i).SyncMemory(trueX);
384 _complex_gfuncs->Get(trial_var_name)->Distribute(&(trueX.GetBlock(i)));
385 }
386 // Solution variables changed: stored projections of solution-dependent coefficients are stale.
389}
void markSolutionChanged()
Notify quadrature function coefficients that solution variables have changed, marking the stored valu...

◆ VectorContainsName()

bool Moose::MFEM::EquationSystem::VectorContainsName ( const std::vector< std::string > &  the_vector,
const std::string &  name 
) const
protectedinherited

Member Data Documentation

◆ _assembly_level

mfem::AssemblyLevel Moose::MFEM::EquationSystem::_assembly_level
protectedinherited

◆ _blfs

NamedFieldsMap<mfem::ParBilinearForm> Moose::MFEM::EquationSystem::_blfs
protectedinherited

◆ _block_true_offsets

mfem::Array<int> Moose::MFEM::EquationSystem::_block_true_offsets
protectedinherited

◆ _clfs

NamedFieldsMap<mfem::ParComplexLinearForm> Moose::MFEM::ComplexEquationSystem::_clfs
protected

◆ _cmplx_eliminated_variables

ComplexGridFunctions Moose::MFEM::ComplexEquationSystem::_cmplx_eliminated_variables
protected

Pointers to coupled variables not part of the reduced ComplexEquationSystem.

Definition at line 128 of file ComplexEquationSystem.h.

Referenced by EliminateCoupledVariables(), and Init().

◆ _cmplx_essential_bc_map

NamedFieldsMap<std::vector<std::shared_ptr<MFEMComplexEssentialBC> > > Moose::MFEM::ComplexEquationSystem::_cmplx_essential_bc_map
protected

Definition at line 125 of file ComplexEquationSystem.h.

Referenced by AddComplexEssentialBCs(), and ApplyComplexEssentialBC().

◆ _cmplx_integrated_bc_map

NamedFieldsMap<NamedFieldsMap<std::vector<std::shared_ptr<MFEMComplexIntegratedBC> > > > Moose::MFEM::ComplexEquationSystem::_cmplx_integrated_bc_map
protected

◆ _cmplx_kernels_map

NamedFieldsMap<NamedFieldsMap<std::vector<std::shared_ptr<MFEMComplexKernel> > > > Moose::MFEM::ComplexEquationSystem::_cmplx_kernels_map
protected

◆ _cmplx_var_ess_constraints

std::vector<std::unique_ptr<mfem::ParComplexGridFunction> > Moose::MFEM::ComplexEquationSystem::_cmplx_var_ess_constraints
protected

Complex Gridfunctions holding essential constraints from Dirichlet BCs.

Definition at line 131 of file ComplexEquationSystem.h.

Referenced by ApplyEssentialBCs(), FormSystemMatrix(), FormSystemOperator(), and Init().

◆ _coefficient_manager

CoefficientManager* Moose::MFEM::EquationSystem::_coefficient_manager = nullptr
protectedinherited

◆ _complex_gfuncs

Moose::MFEM::ComplexGridFunctions* Moose::MFEM::ComplexEquationSystem::_complex_gfuncs
protected

◆ _coupled_pfespaces

std::vector<mfem::ParFiniteElementSpace *> Moose::MFEM::EquationSystem::_coupled_pfespaces
protectedinherited

◆ _coupled_var_names

std::vector<std::string> Moose::MFEM::EquationSystem::_coupled_var_names
protectedinherited

◆ _eliminated_var_names

std::vector<std::string> Moose::MFEM::EquationSystem::_eliminated_var_names
protectedinherited

◆ _eliminated_variables

Moose::MFEM::GridFunctions Moose::MFEM::EquationSystem::_eliminated_variables
protectedinherited

◆ _ess_markers

std::vector<mfem::Array<int> > Moose::MFEM::EquationSystem::_ess_markers
protectedinherited

◆ _ess_tdof_lists

std::vector<mfem::Array<int> > Moose::MFEM::EquationSystem::_ess_tdof_lists
protectedinherited

◆ _essential_bc_map

NamedFieldsMap<std::vector<std::shared_ptr<MFEMEssentialBC> > > Moose::MFEM::EquationSystem::_essential_bc_map
protectedinherited

Arrays to store essential BCs to act on each component of weak form.

Named according to test variable.

Definition at line 328 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystem::AddEssentialBC(), and Moose::MFEM::EquationSystem::ApplyEssentialBC().

◆ _gfuncs

Moose::MFEM::GridFunctions* Moose::MFEM::EquationSystem::_gfuncs
protectedinherited

◆ _gradient_required

bool Moose::MFEM::EquationSystem::_gradient_required = false
protectedinherited

◆ _h_blocks

mfem::Array2D<const mfem::HypreParMatrix *> Moose::MFEM::EquationSystem::_h_blocks
protectedinherited

◆ _integrated_bc_map

NamedFieldsMap<NamedFieldsMap<std::vector<std::shared_ptr<MFEMIntegratedBC> > > > Moose::MFEM::EquationSystem::_integrated_bc_map
protectedinherited

◆ _jacobian

mfem::OperatorHandle Moose::MFEM::EquationSystem::_jacobian
mutableprotectedinherited

◆ _jacobian_blocks

mfem::Array2D<const mfem::HypreParMatrix *> Moose::MFEM::EquationSystem::_jacobian_blocks
protectedinherited

◆ _kernels_map

NamedFieldsMap<NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel> > > > Moose::MFEM::EquationSystem::_kernels_map
protectedinherited

◆ _lfs

NamedFieldsMap<mfem::ParLinearForm> Moose::MFEM::EquationSystem::_lfs
protectedinherited

◆ _linear_operator

mfem::OperatorHandle Moose::MFEM::EquationSystem::_linear_operator
mutableprotectedinherited

◆ _linearization_point

const mfem::Vector* Moose::MFEM::EquationSystem::_linearization_point = nullptr
mutableprotectedinherited

◆ _mblfs

NamedFieldsMap<NamedFieldsMap<mfem::ParMixedBilinearForm> > Moose::MFEM::EquationSystem::_mblfs
protectedinherited

◆ _mslfs

NamedFieldsMap<NamedFieldsMap<mfem::ParMixedSesquilinearForm> > Moose::MFEM::ComplexEquationSystem::_mslfs
protected

◆ _nlfs

NamedFieldsMap<mfem::ParNonlinearForm> Moose::MFEM::EquationSystem::_nlfs
protectedinherited

◆ _non_linear

bool Moose::MFEM::EquationSystem::_non_linear = false
protectedinherited

◆ _slfs

NamedFieldsMap<mfem::ParSesquilinearForm> Moose::MFEM::ComplexEquationSystem::_slfs
protected

◆ _test_pfespaces

std::vector<mfem::ParFiniteElementSpace *> Moose::MFEM::EquationSystem::_test_pfespaces
protectedinherited

◆ _test_var_names

std::vector<std::string> Moose::MFEM::EquationSystem::_test_var_names
protectedinherited

◆ _trial_var_names

std::vector<std::string> Moose::MFEM::EquationSystem::_trial_var_names
protectedinherited

◆ _var_ess_constraints

std::vector<std::unique_ptr<mfem::ParGridFunction> > Moose::MFEM::EquationSystem::_var_ess_constraints
protectedinherited

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