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

Equation system specialization for eigenproblems. More...

#include <EigenproblemEquationSystem.h>

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

Public Member Functions

 EigenproblemEquationSystem ()=default
 
 ~EigenproblemEquationSystem () override=default
 
void BuildEigenproblemJacobian (mfem::BlockVector &trueX, EigenRHSCoefficient rhs_coefficient)
 Build eigenproblem system, with essential boundary conditions accounted for.
 
void PrepareEigensolver (EigensolverBase &solver)
 Prepare the provided eigensolver.
 
bool IsEigen () const override
 
void AddEssentialConstraint (std::shared_ptr< MFEMEssentialConstraint > constraint) override
 Eigenproblems mark external boundaries as essential and do not consult the constraint map, so reject constraints rather than silently ignoring them.
 
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.
 
virtual void Init (GridFunctions &gridfunctions, ComplexGridFunctions &cmplx_gridfunctions, mfem::AssemblyLevel assembly_level)
 Initialise.
 
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.
 
void Mult (const mfem::Vector &u, mfem::Vector &residual) const override
 Compute residual y = Mu.
 
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.
 
virtual void SetTrialVariablesFromTrueVectors (const mfem::BlockVector &trueX) const
 Update variable from solution vector after solve.
 
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)
 
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.
 
const mfem::Array< int > & GetEssentialTrueDofs (const std::string &var_name) const
 Return the essentially constrained true dofs of a given trial variable: those on essential boundaries and those set by essential constraints within subdomains.
 
virtual bool HasEssentialConstraints (const std::string &var_name) const
 
virtual bool IsComplex () 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 ApplyEssentialConstraints () override
 Mark external boundaries as essential for eigenproblem BC elimination.
 
virtual void CheckProblemIsHomogeneous ()
 Verify that the problem is homogeneous (all Dirichlet BCs are zero)
 
void FormEigenproblemMatrix ()
 Form HypreParMatrix matrix operator for the eigensolver with Dirichlet BC elimination.
 
void FormMassMatrix (EigenRHSCoefficient rhs_coefficient)
 Form mass matrix for the eigensolver with Dirichlet BC elimination.
 
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.
 
template<typename T >
void CheckConstrainedVariablesAreTrialVariables (const Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< T > > > &map) const
 Error if any variable that map holds strongly constrained DoFs for is not a trial variable of this system.
 
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 ApplyEssentialConstraint (const std::string &var_name, mfem::ParGridFunction &trial_gf, mfem::Array< int > &global_bdr_markers, mfem::Array< int > &global_ess_tdofs)
 Apply essential constraints associated with var_name to set true DoFs of trial_gf, and update markers of all essential boundaries.
 
virtual void EliminateCoupledVariables ()
 Perform trivial eliminations of coupled variables lacking corresponding test variables.
 
virtual void BuildLinearForms ()
 Build linear forms and eliminate constrained DoFs.
 
virtual void BuildNonlinearForms ()
 Build non-linear action forms.
 
virtual void BuildBilinearForms ()
 Build bilinear forms (diagonal Jacobian contributions)
 
virtual void BuildMixedBilinearForms ()
 Build mixed bilinear forms (off-diagonal Jacobian contributions)
 
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.
 
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.
 
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

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_bdr_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.
 
NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialConstraint > > > _essential_constraint_map
 Arrays to store essential domain constraints 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
 

Private Attributes

mfem::OperatorHandle _mass_rhs
 The mass operator (e.g. the RHS operator for a generalized eigenproblem)
 

Friends

class EigenproblemESProblemOperator
 

Detailed Description

Equation system specialization for eigenproblems.

Definition at line 27 of file EigenproblemEquationSystem.h.

Constructor & Destructor Documentation

◆ EigenproblemEquationSystem()

Moose::MFEM::EigenproblemEquationSystem::EigenproblemEquationSystem ( )
default

◆ ~EigenproblemEquationSystem()

Moose::MFEM::EigenproblemEquationSystem::~EigenproblemEquationSystem ( )
overridedefault

Member Function Documentation

◆ 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 Moose::MFEM::ComplexEquationSystem::AddComplexIntegratedBC(), Moose::MFEM::ComplexEquationSystem::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 // Essential BCs act on a trial gridfunction and are applied while iterating the
142 // trial variables, so they are keyed by trial variable name. The variable's
143 // equation is established by its kernels; a BC does not create one, and Init
144 // checks that one exists.
145 const auto & trial_var_name = bc->getTrialVariableName();
146 // Register new essential bc map if not present for the trial variable
147 if (!_essential_bc_map.Has(trial_var_name))
148 {
149 auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMEssentialBC>>>();
150 _essential_bc_map.Register(trial_var_name, std::move(bcs));
151 }
152 _essential_bc_map.GetRef(trial_var_name).push_back(std::move(bc));
153}
NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialBC > > > _essential_bc_map
Arrays to store essential BCs to act on each component of weak form.
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.

◆ AddEssentialConstraint()

void Moose::MFEM::EigenproblemEquationSystem::AddEssentialConstraint ( std::shared_ptr< MFEMEssentialConstraint >  constraint)
overridevirtual

Eigenproblems mark external boundaries as essential and do not consult the constraint map, so reject constraints rather than silently ignoring them.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 20 of file EigenproblemEquationSystem.C.

22{
23 mooseError("Constraint '",
24 constraint->name(),
25 "' cannot be used in an MFEM eigenproblem: essential constraints on interior "
26 "degrees of freedom are not supported by the eigenproblem equation system.");
27}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311

◆ 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}
virtual void AddTestVariableNameIfMissing(const std::string &test_var_name)
Add test variable to EquationSystem.
virtual void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name)
Add coupled variable to EquationSystem.
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 Moose::MFEM::ComplexEquationSystem::AddComplexIntegratedBC(), Moose::MFEM::ComplexEquationSystem::AddComplexKernel(), Moose::MFEM::EquationSystem::AddIntegratedBC(), Moose::MFEM::EquationSystem::AddKernel(), and Moose::MFEM::TimeDependentEquationSystem::AddKernel().

◆ ApplyBoundaryBLFIntegrators()

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 423 of file EquationSystem.h.

430{
431 if (integrated_bc_map.Has(test_var_name) &&
432 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
433 {
434 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
435 for (auto & bc : bcs)
436 {
437 mfem::BilinearFormIntegrator * integ = bc->createBFIntegrator();
438
439 if (integ)
440 {
441 if (scale_factor.has_value())
442 integ = new ScaleIntegrator(integ, scale_factor.value(), true);
443 bc->isDGBC() ? bc->isBoundaryRestricted()
444 ? form->AddBdrFaceIntegrator(std::move(integ), bc->getBoundaryMarkers())
445 : form->AddBdrFaceIntegrator(std::move(integ))
446 : bc->isBoundaryRestricted()
447 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
448 : form->AddBoundaryIntegrator(std::move(integ));
449 }
450 }
451 }
452}

◆ ApplyBoundaryLFIntegrators()

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 687 of file EquationSystem.C.

692{
693 if (integrated_bc_map.Has(test_var_name) &&
694 integrated_bc_map.Get(test_var_name)->Has(test_var_name))
695 {
696 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
697 for (auto & bc : bcs)
698 {
699 mfem::LinearFormIntegrator * integ = bc->createLFIntegrator();
700
701 if (integ)
702 {
703 bc->isDGBC() ? bc->isBoundaryRestricted()
704 ? form->AddBdrFaceIntegrator(std::move(integ), bc->getBoundaryMarkers())
705 : form->AddBdrFaceIntegrator(std::move(integ))
706 : bc->isBoundaryRestricted()
707 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
708 : form->AddBoundaryIntegrator(std::move(integ));
709 }
710 }
711 }
712}

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 715 of file EquationSystem.C.

721{
722 if (integrated_bc_map.Has(test_var_name))
723 for (const auto & [trial_var_name, bcs] : integrated_bc_map.GetRef(test_var_name))
724 for (auto & bc : *bcs)
725 if (auto * integ = bc->createNLIntegrator())
726 {
727 if (_gradient_required && (test_var_name != trial_var_name))
729 "Support for Off-diagonal MFEM nonlinear boundary integrators in conjunction with "
730 "a nonlinear solver that requires a gradient is not currently "
731 "implemented. Boundary condition '",
732 bc->name(),
733 "' contributes to test variable '",
734 test_var_name,
735 "' from trial variable '",
736 trial_var_name,
737 "'.");
738
739 _non_linear = true;
740 if (scale_factor.has_value())
741 integ = new NLScaleIntegrator(integ, scale_factor.value(), true);
742 bc->isBoundaryRestricted()
743 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
744 : form->AddBoundaryIntegrator(std::move(integ));
745 }
746}
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().

◆ ApplyDomainBLFIntegrators()

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 394 of file EquationSystem.h.

400{
401 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
402 {
403 auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
404 for (auto & kernel : kernels)
405 {
406 mfem::BilinearFormIntegrator * integ = kernel->createBFIntegrator();
407
408 if (integ)
409 {
410 if (scale_factor.has_value())
411 integ = new ScaleIntegrator(integ, scale_factor.value(), true);
412 kernel->isDGKernel() ? form->AddInteriorFaceIntegrator(std::move(integ))
413 : kernel->isSubdomainRestricted()
414 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
415 : form->AddDomainIntegrator(std::move(integ));
416 }
417 }
418 }
419}

◆ ApplyDomainLFIntegrators()

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 632 of file EquationSystem.C.

636{
637 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(test_var_name))
638 {
639 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
640 for (auto & kernel : kernels)
641 {
642 mfem::LinearFormIntegrator * integ = kernel->createLFIntegrator();
643
644 if (integ)
645 {
646 kernel->isSubdomainRestricted()
647 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
648 : form->AddDomainIntegrator(std::move(integ));
649 }
650 }
651 }
652}

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 655 of file EquationSystem.C.

660{
661 if (kernels_map.Has(test_var_name))
662 for (const auto & [trial_var_name, kernels] : kernels_map.GetRef(test_var_name))
663 for (auto & kernel : *kernels)
664 if (auto * integ = kernel->createNLIntegrator())
665 {
666 if (_gradient_required && (trial_var_name != test_var_name))
667 mooseError("Support for off-diagonal MFEM nonlinear domain integrators in conjunction "
668 "with a nonlinear solver that requires a gradient is not currently "
669 "implemented. Kernel '",
670 kernel->name(),
671 "' contributes to test variable '",
672 test_var_name,
673 "' from trial variable '",
674 trial_var_name,
675 "'.");
676
677 _non_linear = true;
678 if (scale_factor.has_value())
679 integ = new NLScaleIntegrator(integ, scale_factor.value(), true);
680 kernel->isSubdomainRestricted()
681 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
682 : form->AddDomainIntegrator(std::move(integ));
683 }
684}

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

◆ ApplyEssentialConstraint()

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

Apply essential constraints associated with var_name to set true DoFs of trial_gf, and update markers of all essential boundaries.

Definition at line 225 of file EquationSystem.C.

229{
230 // A mesh without boundary elements, such as a periodic one, has no boundary attributes
231 const auto & bdr_attributes = trial_gf.ParFESpace()->GetParMesh()->bdr_attributes;
232 global_bdr_markers.SetSize(bdr_attributes.Size() ? bdr_attributes.Max() : 0, 0);
233 global_ess_tdofs.SetSize(0);
234 if (_essential_bc_map.Has(var_name))
235 for (auto & bc : _essential_bc_map.GetRef(var_name))
236 {
237 // Set constrained DoFs values on essential boundaries
238 bc->ApplyBC(trial_gf);
239 // Fetch marker array labelling essential boundaries of current BC
240 mfem::Array<int> ess_bdrs(bc->getBoundaryMarkers());
241 // Add these boundary markers to the set of markers labelling all essential boundaries
242 for (const auto i : make_range(ess_bdrs.Size()))
243 global_bdr_markers[i] |= ess_bdrs[i];
244
245 // Append to the global list so we can detect duplicate essential true DoFs below
246 mfem::Array<int> ess_tdofs;
247 trial_gf.ParFESpace()->GetEssentialTrueDofs(ess_bdrs, ess_tdofs);
248 global_ess_tdofs.Append(ess_tdofs);
249 }
250
251 // Set constrained DoF values and append the constrained tdofs. The constraints on a variable act
252 // on disjoint sets of subdomains and we error below if any one DoF is constrained more than once,
253 // so they may be applied in any order.
254 if (_essential_constraint_map.Has(var_name))
255 for (auto & constraint : _essential_constraint_map.GetRef(var_name))
256 constraint->ApplyConstraint(trial_gf, global_ess_tdofs);
257
258 // We do not allow users to constrain the same DoFs more than once.
259 // mfem::Array::Unique only drops *consecutive* duplicates, so the list must be sorted first.
260 const int num_ess_tdofs = global_ess_tdofs.Size();
261 global_ess_tdofs.Sort();
262 global_ess_tdofs.Unique();
263 if (global_ess_tdofs.Size() != num_ess_tdofs)
264 mooseError("Duplicate essential true degrees of freedom for variable '",
265 var_name,
266 "'. Check for overlapping essential constraints or boundary conditions.");
267}
NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialConstraint > > > _essential_constraint_map
Arrays to store essential domain constraints to act on each component of weak form.
IntRange< T > make_range(T beg, T end)

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

◆ ApplyEssentialConstraints()

void Moose::MFEM::EigenproblemEquationSystem::ApplyEssentialConstraints ( )
overrideprotectedvirtual

Mark external boundaries as essential for eigenproblem BC elimination.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 30 of file EigenproblemEquationSystem.C.

31{
32 _ess_tdof_lists.resize(1);
33 _ess_bdr_markers.resize(1);
34 mfem::ParGridFunction & trial_gf = *(_var_ess_constraints.at(0));
35 trial_gf.Update();
36 trial_gf = _gfuncs->GetRef(_trial_var_names.at(0));
37 // Set constrained DoF values on user-declared essential boundaries and collect their markers
39 _trial_var_names.at(0), trial_gf, _ess_bdr_markers.at(0), _ess_tdof_lists.at(0));
41}
virtual void CheckProblemIsHomogeneous()
Verify that the problem is homogeneous (all Dirichlet BCs are zero)
std::vector< mfem::Array< int > > _ess_bdr_markers
virtual void ApplyEssentialConstraint(const std::string &var_name, mfem::ParGridFunction &trial_gf, mfem::Array< int > &global_bdr_markers, mfem::Array< int > &global_ess_tdofs)
Apply essential constraints associated with var_name to set true DoFs of trial_gf,...
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< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
Moose::MFEM::GridFunctions * _gfuncs

Referenced by BuildEigenproblemJacobian().

◆ 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 757 of file EquationSystem.C.

760{
761 auto blf = std::make_shared<mfem::ParBilinearForm>(&fespace);
762 blf->SetAssemblyLevel(assembly_level);
763 ApplyBoundaryBLFIntegrators<mfem::ParBilinearForm>(var_name, var_name, blf, _integrated_bc_map);
764 ApplyDomainBLFIntegrators<mfem::ParBilinearForm>(var_name, var_name, blf, _kernels_map);
765 blf->Assemble();
766 blf->Finalize();
767 return blf;
768}

◆ BuildBilinearForms()

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

Build bilinear forms (diagonal Jacobian contributions)

Reimplemented in Moose::MFEM::ComplexEquationSystem, and Moose::MFEM::TimeDependentEquationSystem.

Definition at line 561 of file EquationSystem.C.

562{
563 // Register bilinear forms
564 for (const auto i : index_range(_test_var_names))
565 {
566 auto test_var_name = _test_var_names.at(i);
567 _blfs.Register(test_var_name, std::make_shared<mfem::ParBilinearForm>(_test_pfespaces.at(i)));
568
569 // Apply kernels
570 auto blf = _blfs.GetShared(test_var_name);
571 blf->SetAssemblyLevel(_assembly_level);
572 ApplyBoundaryBLFIntegrators<mfem::ParBilinearForm>(
573 test_var_name, test_var_name, blf, _integrated_bc_map);
574 ApplyDomainBLFIntegrators<mfem::ParBilinearForm>(
575 test_var_name, test_var_name, blf, _kernels_map);
576 // Assemble
577 blf->Assemble();
578 blf->Finalize();
579 }
580}
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
mfem::AssemblyLevel _assembly_level
NamedFieldsMap< mfem::ParBilinearForm > _blfs
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.
auto index_range(const T &sizable)

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

◆ BuildEigenproblemJacobian()

void Moose::MFEM::EigenproblemEquationSystem::BuildEigenproblemJacobian ( mfem::BlockVector &  trueX,
EigenRHSCoefficient  rhs_coefficient 
)

Build eigenproblem system, with essential boundary conditions accounted for.

Definition at line 116 of file EigenproblemEquationSystem.C.

118{
119 mooseAssert(_test_var_names.size() == 1 && (_test_var_names.size() == _trial_var_names.size()) &&
120 (_test_var_names.at(0) == _trial_var_names.at(0)),
121 "Eigensolve is only supported for single-variable, square systems");
122
123 height = trueX.Size();
124 width = trueX.Size();
127 FormMassMatrix(rhs_coefficient);
128}
void FormMassMatrix(EigenRHSCoefficient rhs_coefficient)
Form mass matrix for the eigensolver with Dirichlet BC elimination.
void FormEigenproblemMatrix()
Form HypreParMatrix matrix operator for the eigensolver with Dirichlet BC elimination.
virtual void ApplyEssentialConstraints() override
Mark external boundaries as essential for eigenproblem BC elimination.

Referenced by Moose::MFEM::EigenproblemESProblemOperator::FormEquationSystemOperator().

◆ BuildEquationSystem()

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

Build all forms comprising this EquationSystem.

Definition at line 623 of file EquationSystem.C.

624{
629}
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::EquationSystem::BuildLinearForms ( )
protectedvirtualinherited

Build linear forms and eliminate constrained DoFs.

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 518 of file EquationSystem.C.

519{
520 // Register linear forms
521 for (const auto i : index_range(_test_var_names))
522 {
523 auto test_var_name = _test_var_names.at(i);
524 _lfs.Register(test_var_name, std::make_shared<mfem::ParLinearForm>(_test_pfespaces.at(i)));
525 _lfs.GetRef(test_var_name) = 0.0;
526 }
527
528 for (auto & test_var_name : _test_var_names)
529 {
530 // Apply kernels
531 auto lf = _lfs.GetShared(test_var_name);
532 ApplyDomainLFIntegrators(test_var_name, lf, _kernels_map);
534 lf->Assemble();
535 }
536
537 // Apply essential constraints on strongly constrained DoFs
539
540 // Eliminate trivially eliminated variables by subtracting contributions from linear forms
542}
virtual void EliminateCoupledVariables()
Perform trivial eliminations of coupled variables lacking corresponding test variables.
virtual void ApplyEssentialConstraints()
Update essential boundary markers and all constrained true DoF lists and values.
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 associate...
NamedFieldsMap< mfem::ParLinearForm > _lfs
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 ...

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

◆ BuildMixedBilinearForms()

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

Build mixed bilinear forms (off-diagonal Jacobian contributions)

Reimplemented in Moose::MFEM::ComplexEquationSystem, and Moose::MFEM::TimeDependentEquationSystem.

Definition at line 583 of file EquationSystem.C.

584{
585 // Register mixed bilinear forms. Note that not all combinations may
586 // have a kernel.
587
588 // Create mblf for each test/coupled variable pair with an added kernel.
589 // Mixed bilinear forms with coupled variables that are not trial variables are
590 // associated with contributions from eliminated variables.
591 for (const auto i : index_range(_test_var_names))
592 {
593 auto test_var_name = _test_var_names.at(i);
594 auto test_mblfs = std::make_shared<Moose::MFEM::NamedFieldsMap<mfem::ParMixedBilinearForm>>();
595 for (const auto j : index_range(_coupled_var_names))
596 {
597 const auto & coupled_var_name = _coupled_var_names.at(j);
598 auto mblf = std::make_shared<mfem::ParMixedBilinearForm>(_coupled_pfespaces.at(j),
599 _test_pfespaces.at(i));
600 // Register MixedBilinearForm if kernels exist for it, and assemble kernels
601 if (_kernels_map.Has(test_var_name) &&
602 _kernels_map.Get(test_var_name)->Has(coupled_var_name) &&
603 test_var_name != coupled_var_name)
604 {
605 mblf->SetAssemblyLevel(_assembly_level);
606 // Apply all mixed kernels with this test/trial pair
607 ApplyDomainBLFIntegrators<mfem::ParMixedBilinearForm>(
608 coupled_var_name, test_var_name, mblf, _kernels_map);
609 // Assemble mixed bilinear forms
610 mblf->Assemble();
611 mblf->Finalize();
612 // Register mixed bilinear forms associated with a single trial variable
613 // for the current test variable
614 test_mblfs->Register(coupled_var_name, mblf);
615 }
616 }
617 // Register all mixed bilinear form sets associated with a single test variable
618 _mblfs.Register(test_var_name, test_mblfs);
619 }
620}
std::vector< mfem::ParFiniteElementSpace * > _coupled_pfespaces
Pointers to finite element spaces associated with coupled variables.
NamedFieldsMap< NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs

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

◆ 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 771 of file EquationSystem.C.

774{
775 auto nlf = std::make_shared<mfem::ParNonlinearForm>(&fespace);
776 ApplyDomainNLFIntegrators(var_name, nlf, _kernels_map, std::nullopt);
777 ApplyBoundaryNLFIntegrators(var_name, nlf, _integrated_bc_map, std::nullopt);
778 return nlf;
779}
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 545 of file EquationSystem.C.

546{
547 // Register non-linear Action forms
548 for (const auto i : index_range(_test_var_names))
549 {
550 auto test_var_name = _test_var_names.at(i);
551 _nlfs.Register(test_var_name, std::make_shared<mfem::ParNonlinearForm>(_test_pfespaces.at(i)));
552 // Apply kernels
553 auto nlf = _nlfs.GetShared(test_var_name);
554 nlf->SetEssentialTrueDofs(_ess_tdof_lists.at(i));
555 ApplyDomainNLFIntegrators(test_var_name, nlf, _kernels_map, std::nullopt);
556 ApplyBoundaryNLFIntegrators(test_var_name, nlf, _integrated_bc_map, std::nullopt);
557 }
558}
NamedFieldsMap< mfem::ParNonlinearForm > _nlfs

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

◆ CheckConstrainedVariablesAreTrialVariables()

template<typename T >
void Moose::MFEM::EquationSystem::CheckConstrainedVariablesAreTrialVariables ( const Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< T > > > &  map) const
protectedinherited

Error if any variable that map holds strongly constrained DoFs for is not a trial variable of this system.

Essential BCs and constraints do not create an equation for the variable they act on; they rely on one already existing, and are only ever applied while iterating the trial variables, so a variable missing from that set would have them silently dropped.

Definition at line 377 of file EquationSystem.h.

379{
380 for (const auto & [var_name, objects] : map)
382 mooseError("MFEM variable '",
383 var_name,
384 "' has an object of type '",
385 MooseUtils::prettyCppType(objects->front().get()),
386 "' applied to it, but it is not a trial variable of the equation system. "
387 "Add a kernel acting on '",
388 var_name,
389 "', or remove it.");
390}
std::string prettyCppType(const std::string &cpp_type)
const Elem & get(const ElemType type_in)

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

◆ CheckProblemIsHomogeneous()

void Moose::MFEM::EigenproblemEquationSystem::CheckProblemIsHomogeneous ( )
protectedvirtual

Verify that the problem is homogeneous (all Dirichlet BCs are zero)

Definition at line 44 of file EigenproblemEquationSystem.C.

45{
46 // Reject nonzero Dirichlet BCs.
47 mfem::ParGridFunction & trial_gf = *(_var_ess_constraints.at(0));
48 mfem::Vector ess_values;
49 trial_gf.GetTrueDofs(ess_values);
50 ess_values.SetSubVectorComplement(_ess_tdof_lists.at(0), 0.0);
51 mfem::real_t max_ess_value =
52 mfem::GlobalLpNorm(mfem::infinity(), ess_values.Normlinf(), trial_gf.ParFESpace()->GetComm());
53 // Roundoff guard. Zero coefficients project to exactly zero.
54 if (max_ess_value > 10 * std::numeric_limits<mfem::real_t>::epsilon())
55 mooseError("Essential boundary conditions on variable '",
56 _trial_var_names.at(0),
57 "' prescribe a nonzero value. "
58 "An eigenproblem is homogeneous so only zero-valued essential boundary conditions "
59 "are meaningful. Set the boundary coefficient to zero.");
60}

Referenced by ApplyEssentialConstraints().

◆ 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 437 of file EquationSystem.C.

438{
439 mooseAssert(IsNonlinear(), "Should not be calling this method if our forms are not nonlinear");
440
441 const mfem::BlockVector block_solution(const_cast<mfem::Vector &>(sol), _block_true_offsets);
442 SetTrialVariablesFromTrueVectors(block_solution);
443
444 mfem::BlockVector block_residual(residual, _block_true_offsets);
445 for (unsigned int i = 0; i < _test_var_names.size(); i++)
446 {
447 auto & test_var_name = _test_var_names.at(i);
448 auto nlf = _nlfs.GetShared(test_var_name);
449 nlf->AddMult(block_solution.GetBlock(i), block_residual.GetBlock(i));
450 block_residual.GetBlock(i).SyncAliasMemory(block_residual);
451 }
452}
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(), Moose::MFEM::ComplexEquationSystem::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::EquationSystem::EliminateCoupledVariables ( )
protectedvirtualinherited

Perform trivial eliminations of coupled variables lacking corresponding test variables.

Reimplemented in Moose::MFEM::ComplexEquationSystem, and Moose::MFEM::TimeDependentEquationSystem.

Definition at line 292 of file EquationSystem.C.

293{
294 for (const auto & test_var_name : _test_var_names)
295 for (const auto & eliminated_var_name : _eliminated_var_names)
296 if (_mblfs.Has(test_var_name) && _mblfs.Get(test_var_name)->Has(eliminated_var_name) &&
297 !VectorContainsName(_test_var_names, eliminated_var_name))
298 {
299 auto & mblf = *_mblfs.Get(test_var_name)->Get(eliminated_var_name);
300 mblf.AddMult(*_eliminated_variables.Get(eliminated_var_name), *_lfs.Get(test_var_name), -1);
301 }
302}
Moose::MFEM::GridFunctions _eliminated_variables
Pointers to coupled variables not part of the reduced EquationSystem.
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 Moose::MFEM::EquationSystem::BuildLinearForms(), and Moose::MFEM::TimeDependentEquationSystem::EliminateCoupledVariables().

◆ FormEigenproblemMatrix()

void Moose::MFEM::EigenproblemEquationSystem::FormEigenproblemMatrix ( )
protected

Form HypreParMatrix matrix operator for the eigensolver with Dirichlet BC elimination.

Definition at line 63 of file EigenproblemEquationSystem.C.

64{
65 auto & test_var_name = _test_var_names.at(0);
66 auto blf = _blfs.Get(test_var_name);
67
68 blf->EliminateEssentialBCDiag(_ess_bdr_markers.at(0), 1.0);
69 blf->Finalize();
70 _jacobian.Reset(blf->ParallelAssemble());
71}
mfem::OperatorHandle _jacobian

Referenced by BuildEigenproblemJacobian().

◆ 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 455 of file EquationSystem.C.

456{
458 _jacobian_blocks.SetSize(_test_var_names.size(), _trial_var_names.size());
459 _jacobian_blocks = nullptr;
460
461 const mfem::BlockVector update_vector(const_cast<mfem::Vector &>(u), _block_true_offsets);
462 for (const auto i : index_range(_test_var_names))
463 {
464 auto test_var_name = _test_var_names.at(i);
465 if (_nlfs.Has(test_var_name))
466 {
467 auto nlf = _nlfs.Get(test_var_name);
468 mfem::HypreParMatrix * nlf_jac =
469 dynamic_cast<mfem::HypreParMatrix *>(&nlf->GetGradient(update_vector.GetBlock(i)));
470 mooseAssert(nlf_jac,
471 "Jacobian contribution of nonlinear form associated with " + test_var_name +
472 " is not castable into a HypreParMatrix");
473 _jacobian_blocks(i, i) = mfem::ParAdd(_h_blocks(i, i), nlf_jac);
474 }
475 else
476 _jacobian_blocks(i, i) = _h_blocks(i, i);
477 for (const auto j : index_range(_trial_var_names))
478 if (i != j) // nlf->GetGradient only contributes to on-diagonal blocks
479 _jacobian_blocks(i, j) = _h_blocks(i, j);
480 }
481 // Create monolithic matrix
482 _jacobian.Reset(mfem::HypreParMatrixFromBlocks(_jacobian_blocks));
483}
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 305 of file EquationSystem.C.

308{
309 mooseAssert(_test_var_names.size() == _trial_var_names.size(),
310 "Number of test and trial variables must be the same for block matrix assembly.");
311
312 if (_assembly_level == mfem::AssemblyLevel::LEGACY)
313 FormSystemMatrix(op, trueX, trueRHS);
314 else
315 FormSystemOperator(op, trueX, trueRHS);
316}
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().

◆ FormMassMatrix()

void Moose::MFEM::EigenproblemEquationSystem::FormMassMatrix ( EigenRHSCoefficient  rhs_coefficient)
protected

Form mass matrix for the eigensolver with Dirichlet BC elimination.

Definition at line 74 of file EigenproblemEquationSystem.C.

75{
76 mfem::ParFiniteElementSpace * fespace = _test_pfespaces.at(0);
77 std::unique_ptr<mfem::ParBilinearForm> m = std::make_unique<mfem::ParBilinearForm>(fespace);
78
79 if (fespace->GetTypicalFE()->GetRangeType() == mfem::FiniteElement::SCALAR)
80 {
81 // VectorMassIntegrator reads vdim x vdim entries of the evaluated matrix without bounds checks.
82 if (std::holds_alternative<mfem::MatrixCoefficient *>(rhs_coefficient))
83 {
84 const auto & mat_coef = *std::get<mfem::MatrixCoefficient *>(rhs_coefficient);
85 if (mat_coef.GetHeight() != fespace->GetVDim() || mat_coef.GetWidth() != fespace->GetVDim())
86 mooseError("A matrix rhs_coefficient on an H1 or L2 finite element space must be ",
87 fespace->GetVDim(),
88 "x",
89 fespace->GetVDim(),
90 " to match the number of components of the space, but it is ",
91 mat_coef.GetHeight(),
92 "x",
93 mat_coef.GetWidth(),
94 ".");
95 }
96 auto * const integ = std::visit(
97 [](auto * coef) { return new mfem::VectorMassIntegrator(*coef); }, rhs_coefficient);
98 // Otherwise, for scalar coefficients, VectorMassIntegrator defaults to the space dimension.
99 integ->SetVDim(fespace->GetVDim());
100 m->AddDomainIntegrator(integ);
101 }
102 else
103 m->AddDomainIntegrator(std::visit(
104 [](auto * coef) { return new mfem::VectorFEMassIntegrator(*coef); }, rhs_coefficient));
105
106 m->Assemble();
107 // Shift the eigenvalue corresponding to eliminated dofs to a large value. The BC DoFs on the
108 // stiffness matrix are set to 1 and the mass matrix BC DoFs are set to a small value eps, such
109 // that the eigenvalues associate with these DOFs are ~1/eps.
110 m->EliminateEssentialBCDiag(_ess_bdr_markers.at(0), std::numeric_limits<mfem::real_t>::epsilon());
111 m->Finalize();
112 _mass_rhs.Reset(m->ParallelAssemble());
113}
mfem::OperatorHandle _mass_rhs
The mass operator (e.g. the RHS operator for a generalized eigenproblem)

Referenced by BuildEigenproblemJacobian().

◆ 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 413 of file EquationSystem.C.

414{
416 height = trueX.Size();
417 width = trueRHS.Size();
418 // Store block offsets
419 _block_true_offsets.SetSize(trueX.NumBlocks() + 1);
420 _block_true_offsets[0] = 0;
421 for (unsigned i = 0; i < _trial_var_names.size(); i++)
422 _block_true_offsets[i + 1] = trueX.BlockSize(i);
423 _block_true_offsets.PartialSum();
424 FormLinearSystem(_linear_operator, trueX, trueRHS);
425}
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::EquationSystem::FormSystemMatrix ( mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
protectedvirtualinherited

Form matrix representation of linear components of system operator as a HypreParMatrix.

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

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 349 of file EquationSystem.C.

352{
353 // Allocate block operator
355 _h_blocks.SetSize(_test_var_names.size(), _trial_var_names.size());
356 _h_blocks = nullptr;
357 // Zero out RHS and sync memory
358 trueRHS = 0.0;
359 trueRHS.SyncToBlocks();
360
361 for (const auto i : index_range(_test_var_names))
362 {
363 auto test_var_name = _test_var_names.at(i);
364
365 for (const auto j : index_range(_trial_var_names))
366 {
367 auto trial_var_name = _trial_var_names.at(j);
368
369 mfem::Vector aux_x, aux_rhs;
370 mfem::ParLinearForm aux_lf(_test_pfespaces.at(i));
371 mfem::HypreParMatrix * aux_a = new mfem::HypreParMatrix;
372
373 if (test_var_name == trial_var_name)
374 {
375 mooseAssert(i == j, "Trial and test variables must have the same ordering.");
376 auto blf = _blfs.Get(test_var_name);
377 blf->FormLinearSystem(_ess_tdof_lists.at(j),
379 *_lfs.Get(test_var_name),
380 *aux_a,
381 aux_x,
382 aux_rhs,
383 /*copy_interior=*/true);
384 trueX.GetBlock(j) = aux_x;
385 }
386 else if (_mblfs.Has(test_var_name) && _mblfs.Get(test_var_name)->Has(trial_var_name))
387 {
388 auto mblf = _mblfs.Get(test_var_name)->Get(trial_var_name);
389 mblf->FormRectangularLinearSystem(_ess_tdof_lists.at(j),
390 _ess_tdof_lists.at(i),
392 aux_lf = 0.,
393 *aux_a,
394 aux_x,
395 aux_rhs);
396 }
397 else
398 continue;
399
400 trueRHS.GetBlock(i) += aux_rhs;
401 _h_blocks(i, j) = aux_a;
402 }
403 }
404 // Sync memory
405 trueX.SyncFromBlocks();
406 trueRHS.SyncFromBlocks();
407
408 // Create monolithic matrix
409 op.Reset(mfem::HypreParMatrixFromBlocks(_h_blocks));
410}
void DeleteHBlocks()
Deletes the HypreParMatrix associated with any pointer stored in _h_blocks, and then proceeds to dele...

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

◆ FormSystemOperator()

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

Form matrix-free representation of linear components of system operator.

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

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 319 of file EquationSystem.C.

322{
323 mooseAssert(_test_var_names.size() == 1 && _test_var_names.size() == _trial_var_names.size(),
324 "Non-legacy assembly is only supported for single test and trial variable systems");
325
326 auto & test_var_name = _test_var_names.at(0);
327 mfem::Vector aux_x, aux_rhs;
328 mfem::OperatorPtr aux_a;
329
330 auto blf = _blfs.Get(test_var_name);
331 blf->FormLinearSystem(_ess_tdof_lists.at(0),
333 *_lfs.Get(test_var_name),
334 aux_a,
335 aux_x,
336 aux_rhs,
337 /*copy_interior=*/true);
338
339 trueX.GetBlock(0) = aux_x;
340 trueRHS.GetBlock(0) = aux_rhs;
341 trueX.SyncFromBlocks();
342 trueRHS.SyncFromBlocks();
343
344 op.Reset(aux_a.Ptr());
345 aux_a.SetOperatorOwner(false);
346}

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

◆ 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 109 of file EquationSystem.h.

110 {
111 return _blfs.GetRef(test_var_name);
112 }

◆ GetBlockOffsets()

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

Getter for block true offsets associated with the EquationSystem operator.

Definition at line 104 of file EquationSystem.h.

104{ 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 782 of file EquationSystem.C.

783{
784 for (const auto i : index_range(_trial_var_names))
785 if (_trial_var_names.at(i) == var_name)
786 return _ess_bdr_markers.at(i);
787
788 mooseError("No essential boundary markers found for variable '", var_name, "'.");
789}

◆ GetEssentialTrueDofs()

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

Return the essentially constrained true dofs of a given trial variable: those on essential boundaries and those set by essential constraints within subdomains.

Definition at line 792 of file EquationSystem.C.

793{
794 for (const auto i : index_range(_trial_var_names))
795 if (_trial_var_names.at(i) == var_name)
796 return _ess_tdof_lists.at(i);
797
798 mooseError("No essential true dofs found for variable '", var_name, "'.");
799}

◆ 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 486 of file EquationSystem.C.

487{
489
490 if (IsNonlinear())
491 {
492 if (_assembly_level != mfem::AssemblyLevel::LEGACY)
493 mooseError("MFEM nonlinear solvers that require GetGradient() currently require legacy "
494 "assembly in EquationSystem.");
495 const_cast<EquationSystem *>(this)->FormJacobianMatrix(u);
496 }
497 else
499
500 return *_jacobian;
501}
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 117 of file EquationSystem.h.

118 {
119 return _gfuncs->GetRef(trial_var_name);
120 }

◆ GetLinearizationPoint()

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

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

Definition at line 749 of file EquationSystem.C.

750{
752 mooseError("EquationSystem::GetLinearizationPoint() called before GetGradient().");
753 return *_linearization_point;
754}

◆ GetLinearOperator()

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

Get operator handle for linear component of system operator.

Definition at line 83 of file EquationSystem.h.

83{ 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

◆ HasEssentialConstraints()

bool Moose::MFEM::EquationSystem::HasEssentialConstraints ( const std::string &  var_name) const
virtualinherited
Returns
Whether any essential constraint acts on trial variable var_name

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 802 of file EquationSystem.C.

803{
804 return _essential_constraint_map.Has(var_name);
805}

◆ Init()

void Moose::MFEM::EquationSystem::Init ( GridFunctions &  gridfunctions,
ComplexGridFunctions &  cmplx_gridfunctions,
mfem::AssemblyLevel  assembly_level 
)
virtualinherited

Initialise.

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 172 of file EquationSystem.C.

175{
176 _assembly_level = assembly_level;
177
178 // Extract which coupled variables are to be trivially eliminated and which are trial variables
182
183 for (auto & test_var_name : _test_var_names)
184 {
185 if (!gridfunctions.Has(test_var_name))
186 {
187 mooseError("MFEM variable ",
188 test_var_name,
189 " requested by equation system during initialization was "
190 "not found in gridfunctions");
191 }
192 // Store pointers to test FESpaces
193 _test_pfespaces.push_back(gridfunctions.Get(test_var_name)->ParFESpace());
194 }
195
196 for (auto & trial_var_name : _trial_var_names)
197 {
198 if (!gridfunctions.Has(trial_var_name))
199 {
200 mooseError("MFEM variable ",
201 trial_var_name,
202 " requested by equation system during initialization was "
203 "not found in gridfunctions");
204 }
205 // Create auxiliary gridfunctions for storing essential constraints from Dirichlet conditions
206 _var_ess_constraints.emplace_back(
207 std::make_unique<mfem::ParGridFunction>(gridfunctions.Get(trial_var_name)->ParFESpace()));
208 }
209
210 // Store pointers to FESpaces of all coupled variables
211 for (auto & coupled_var_name : _coupled_var_names)
212 _coupled_pfespaces.push_back(gridfunctions.Get(coupled_var_name)->ParFESpace());
213
214 // Store pointers to coupled variable GridFunctions that are to be eliminated prior to forming the
215 // jacobian
216 for (auto & eliminated_var_name : _eliminated_var_names)
217 _eliminated_variables.Register(eliminated_var_name,
218 gridfunctions.GetShared(eliminated_var_name));
219
220 // Get a reference to the GridFunctions
221 _gfuncs = &gridfunctions;
222}
void CheckConstrainedVariablesAreTrialVariables(const Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< T > > > &map) const
Error if any variable that map holds strongly constrained DoFs for is not a trial variable of this sy...
virtual void SetTrialVariableNames()
Set trial variable names from subset of coupled variables that have an associated test variable.

◆ IsComplex()

virtual bool Moose::MFEM::EquationSystem::IsComplex ( ) const
inlinevirtualinherited
Returns
Whether this EquationSystem includes complex components

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 159 of file EquationSystem.h.

159{ return false; }

◆ IsEigen()

bool Moose::MFEM::EigenproblemEquationSystem::IsEigen ( ) const
inlineoverridevirtual
Returns
Whether this EquationSystem represents an eigenproblem

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 39 of file EigenproblemEquationSystem.h.

39{ return true; }

◆ IsMultivariate()

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

Definition at line 165 of file EquationSystem.h.

165{ 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 167 of file EquationSystem.h.

167{ return _non_linear; }

Referenced by Moose::MFEM::EquationSystem::ComputeNonlinearResidual(), Moose::MFEM::EquationSystem::GetGradient(), and Moose::MFEM::EquationSystem::Mult().

◆ 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 163 of file EquationSystem.h.

163{ return false; }

◆ Mult()

void Moose::MFEM::EquationSystem::Mult ( const mfem::Vector &  u,
mfem::Vector &  residual 
) const
overrideinherited

Compute residual y = Mu.

Definition at line 428 of file EquationSystem.C.

429{
430 _linear_operator->Mult(sol, residual);
431
432 if (IsNonlinear())
433 ComputeNonlinearResidual(sol, residual);
434}
virtual void ComputeNonlinearResidual(const mfem::Vector &u, mfem::Vector &residual) const
Compute the contribution to the residual from nonlinear forms only.

◆ PrepareEigensolver()

void Moose::MFEM::EigenproblemEquationSystem::PrepareEigensolver ( EigensolverBase &  solver)

Prepare the provided eigensolver.

Definition at line 131 of file EigenproblemEquationSystem.C.

132{
133 solver.SetMassMatrix(*_mass_rhs);
134 solver.SetOperator(*_jacobian);
135}

◆ 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 93 of file EquationSystem.h.

94 {
95 _coefficient_manager = &coefficients;
96 }
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 89 of file EquationSystem.h.

89{ _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 Moose::MFEM::ComplexEquationSystem::Init().

◆ SetTrialVariablesFromTrueVectors()

void Moose::MFEM::EquationSystem::SetTrialVariablesFromTrueVectors ( const mfem::BlockVector &  trueX) const
virtualinherited

Update variable from solution vector after solve.

Reimplemented in Moose::MFEM::ComplexEquationSystem.

Definition at line 504 of file EquationSystem.C.

505{
506 for (const auto i : index_range(_trial_var_names))
507 {
508 auto & trial_var_name = _trial_var_names.at(i);
509 trueX.GetBlock(i).SyncMemory(trueX);
510 _gfuncs->Get(trial_var_name)->Distribute(&(trueX.GetBlock(i)));
511 }
512 // Solution variables changed: stored projections of solution-dependent coefficients are stale.
515}
void markSolutionChanged()
Notify quadrature function coefficients that solution variables have changed, marking the stored valu...

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

◆ VectorContainsName()

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

Friends And Related Symbol Documentation

◆ EigenproblemESProblemOperator

friend class EigenproblemESProblemOperator
friend

Definition at line 59 of file EigenproblemEquationSystem.h.

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

◆ _coefficient_manager

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

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

std::vector<mfem::Array<int> > Moose::MFEM::EquationSystem::_ess_bdr_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 345 of file EquationSystem.h.

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

◆ _essential_constraint_map

NamedFieldsMap<std::vector<std::shared_ptr<MFEMEssentialConstraint> > > Moose::MFEM::EquationSystem::_essential_constraint_map
protectedinherited

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

Named according to trial variable.

Definition at line 348 of file EquationSystem.h.

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

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

◆ _mass_rhs

mfem::OperatorHandle Moose::MFEM::EigenproblemEquationSystem::_mass_rhs
private

The mass operator (e.g. the RHS operator for a generalized eigenproblem)

Definition at line 62 of file EigenproblemEquationSystem.h.

Referenced by FormMassMatrix(), and PrepareEigensolver().

◆ _mblfs

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

◆ _nlfs

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

◆ _non_linear

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

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

Names of all test variables corresponding to linear forms in this equation system.

Definition at line 319 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystem::AddTestVariableNameIfMissing(), Moose::MFEM::EquationSystem::BuildBilinearForms(), Moose::MFEM::ComplexEquationSystem::BuildBilinearForms(), Moose::MFEM::TimeDependentEquationSystem::BuildBilinearForms(), BuildEigenproblemJacobian(), Moose::MFEM::EquationSystem::BuildLinearForms(), Moose::MFEM::ComplexEquationSystem::BuildLinearForms(), Moose::MFEM::EquationSystem::BuildMixedBilinearForms(), Moose::MFEM::ComplexEquationSystem::BuildMixedBilinearForms(), Moose::MFEM::TimeDependentEquationSystem::BuildMixedBilinearForms(), Moose::MFEM::EquationSystem::BuildNonlinearForms(), Moose::MFEM::TimeDependentEquationSystem::BuildNonlinearForms(), Moose::MFEM::EquationSystem::ComputeNonlinearResidual(), Moose::MFEM::EquationSystem::EliminateCoupledVariables(), Moose::MFEM::ComplexEquationSystem::EliminateCoupledVariables(), Moose::MFEM::TimeDependentEquationSystem::EliminateCoupledVariables(), FormEigenproblemMatrix(), Moose::MFEM::EquationSystem::FormJacobianMatrix(), Moose::MFEM::EquationSystem::FormLinearSystem(), Moose::MFEM::EquationSystem::FormSystemMatrix(), Moose::MFEM::ComplexEquationSystem::FormSystemMatrix(), Moose::MFEM::EquationSystem::FormSystemOperator(), Moose::MFEM::ComplexEquationSystem::FormSystemOperator(), Moose::MFEM::EquationSystem::GetTestVarNames(), Moose::MFEM::EquationSystem::Init(), Moose::MFEM::ComplexEquationSystem::Init(), Moose::MFEM::EquationSystem::IsMultivariate(), and Moose::MFEM::EquationSystem::SetTrialVariableNames().

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