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

Class to store weak form components (bilinear and linear forms, and optionally mixed and nonlinear forms) and build methods. More...

#include <EquationSystem.h>

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

Public Member Functions

 EquationSystem ()=default
 
 ~EquationSystem () override
 
virtual void AddTestVariableNameIfMissing (const std::string &test_var_name)
 Add test variable to EquationSystem. More...
 
virtual void AddCoupledVariableNameIfMissing (const std::string &coupled_var_name)
 Add coupled variable to EquationSystem. More...
 
virtual void AddKernel (std::shared_ptr< MFEMKernel > kernel)
 Add kernels. More...
 
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. More...
 
virtual void Init (Moose::MFEM::GridFunctions &gridfunctions, mfem::AssemblyLevel assembly_level)
 Initialise. More...
 
virtual void BuildLinearForms ()
 Build linear forms and eliminate constrained DoFs. More...
 
virtual void ApplyEssentialBC (const std::string &test_var_name, mfem::ParGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
 Apply essential BC(s) associated with test_var_name to set true DoFs of trial_gf and update markers of all essential boundaries. More...
 
virtual void ApplyEssentialBCs ()
 Update all essentially constrained true DoF markers and values on boundaries. More...
 
virtual void EliminateCoupledVariables ()
 Perform trivial eliminations of coupled variables lacking corresponding test variables. More...
 
virtual void BuildBilinearForms ()
 Build bilinear forms (diagonal Jacobian contributions) More...
 
virtual void BuildMixedBilinearForms ()
 Build mixed bilinear forms (off-diagonal Jacobian contributions) More...
 
virtual void BuildEquationSystem ()
 Build all forms comprising this EquationSystem. More...
 
void AssembleJacobian (Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > &jac_blfs, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm >> &jac_mblfs, Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > &rhs_lfs, std::vector< mfem::Array< int >> &ess_tdof_lists, std::vector< std::unique_ptr< mfem::ParGridFunction >> &var_ess_constraints, mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 Form Jacobian operator based on on- and off-diagonal bilinear form contributions, populate solution and RHS vectors of true DoFs, and apply constraints. More...
 
virtual void FormLinearSystem (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 Form linear system, with essential boundary conditions accounted for. More...
 
virtual void FormSystem (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 
virtual void FormLegacySystem (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 
virtual void BuildJacobian (mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 Build linear system, with essential boundary conditions accounted for. More...
 
void Mult (const mfem::Vector &u, mfem::Vector &residual) const override
 Compute residual y = Mu. More...
 
mfem::Operator & GetGradient (const mfem::Vector &u) const override
 Compute J = M + grad_H(u) More...
 
virtual void RecoverFEMSolution (mfem::BlockVector &trueX, Moose::MFEM::GridFunctions &gridfunctions)
 Update variable from solution vector after solve. More...
 
const std::vector< std::string > & TrialVarNames () const
 
const std::vector< std::string > & TestVarNames () const
 

Public Attributes

std::vector< mfem::Array< int > > _ess_tdof_lists
 

Protected Member Functions

void DeleteAllBlocks ()
 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. More...
 
bool VectorContainsName (const std::vector< std::string > &the_vector, const std::string &name) const
 
template<class FormType >
void ApplyDomainBLFIntegrators (const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel >>>> &kernels_map)
 Template method for applying BilinearFormIntegrators on domains from kernels to a BilinearForm, or MixedBilinearForm. More...
 
void ApplyDomainLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParLinearForm > form, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel >>>> &kernels_map)
 
template<class FormType >
void ApplyBoundaryBLFIntegrators (const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC >>>> &integrated_bc_map)
 
void ApplyBoundaryLFIntegrators (const std::string &test_var_name, std::shared_ptr< mfem::ParLinearForm > form, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC >>>> &integrated_bc_map)
 

Protected Attributes

std::vector< std::string > _coupled_var_names
 Names of all trial variables of kernels and boundary conditions added to this EquationSystem. More...
 
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. More...
 
std::vector< std::string > _eliminated_var_names
 Names of all coupled variables without a corresponding test variable. More...
 
Moose::MFEM::GridFunctions _eliminated_variables
 Pointers to coupled variables not part of the reduced EquationSystem. More...
 
std::vector< std::string > _test_var_names
 Names of all test variables corresponding to linear forms in this equation system. More...
 
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
 Pointers to finite element spaces associated with test variables. More...
 
std::vector< mfem::ParFiniteElementSpace * > _coupled_pfespaces
 Pointers to finite element spaces associated with coupled variables. More...
 
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
 
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs
 
Moose::MFEM::NamedFieldsMap< mfem::ParNonlinearForm > _nlfs
 
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
 
std::vector< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
 Gridfunctions holding essential constraints from Dirichlet BCs. More...
 
mfem::Array2D< const mfem::HypreParMatrix * > _h_blocks
 
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
 Arrays to store kernels to act on each component of weak form. More...
 
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > _integrated_bc_map
 Arrays to store integrated BCs to act on each component of weak form. More...
 
Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialBC > > > _essential_bc_map
 Arrays to store essential BCs to act on each component of weak form. More...
 
mfem::OperatorHandle _jacobian
 
mfem::AssemblyLevel _assembly_level
 

Private Member Functions

virtual void SetTrialVariableNames ()
 Set trial variable names from subset of coupled variables that have an associated test variable. More...
 

Friends

class EquationSystemProblemOperator
 
class TimeDomainEquationSystemProblemOperator
 

Detailed Description

Class to store weak form components (bilinear and linear forms, and optionally mixed and nonlinear forms) and build methods.

Definition at line 30 of file EquationSystem.h.

Constructor & Destructor Documentation

◆ EquationSystem()

Moose::MFEM::EquationSystem::EquationSystem ( )
default

◆ ~EquationSystem()

Moose::MFEM::EquationSystem::~EquationSystem ( )
override

Definition at line 18 of file EquationSystem.C.

18 { DeleteAllBlocks(); }
void DeleteAllBlocks()
Deletes the HypreParMatrix associated with any pointer stored in _h_blocks, and then proceeds to dele...

Member Function Documentation

◆ AddCoupledVariableNameIfMissing()

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

Add coupled variable to EquationSystem.

Definition at line 38 of file EquationSystem.C.

Referenced by AddIntegratedBC(), AddKernel(), Moose::MFEM::TimeDependentEquationSystem::AddKernel(), and Moose::MFEM::TimeDependentEquationSystem::SetTrialVariableNames().

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

◆ AddEssentialBC()

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

Add BC associated with essentially constrained DoFs on boundaries.

Definition at line 112 of file EquationSystem.C.

113 {
114  auto test_var_name = bc->getTestVariableName();
115  if (!_essential_bc_map.Has(test_var_name))
116  {
117  auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMEssentialBC>>>();
118  _essential_bc_map.Register(test_var_name, std::move(bcs));
119  }
120  _essential_bc_map.GetRef(test_var_name).push_back(std::move(bc));
121 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
Moose::MFEM::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.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ AddIntegratedBC()

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

Definition at line 89 of file EquationSystem.C.

90 {
91  AddTestVariableNameIfMissing(bc->getTestVariableName());
92  AddCoupledVariableNameIfMissing(bc->getTrialVariableName());
93  auto trial_var_name = bc->getTrialVariableName();
94  auto test_var_name = bc->getTestVariableName();
95  if (!_integrated_bc_map.Has(test_var_name))
96  {
97  auto integrated_bc_field_map = std::make_shared<
99  _integrated_bc_map.Register(test_var_name, std::move(integrated_bc_field_map));
100  }
101  // Register new integrated bc map if not present for the test/trial variable
102  // pair
103  if (!_integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
104  {
105  auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMIntegratedBC>>>();
106  _integrated_bc_map.Get(test_var_name)->Register(trial_var_name, std::move(bcs));
107  }
108  _integrated_bc_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(bc));
109 }
virtual void AddTestVariableNameIfMissing(const std::string &test_var_name)
Add test variable to EquationSystem.
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
Lightweight adaptor over an std::map from strings to pointer to T.
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...
virtual void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name)
Add coupled variable to EquationSystem.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > _integrated_bc_map
Arrays to store integrated BCs to act on each component of weak form.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ AddKernel()

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

Add kernels.

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 66 of file EquationSystem.C.

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

67 {
68  AddTestVariableNameIfMissing(kernel->getTestVariableName());
69  AddCoupledVariableNameIfMissing(kernel->getTrialVariableName());
70  auto trial_var_name = kernel->getTrialVariableName();
71  auto test_var_name = kernel->getTestVariableName();
72  if (!_kernels_map.Has(test_var_name))
73  {
74  auto kernel_field_map =
75  std::make_shared<Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>>();
76  _kernels_map.Register(test_var_name, std::move(kernel_field_map));
77  }
78  // Register new kernels map if not present for the test/trial variable
79  // pair
80  if (!_kernels_map.Get(test_var_name)->Has(trial_var_name))
81  {
82  auto kernels = std::make_shared<std::vector<std::shared_ptr<MFEMKernel>>>();
83  _kernels_map.Get(test_var_name)->Register(trial_var_name, std::move(kernels));
84  }
85  _kernels_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(kernel));
86 }
virtual void AddTestVariableNameIfMissing(const std::string &test_var_name)
Add test variable to EquationSystem.
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
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...
virtual void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name)
Add coupled variable to EquationSystem.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
Arrays to store kernels to act on each component of weak form.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ AddTestVariableNameIfMissing()

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

Add test variable to EquationSystem.

Definition at line 45 of file EquationSystem.C.

Referenced by AddIntegratedBC(), AddKernel(), and Moose::MFEM::TimeDependentEquationSystem::AddKernel().

46 {
47  if (!VectorContainsName(_test_var_names, test_var_name))
48  _test_var_names.push_back(test_var_name);
49 }
bool VectorContainsName(const std::vector< std::string > &the_vector, const std::string &name) const
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.

◆ 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,
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC >>>> &  integrated_bc_map 
)
protected

Definition at line 269 of file EquationSystem.h.

276 {
277  if (integrated_bc_map.Has(test_var_name) &&
278  integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
279  {
280  auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
281  for (auto & bc : bcs)
282  {
283  mfem::BilinearFormIntegrator * integ = bc->createBFIntegrator();
284  if (integ != nullptr)
285  {
286  bc->isBoundaryRestricted()
287  ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
288  : form->AddBoundaryIntegrator(std::move(integ));
289  }
290  }
291  }
292 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
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...
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ ApplyBoundaryLFIntegrators()

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

Definition at line 295 of file EquationSystem.h.

Referenced by BuildLinearForms().

301 {
302  if (integrated_bc_map.Has(test_var_name) &&
303  integrated_bc_map.Get(test_var_name)->Has(test_var_name))
304  {
305  auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
306  for (auto & bc : bcs)
307  {
308  mfem::LinearFormIntegrator * integ = bc->createLFIntegrator();
309  if (integ != nullptr)
310  {
311  bc->isBoundaryRestricted()
312  ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
313  : form->AddBoundaryIntegrator(std::move(integ));
314  }
315  }
316  }
317 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
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...
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ 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,
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel >>>> &  kernels_map 
)
protected

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

Definition at line 221 of file EquationSystem.h.

227 {
228  if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
229  {
230  auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
231  for (auto & kernel : kernels)
232  {
233  mfem::BilinearFormIntegrator * integ = kernel->createBFIntegrator();
234  if (integ != nullptr)
235  {
236  kernel->isSubdomainRestricted()
237  ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
238  : form->AddDomainIntegrator(std::move(integ));
239  }
240  }
241  }
242 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
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...
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ ApplyDomainLFIntegrators()

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

Definition at line 245 of file EquationSystem.h.

Referenced by BuildLinearForms().

250 {
251  if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(test_var_name))
252  {
253  auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
254  for (auto & kernel : kernels)
255  {
256  mfem::LinearFormIntegrator * integ = kernel->createLFIntegrator();
257  if (integ != nullptr)
258  {
259  kernel->isSubdomainRestricted()
260  ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
261  : form->AddDomainIntegrator(std::move(integ));
262  }
263  }
264  }
265 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
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...
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ ApplyEssentialBC()

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

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

Definition at line 159 of file EquationSystem.C.

Referenced by ApplyEssentialBCs(), and Moose::MFEM::TimeDependentEquationSystem::ApplyEssentialBCs().

162 {
163  if (_essential_bc_map.Has(var_name))
164  {
165  auto & bcs = _essential_bc_map.GetRef(var_name);
166  for (auto & bc : bcs)
167  {
168  // Set constrained DoFs values on essential boundaries
169  bc->ApplyBC(trial_gf);
170  // Fetch marker array labelling essential boundaries of current BC
171  mfem::Array<int> ess_bdrs(bc->getBoundaryMarkers());
172  // Add these boundary markers to the set of markers labelling all essential boundaries
173  for (auto it = 0; it != trial_gf.ParFESpace()->GetParMesh()->bdr_attributes.Max(); ++it)
174  global_ess_markers[it] = std::max(global_ess_markers[it], ess_bdrs[it]);
175  }
176  }
177 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
auto max(const L &left, const R &right)
Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMEssentialBC > > > _essential_bc_map
Arrays to store essential BCs to act on each component of weak form.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.

◆ ApplyEssentialBCs()

void Moose::MFEM::EquationSystem::ApplyEssentialBCs ( )
virtual

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

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 180 of file EquationSystem.C.

Referenced by BuildLinearForms().

181 {
182  _ess_tdof_lists.resize(_test_var_names.size());
183  for (const auto i : index_range(_test_var_names))
184  {
185  const auto & test_var_name = _test_var_names.at(i);
186  mfem::ParGridFunction & trial_gf = *(_var_ess_constraints.at(i));
187  mfem::Array<int> global_ess_markers(trial_gf.ParFESpace()->GetParMesh()->bdr_attributes.Max());
188  global_ess_markers = 0;
189  // Set strongly constrained DoFs of trial_gf on essential boundaries and add markers for all
190  // essential boundaries to the global_ess_markers array
191  ApplyEssentialBC(test_var_name, trial_gf, global_ess_markers);
192  trial_gf.ParFESpace()->GetEssentialTrueDofs(global_ess_markers, _ess_tdof_lists.at(i));
193  }
194 }
std::vector< mfem::Array< int > > _ess_tdof_lists
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
std::vector< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
virtual void ApplyEssentialBC(const std::string &test_var_name, mfem::ParGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
Apply essential BC(s) associated with test_var_name to set true DoFs of trial_gf and update markers o...
auto index_range(const T &sizable)

◆ AssembleJacobian()

void Moose::MFEM::EquationSystem::AssembleJacobian ( Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > &  jac_blfs,
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm >> &  jac_mblfs,
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > &  rhs_lfs,
std::vector< mfem::Array< int >> &  ess_tdof_lists,
std::vector< std::unique_ptr< mfem::ParGridFunction >> &  var_ess_constraints,
mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)

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

Definition at line 261 of file EquationSystem.C.

Referenced by FormLegacySystem(), and Moose::MFEM::TimeDependentEquationSystem::FormLegacySystem().

271 {
272  // Allocate block operator
273  DeleteAllBlocks();
274  _h_blocks.SetSize(_test_var_names.size(), _test_var_names.size());
275  // Form diagonal blocks.
276  for (const auto i : index_range(_test_var_names))
277  {
278  auto & test_var_name = _test_var_names.at(i);
279  auto blf = jac_blfs.Get(test_var_name);
280  auto lf = rhs_lfs.Get(test_var_name);
281  mfem::Vector aux_x, aux_rhs;
282  mfem::HypreParMatrix * aux_a = new mfem::HypreParMatrix;
283  blf->FormLinearSystem(
284  ess_tdof_lists.at(i), *(var_ess_constraints.at(i)), *lf, *aux_a, aux_x, aux_rhs);
285  _h_blocks(i, i) = aux_a;
286  trueX.GetBlock(i) = aux_x;
287  trueRHS.GetBlock(i) = aux_rhs;
288  }
289 
290  // Form off-diagonal blocks
291  for (const auto i : index_range(_test_var_names))
292  {
293  auto test_var_name = _test_var_names.at(i);
294  for (const auto j : index_range(_trial_var_names))
295  {
296  auto trial_var_name = _trial_var_names.at(j);
297 
298  mfem::Vector aux_x, aux_rhs;
299  mfem::ParLinearForm aux_lf(_test_pfespaces.at(i));
300  aux_lf = 0.0;
301  if (jac_mblfs.Has(test_var_name) && jac_mblfs.Get(test_var_name)->Has(trial_var_name))
302  {
303  auto mblf = jac_mblfs.Get(test_var_name)->Get(trial_var_name);
304  mfem::HypreParMatrix * aux_a = new mfem::HypreParMatrix;
305  mblf->FormRectangularLinearSystem(ess_tdof_lists.at(j),
306  ess_tdof_lists.at(i),
307  *(var_ess_constraints.at(j)),
308  aux_lf,
309  *aux_a,
310  aux_x,
311  aux_rhs);
312  _h_blocks(i, j) = aux_a;
313  trueRHS.GetBlock(i) += aux_rhs;
314  }
315  }
316  }
317  // Sync memory
318  trueX.SyncFromBlocks();
319  trueRHS.SyncFromBlocks();
320 
321  // Create monolithic matrix
322  op.Reset(mfem::HypreParMatrixFromBlocks(_h_blocks));
323 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
std::vector< std::string > _trial_var_names
Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom ...
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
mfem::Array2D< const mfem::HypreParMatrix * > _h_blocks
void DeleteAllBlocks()
Deletes the HypreParMatrix associated with any pointer stored in _h_blocks, and then proceeds to dele...
auto index_range(const T &sizable)

◆ BuildBilinearForms()

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

Build bilinear forms (diagonal Jacobian contributions)

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 395 of file EquationSystem.C.

Referenced by Moose::MFEM::TimeDependentEquationSystem::BuildBilinearForms(), and BuildEquationSystem().

396 {
397  // Register bilinear forms
398  for (const auto i : index_range(_test_var_names))
399  {
400  auto test_var_name = _test_var_names.at(i);
401  _blfs.Register(test_var_name, std::make_shared<mfem::ParBilinearForm>(_test_pfespaces.at(i)));
402 
403  // Apply kernels
404  auto blf = _blfs.GetShared(test_var_name);
405  blf->SetAssemblyLevel(_assembly_level);
406  ApplyBoundaryBLFIntegrators<mfem::ParBilinearForm>(
407  test_var_name, test_var_name, blf, _integrated_bc_map);
408  ApplyDomainBLFIntegrators<mfem::ParBilinearForm>(
409  test_var_name, test_var_name, blf, _kernels_map);
410  // Assemble
411  blf->Assemble();
412  }
413 }
mfem::AssemblyLevel _assembly_level
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
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...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > _integrated_bc_map
Arrays to store integrated BCs to act on each component of weak form.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
Arrays to store kernels to act on each component of weak form.
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
auto index_range(const T &sizable)

◆ BuildEquationSystem()

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

Build all forms comprising this EquationSystem.

Definition at line 457 of file EquationSystem.C.

Referenced by Moose::MFEM::EquationSystemProblemOperator::Init(), Moose::MFEM::TimeDomainEquationSystemProblemOperator::Init(), and Moose::MFEM::TimeDependentEquationSystem::UpdateEquationSystem().

458 {
462 }
virtual void BuildBilinearForms()
Build bilinear forms (diagonal Jacobian contributions)
virtual void BuildMixedBilinearForms()
Build mixed bilinear forms (off-diagonal Jacobian contributions)
virtual void BuildLinearForms()
Build linear forms and eliminate constrained DoFs.

◆ BuildJacobian()

void Moose::MFEM::EquationSystem::BuildJacobian ( mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
virtual

Build linear system, with essential boundary conditions accounted for.

Definition at line 334 of file EquationSystem.C.

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

335 {
336  height = trueX.Size();
337  width = trueRHS.Size();
338  FormLinearSystem(_jacobian, trueX, trueRHS);
339 }
mfem::OperatorHandle _jacobian
virtual void FormLinearSystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Form linear system, with essential boundary conditions accounted for.

◆ BuildLinearForms()

void Moose::MFEM::EquationSystem::BuildLinearForms ( )
virtual

Build linear forms and eliminate constrained DoFs.

Definition at line 368 of file EquationSystem.C.

Referenced by BuildEquationSystem().

369 {
370  // Register linear forms
371  for (const auto i : index_range(_test_var_names))
372  {
373  auto test_var_name = _test_var_names.at(i);
374  _lfs.Register(test_var_name, std::make_shared<mfem::ParLinearForm>(_test_pfespaces.at(i)));
375  _lfs.GetRef(test_var_name) = 0.0;
376  }
377 
378  for (auto & test_var_name : _test_var_names)
379  {
380  // Apply kernels
381  auto lf = _lfs.GetShared(test_var_name);
382  ApplyDomainLFIntegrators(test_var_name, lf, _kernels_map);
384  lf->Assemble();
385  }
386 
387  // Apply essential boundary conditions
389 
390  // Eliminate trivially eliminated variables by subtracting contributions from linear forms
392 }
virtual void EliminateCoupledVariables()
Perform trivial eliminations of coupled variables lacking corresponding test variables.
void ApplyBoundaryLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParLinearForm > form, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC >>>> &integrated_bc_map)
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
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...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMIntegratedBC > > > > _integrated_bc_map
Arrays to store integrated BCs to act on each component of weak form.
void ApplyDomainLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParLinearForm > form, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel >>>> &kernels_map)
virtual void ApplyEssentialBCs()
Update all essentially constrained true DoF markers and values on boundaries.
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
Arrays to store kernels to act on each component of weak form.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.
auto index_range(const T &sizable)

◆ BuildMixedBilinearForms()

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

Build mixed bilinear forms (off-diagonal Jacobian contributions)

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 416 of file EquationSystem.C.

Referenced by BuildEquationSystem(), and Moose::MFEM::TimeDependentEquationSystem::BuildMixedBilinearForms().

417 {
418  // Register mixed bilinear forms. Note that not all combinations may
419  // have a kernel.
420 
421  // Create mblf for each test/coupled variable pair with an added kernel.
422  // Mixed bilinear forms with coupled variables that are not trial variables are
423  // associated with contributions from eliminated variables.
424  for (const auto i : index_range(_test_var_names))
425  {
426  auto test_var_name = _test_var_names.at(i);
427  auto test_mblfs = std::make_shared<Moose::MFEM::NamedFieldsMap<mfem::ParMixedBilinearForm>>();
428  for (const auto j : index_range(_coupled_var_names))
429  {
430  const auto & coupled_var_name = _coupled_var_names.at(j);
431  auto mblf = std::make_shared<mfem::ParMixedBilinearForm>(_coupled_pfespaces.at(j),
432  _test_pfespaces.at(i));
433  // Register MixedBilinearForm if kernels exist for it, and assemble
434  // kernels
435  if (_kernels_map.Has(test_var_name) &&
436  _kernels_map.Get(test_var_name)->Has(coupled_var_name) &&
437  test_var_name != coupled_var_name)
438  {
439  mblf->SetAssemblyLevel(_assembly_level);
440  // Apply all mixed kernels with this test/trial pair
441  ApplyDomainBLFIntegrators<mfem::ParMixedBilinearForm>(
442  coupled_var_name, test_var_name, mblf, _kernels_map);
443  // Assemble mixed bilinear forms
444  mblf->Assemble();
445  // Register mixed bilinear forms associated with a single trial variable
446  // for the current test variable
447  test_mblfs->Register(coupled_var_name, mblf);
448  }
449  }
450  // Register all mixed bilinear form sets associated with a single test
451  // variable
452  _mblfs.Register(test_var_name, test_mblfs);
453  }
454 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
std::vector< mfem::ParFiniteElementSpace * > _coupled_pfespaces
Pointers to finite element spaces associated with coupled variables.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
mfem::AssemblyLevel _assembly_level
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
std::vector< std::string > _coupled_var_names
Names of all trial variables of kernels and boundary conditions added to this EquationSystem.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _kernels_map
Arrays to store kernels to act on each component of weak form.
auto index_range(const T &sizable)

◆ DeleteAllBlocks()

void Moose::MFEM::EquationSystem::DeleteAllBlocks ( )
protected

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

Referenced by AssembleJacobian(), and ~EquationSystem().

22 {
23  for (const auto i : make_range(_h_blocks.NumRows()))
24  for (const auto j : make_range(_h_blocks.NumCols()))
25  delete _h_blocks(i, j);
26  _h_blocks.DeleteAll();
27 }
mfem::Array2D< const mfem::HypreParMatrix * > _h_blocks
IntRange< T > make_range(T beg, T end)

◆ EliminateCoupledVariables()

void Moose::MFEM::EquationSystem::EliminateCoupledVariables ( )
virtual

Perform trivial eliminations of coupled variables lacking corresponding test variables.

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 197 of file EquationSystem.C.

Referenced by BuildLinearForms(), and Moose::MFEM::TimeDependentEquationSystem::EliminateCoupledVariables().

198 {
199  for (const auto & test_var_name : _test_var_names)
200  {
201  auto lf = _lfs.Get(test_var_name);
202  for (const auto & eliminated_var_name : _eliminated_var_names)
203  {
204  if (_mblfs.Has(test_var_name) && _mblfs.Get(test_var_name)->Has(eliminated_var_name))
205  {
206  auto mblf = _mblfs.Get(test_var_name)->Get(eliminated_var_name);
207  // The AddMult method in mfem::BilinearForm is not defined for non-legacy assembly
208  mfem::Vector lf_prev(lf->Size());
209  mblf->Mult(*_eliminated_variables.Get(eliminated_var_name), lf_prev);
210  *lf -= lf_prev;
211  }
212  }
213  }
214 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
std::vector< std::string > _eliminated_var_names
Names of all coupled variables without a corresponding test variable.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
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...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs

◆ FormLegacySystem()

void Moose::MFEM::EquationSystem::FormLegacySystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
virtual

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 326 of file EquationSystem.C.

Referenced by FormLinearSystem().

329 {
331 }
void AssembleJacobian(Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > &jac_blfs, Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm >> &jac_mblfs, Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > &rhs_lfs, std::vector< mfem::Array< int >> &ess_tdof_lists, std::vector< std::unique_ptr< mfem::ParGridFunction >> &var_ess_constraints, mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Form Jacobian operator based on on- and off-diagonal bilinear form contributions, populate solution a...
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
std::vector< mfem::Array< int > > _ess_tdof_lists
std::vector< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs

◆ FormLinearSystem()

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

Form linear system, with essential boundary conditions accounted for.

Definition at line 217 of file EquationSystem.C.

Referenced by BuildJacobian().

220 {
221 
222  switch (_assembly_level)
223  {
224  case mfem::AssemblyLevel::LEGACY:
225  FormLegacySystem(op, trueX, trueRHS);
226  break;
227  default:
228  mooseAssert(_test_var_names.size() == 1,
229  "Non-legacy assembly is only supported for single-variable systems");
230  mooseAssert(
231  _test_var_names.size() == _trial_var_names.size(),
232  "Non-legacy assembly is only supported for single test and trial variable systems");
233  FormSystem(op, trueX, trueRHS);
234  }
235 }
mfem::AssemblyLevel _assembly_level
std::vector< std::string > _trial_var_names
Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom ...
virtual void FormLegacySystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
virtual void FormSystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)

◆ FormSystem()

void Moose::MFEM::EquationSystem::FormSystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  trueX,
mfem::BlockVector &  trueRHS 
)
virtual

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 238 of file EquationSystem.C.

Referenced by FormLinearSystem().

241 {
242  auto & test_var_name = _test_var_names.at(0);
243  auto blf = _blfs.Get(test_var_name);
244  auto lf = _lfs.Get(test_var_name);
245  mfem::BlockVector aux_x, aux_rhs;
246  mfem::OperatorPtr aux_a;
247 
248  blf->FormLinearSystem(
249  _ess_tdof_lists.at(0), *(_var_ess_constraints.at(0)), *lf, aux_a, aux_x, aux_rhs);
250 
251  trueX.GetBlock(0) = aux_x;
252  trueRHS.GetBlock(0) = aux_rhs;
253  trueX.SyncFromBlocks();
254  trueRHS.SyncFromBlocks();
255 
256  op.Reset(aux_a.Ptr());
257  aux_a.SetOperatorOwner(false);
258 }
std::vector< mfem::Array< int > > _ess_tdof_lists
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
std::vector< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs

◆ GetGradient()

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

Compute J = M + grad_H(u)

Definition at line 350 of file EquationSystem.C.

351 {
352  return *_jacobian;
353 }
mfem::OperatorHandle _jacobian

◆ Init()

void Moose::MFEM::EquationSystem::Init ( Moose::MFEM::GridFunctions gridfunctions,
mfem::AssemblyLevel  assembly_level 
)
virtual

Initialise.

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 124 of file EquationSystem.C.

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

125 {
126  _assembly_level = assembly_level;
127 
128  for (auto & test_var_name : _test_var_names)
129  {
130  if (!gridfunctions.Has(test_var_name))
131  {
132  mooseError("MFEM variable ",
133  test_var_name,
134  " requested by equation system during initialisation was "
135  "not found in gridfunctions");
136  }
137  // Store pointers to test FESpaces
138  _test_pfespaces.push_back(gridfunctions.Get(test_var_name)->ParFESpace());
139  // Create auxiliary gridfunctions for storing essential constraints from Dirichlet conditions
140  _var_ess_constraints.emplace_back(
141  std::make_unique<mfem::ParGridFunction>(gridfunctions.Get(test_var_name)->ParFESpace()));
142  }
143 
144  // Extract which coupled variables are to be trivially eliminated and which are trial variables
146 
147  // Store pointers to FESpaces of all coupled variables
148  for (auto & coupled_var_name : _coupled_var_names)
149  _coupled_pfespaces.push_back(gridfunctions.Get(coupled_var_name)->ParFESpace());
150 
151  // Store pointers to coupled variable GridFunctions that are to be eliminated prior to forming the
152  // jacobian
153  for (auto & eliminated_var_name : _eliminated_var_names)
154  _eliminated_variables.Register(eliminated_var_name,
155  gridfunctions.GetShared(eliminated_var_name));
156 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
std::vector< mfem::ParFiniteElementSpace * > _coupled_pfespaces
Pointers to finite element spaces associated with coupled variables.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
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.
mfem::AssemblyLevel _assembly_level
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer...
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...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
std::vector< std::unique_ptr< mfem::ParGridFunction > > _var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
virtual void SetTrialVariableNames()
Set trial variable names from subset of coupled variables that have an associated test variable...
std::vector< std::string > _coupled_var_names
Names of all trial variables of kernels and boundary conditions added to this EquationSystem.
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.

◆ Mult()

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

Compute residual y = Mu.

Definition at line 342 of file EquationSystem.C.

343 {
344  _jacobian->Mult(x, residual);
345  x.HostRead();
346  residual.HostRead();
347 }
mfem::OperatorHandle _jacobian

◆ RecoverFEMSolution()

void Moose::MFEM::EquationSystem::RecoverFEMSolution ( mfem::BlockVector &  trueX,
Moose::MFEM::GridFunctions gridfunctions 
)
virtual

Update variable from solution vector after solve.

Definition at line 356 of file EquationSystem.C.

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

358 {
359  for (const auto i : index_range(_trial_var_names))
360  {
361  auto & trial_var_name = _trial_var_names.at(i);
362  trueX.GetBlock(i).SyncAliasMemory(trueX);
363  gridfunctions.Get(trial_var_name)->Distribute(&(trueX.GetBlock(i)));
364  }
365 }
std::vector< std::string > _trial_var_names
Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom ...
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...
auto index_range(const T &sizable)

◆ SetTrialVariableNames()

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

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

Reimplemented in Moose::MFEM::TimeDependentEquationSystem.

Definition at line 52 of file EquationSystem.C.

Referenced by Init().

53 {
54  // If a coupled variable has an equation associated with it,
55  // add it to the set of trial variables.
56  for (const auto & coupled_var_name : _coupled_var_names)
57  {
58  if (VectorContainsName(_test_var_names, coupled_var_name))
59  _trial_var_names.push_back(coupled_var_name);
60  else
61  _eliminated_var_names.push_back(coupled_var_name);
62  }
63 }
bool VectorContainsName(const std::vector< std::string > &the_vector, const std::string &name) const
std::vector< std::string > _eliminated_var_names
Names of all coupled variables without a corresponding test variable.
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::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
std::vector< std::string > _coupled_var_names
Names of all trial variables of kernels and boundary conditions added to this EquationSystem.

◆ TestVarNames()

const std::vector<std::string>& Moose::MFEM::EquationSystem::TestVarNames ( ) const
inline

Definition at line 116 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystemProblemOperator::SetGridFunctions(), and Moose::MFEM::TimeDomainEquationSystemProblemOperator::SetGridFunctions().

116 { return _test_var_names; }
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.

◆ TrialVarNames()

const std::vector<std::string>& Moose::MFEM::EquationSystem::TrialVarNames ( ) const
inline

Definition at line 115 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystemProblemOperator::SetGridFunctions(), and Moose::MFEM::TimeDomainEquationSystemProblemOperator::SetGridFunctions().

115 { return _trial_var_names; }
std::vector< std::string > _trial_var_names
Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom ...

◆ VectorContainsName()

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

Definition at line 30 of file EquationSystem.C.

Referenced by AddCoupledVariableNameIfMissing(), AddTestVariableNameIfMissing(), SetTrialVariableNames(), and Moose::MFEM::TimeDependentEquationSystem::SetTrialVariableNames().

32 {
33  auto iter = std::find(the_vector.begin(), the_vector.end(), name);
34  return (iter != the_vector.end());
35 }
std::string name(const ElemQuality q)
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition: KokkosUtils.h:42

Friends And Related Function Documentation

◆ EquationSystemProblemOperator

friend class EquationSystemProblemOperator
friend

Definition at line 34 of file EquationSystem.h.

◆ TimeDomainEquationSystemProblemOperator

Definition at line 35 of file EquationSystem.h.

Member Data Documentation

◆ _assembly_level

mfem::AssemblyLevel Moose::MFEM::EquationSystem::_assembly_level
protected

◆ _blfs

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

◆ _coupled_pfespaces

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

Pointers to finite element spaces associated with coupled variables.

Definition at line 153 of file EquationSystem.h.

Referenced by BuildMixedBilinearForms(), and Init().

◆ _coupled_var_names

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

Names of all trial variables of kernels and boundary conditions added to this EquationSystem.

Definition at line 139 of file EquationSystem.h.

Referenced by AddCoupledVariableNameIfMissing(), BuildMixedBilinearForms(), Init(), SetTrialVariableNames(), and Moose::MFEM::TimeDependentEquationSystem::SetTrialVariableNames().

◆ _eliminated_var_names

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

Names of all coupled variables without a corresponding test variable.

Definition at line 145 of file EquationSystem.h.

Referenced by EliminateCoupledVariables(), Init(), SetTrialVariableNames(), and Moose::MFEM::TimeDependentEquationSystem::SetTrialVariableNames().

◆ _eliminated_variables

Moose::MFEM::GridFunctions Moose::MFEM::EquationSystem::_eliminated_variables
protected

◆ _ess_tdof_lists

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

◆ _essential_bc_map

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

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

Named according to test variable.

Definition at line 212 of file EquationSystem.h.

Referenced by AddEssentialBC(), and ApplyEssentialBC().

◆ _h_blocks

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

Definition at line 199 of file EquationSystem.h.

Referenced by AssembleJacobian(), and DeleteAllBlocks().

◆ _integrated_bc_map

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

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

Named according to test and trial variables.

Definition at line 209 of file EquationSystem.h.

Referenced by AddIntegratedBC(), BuildBilinearForms(), Moose::MFEM::TimeDependentEquationSystem::BuildBilinearForms(), and BuildLinearForms().

◆ _jacobian

mfem::OperatorHandle Moose::MFEM::EquationSystem::_jacobian
mutableprotected

Definition at line 214 of file EquationSystem.h.

Referenced by BuildJacobian(), GetGradient(), and Mult().

◆ _kernels_map

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

Arrays to store kernels to act on each component of weak form.

Named according to test and trial variables.

Definition at line 204 of file EquationSystem.h.

Referenced by AddKernel(), BuildBilinearForms(), BuildLinearForms(), and BuildMixedBilinearForms().

◆ _lfs

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

◆ _mblfs

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

◆ _nlfs

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

Definition at line 158 of file EquationSystem.h.

◆ _test_pfespaces

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

◆ _test_var_names

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

◆ _trial_var_names

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

Subset of _coupled_var_names of all variables corresponding to gridfunctions with degrees of freedom that comprise the state vector of this EquationSystem.

This will differ from _coupled_var_names when time derivatives or other eliminated variables are present.

Definition at line 143 of file EquationSystem.h.

Referenced by AssembleJacobian(), Moose::MFEM::TimeDependentEquationSystem::BuildMixedBilinearForms(), FormLinearSystem(), RecoverFEMSolution(), SetTrialVariableNames(), Moose::MFEM::TimeDependentEquationSystem::SetTrialVariableNames(), and TrialVarNames().

◆ _var_ess_constraints

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

Gridfunctions holding essential constraints from Dirichlet BCs.

Definition at line 197 of file EquationSystem.h.

Referenced by ApplyEssentialBCs(), Moose::MFEM::TimeDependentEquationSystem::ApplyEssentialBCs(), FormLegacySystem(), FormSystem(), and Init().


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