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

Class to store weak form components for time dependent PDEs. More...

#include <EquationSystem.h>

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

Public Member Functions

 TimeDependentEquationSystem ()
 
void AddCoupledVariableNameIfMissing (const std::string &coupled_var_name) override
 Add coupled variable to EquationSystem. More...
 
virtual void SetTimeStep (double dt)
 
virtual void UpdateEquationSystem ()
 
virtual void AddKernel (std::shared_ptr< MFEMKernel > kernel) override
 Add kernels. More...
 
virtual void BuildBilinearForms () override
 Build bilinear forms. More...
 
virtual void FormLegacySystem (mfem::OperatorHandle &op, mfem::BlockVector &truedXdt, mfem::BlockVector &trueRHS) override
 
virtual void FormSystem (mfem::OperatorHandle &op, mfem::BlockVector &truedXdt, mfem::BlockVector &trueRHS) override
 
virtual void AddTestVariableNameIfMissing (const std::string &test_var_name)
 Add test variable to EquationSystem. More...
 
virtual void AddIntegratedBC (std::shared_ptr< MFEMIntegratedBC > kernel)
 
virtual void AddEssentialBC (std::shared_ptr< MFEMEssentialBC > bc)
 
virtual void Init (Moose::MFEM::GridFunctions &gridfunctions, const Moose::MFEM::FESpaces &fespaces, mfem::AssemblyLevel assembly_level)
 Initialise. More...
 
virtual void BuildLinearForms ()
 Build linear forms and eliminate constrained DoFs. More...
 
virtual void ApplyEssentialBCs ()
 
virtual void EliminateCoupledVariables ()
 
virtual void BuildMixedBilinearForms ()
 
virtual void BuildEquationSystem ()
 
virtual void FormLinearSystem (mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
 Form linear system, with essential boundary conditions accounted for. More...
 
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

mfem::ConstantCoefficient _dt_coef
 Coefficient for timestep scaling. More...
 
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _td_kernels_map
 
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _td_blfs
 Container to store contributions to weak form of the form (F du/dt, v) More...
 
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 () override
 Set trial variable names from subset of coupled variables that have an associated test variable. More...
 

Detailed Description

Class to store weak form components for time dependent PDEs.

Definition at line 298 of file EquationSystem.h.

Constructor & Destructor Documentation

◆ TimeDependentEquationSystem()

Moose::MFEM::TimeDependentEquationSystem::TimeDependentEquationSystem ( )

Definition at line 448 of file EquationSystem.C.

448 : _dt_coef(1.0) {}
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.

Member Function Documentation

◆ AddCoupledVariableNameIfMissing()

void Moose::MFEM::TimeDependentEquationSystem::AddCoupledVariableNameIfMissing ( const std::string &  coupled_var_name)
overridevirtual

Add coupled variable to EquationSystem.

The TimeDependentEquationSystem operator expects to act on a vector of variable time derivatives, so the coupled variable must be the time derivative of the 'base' variable
When implicit, also register test_var_name in _eliminated_variables for the elimination of 'old' variable values from the previous timestep

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 451 of file EquationSystem.C.

Referenced by AddKernel().

452 {
459 }
std::string GetTimeDerivativeName(std::string name)
virtual void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name)
Add coupled variable to EquationSystem.

◆ AddEssentialBC()

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

Definition at line 114 of file EquationSystem.C.

115 {
116  AddTestVariableNameIfMissing(bc->getTestVariableName());
117  auto test_var_name = bc->getTestVariableName();
118  if (!_essential_bc_map.Has(test_var_name))
119  {
120  auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMEssentialBC>>>();
121  _essential_bc_map.Register(test_var_name, std::move(bcs));
122  }
123  _essential_bc_map.GetRef(test_var_name).push_back(std::move(bc));
124 }
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.
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)
virtualinherited

Definition at line 91 of file EquationSystem.C.

92 {
93  AddTestVariableNameIfMissing(bc->getTestVariableName());
94  AddCoupledVariableNameIfMissing(bc->getTrialVariableName());
95  auto trial_var_name = bc->getTrialVariableName();
96  auto test_var_name = bc->getTestVariableName();
97  if (!_integrated_bc_map.Has(test_var_name))
98  {
99  auto integrated_bc_field_map = std::make_shared<
101  _integrated_bc_map.Register(test_var_name, std::move(integrated_bc_field_map));
102  }
103  // Register new integrated bc map if not present for the test/trial variable
104  // pair
105  if (!_integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
106  {
107  auto bcs = std::make_shared<std::vector<std::shared_ptr<MFEMIntegratedBC>>>();
108  _integrated_bc_map.Get(test_var_name)->Register(trial_var_name, std::move(bcs));
109  }
110  _integrated_bc_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(bc));
111 }
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::TimeDependentEquationSystem::AddKernel ( std::shared_ptr< MFEMKernel kernel)
overridevirtual

Add kernels.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 501 of file EquationSystem.C.

502 {
503  if (kernel->getTrialVariableName() == GetTimeDerivativeName(kernel->getTestVariableName()))
504  {
505  auto trial_var_name = kernel->getTrialVariableName();
506  auto test_var_name = kernel->getTestVariableName();
507  AddTestVariableNameIfMissing(test_var_name);
508  AddCoupledVariableNameIfMissing(test_var_name);
509 
510  if (!_td_kernels_map.Has(test_var_name))
511  {
512  auto kernel_field_map =
513  std::make_shared<Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>>();
514  _td_kernels_map.Register(test_var_name, std::move(kernel_field_map));
515  }
516  // Register new kernels map if not present for the test variable
517  if (!_td_kernels_map.Get(test_var_name)->Has(test_var_name))
518  {
519  auto kernels = std::make_shared<std::vector<std::shared_ptr<MFEMKernel>>>();
520  _td_kernels_map.Get(test_var_name)->Register(test_var_name, std::move(kernels));
521  }
522  _td_kernels_map.GetRef(test_var_name).Get(test_var_name)->push_back(std::move(kernel));
523  }
524  else
525  {
527  }
528 }
virtual void AddTestVariableNameIfMissing(const std::string &test_var_name)
Add test variable to EquationSystem.
virtual void AddKernel(std::shared_ptr< MFEMKernel > kernel)
Add kernels.
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _td_kernels_map
void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name) override
Add coupled variable to EquationSystem.
std::string GetTimeDerivativeName(std::string 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...
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.

◆ AddTestVariableNameIfMissing()

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

Add test variable to EquationSystem.

Definition at line 47 of file EquationSystem.C.

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

48 {
49  if (!VectorContainsName(_test_var_names, test_var_name))
50  _test_var_names.push_back(test_var_name);
51 }
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 
)
protectedinherited

Definition at line 245 of file EquationSystem.h.

252 {
253  if (integrated_bc_map.Has(test_var_name) &&
254  integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
255  {
256  auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
257  for (auto & bc : bcs)
258  {
259  mfem::BilinearFormIntegrator * integ = bc->createBFIntegrator();
260  if (integ != nullptr)
261  {
262  bc->isBoundaryRestricted()
263  ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
264  : form->AddBoundaryIntegrator(std::move(integ));
265  }
266  }
267  }
268 }
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 
)
inlineprotectedinherited

Definition at line 271 of file EquationSystem.h.

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

277 {
278  if (integrated_bc_map.Has(test_var_name) &&
279  integrated_bc_map.Get(test_var_name)->Has(test_var_name))
280  {
281  auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
282  for (auto & bc : bcs)
283  {
284  mfem::LinearFormIntegrator * integ = bc->createLFIntegrator();
285  if (integ != nullptr)
286  {
287  bc->isBoundaryRestricted()
288  ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
289  : form->AddBoundaryIntegrator(std::move(integ));
290  }
291  }
292  }
293 }
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 
)
protectedinherited

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

Definition at line 197 of file EquationSystem.h.

203 {
204  if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
205  {
206  auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
207  for (auto & kernel : kernels)
208  {
209  mfem::BilinearFormIntegrator * integ = kernel->createBFIntegrator();
210  if (integ != nullptr)
211  {
212  kernel->isSubdomainRestricted()
213  ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
214  : form->AddDomainIntegrator(std::move(integ));
215  }
216  }
217  }
218 }
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 
)
inlineprotectedinherited

Definition at line 221 of file EquationSystem.h.

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

226 {
227  if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(test_var_name))
228  {
229  auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
230  for (auto & kernel : kernels)
231  {
232  mfem::LinearFormIntegrator * integ = kernel->createLFIntegrator();
233  if (integ != nullptr)
234  {
235  kernel->isSubdomainRestricted()
236  ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
237  : form->AddDomainIntegrator(std::move(integ));
238  }
239  }
240  }
241 }
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.

◆ ApplyEssentialBCs()

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

Definition at line 164 of file EquationSystem.C.

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

165 {
166  _ess_tdof_lists.resize(_test_var_names.size());
167  for (const auto i : index_range(_test_var_names))
168  {
169  auto test_var_name = _test_var_names.at(i);
170  if (!_essential_bc_map.Has(test_var_name))
171  continue;
172 
173  // Set default value of gridfunction used in essential BC. Values
174  // overwritten in applyEssentialBCs
175  mfem::ParGridFunction & trial_gf(*(_var_ess_constraints.at(i)));
176  auto * const pmesh = _test_pfespaces.at(i)->GetParMesh();
177  mooseAssert(pmesh, "parallel mesh is null");
178 
179  auto bcs = _essential_bc_map.GetRef(test_var_name);
180  mfem::Array<int> global_ess_markers(pmesh->bdr_attributes.Max());
181  global_ess_markers = 0;
182  for (auto & bc : bcs)
183  {
184  bc->ApplyBC(trial_gf);
185 
186  mfem::Array<int> ess_bdrs(bc->getBoundaryMarkers());
187  for (auto it = 0; it != pmesh->bdr_attributes.Max(); ++it)
188  {
189  global_ess_markers[it] = std::max(global_ess_markers[it], ess_bdrs[it]);
190  }
191  }
192  trial_gf.FESpace()->GetEssentialTrueDofs(global_ess_markers, _ess_tdof_lists.at(i));
193  }
194 }
bool Has(const std::string &field_name) const
Predicate to check if a field is registered with name field_name.
std::vector< mfem::Array< int > > _ess_tdof_lists
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.
std::vector< mfem::ParFiniteElementSpace * > _test_pfespaces
Pointers to finite element spaces associated with test variables.
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.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.
auto index_range(const T &sizable)

◆ BuildBilinearForms()

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

Build bilinear forms.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 531 of file EquationSystem.C.

532 {
534 
535  // Build and assemble bilinear forms acting on time derivatives
536  for (const auto i : index_range(_test_var_names))
537  {
538  auto test_var_name = _test_var_names.at(i);
539 
540  _td_blfs.Register(test_var_name,
541  std::make_shared<mfem::ParBilinearForm>(_test_pfespaces.at(i)));
542 
543  // Apply kernels to td_blf
544  auto td_blf = _td_blfs.GetShared(test_var_name);
545  td_blf->SetAssemblyLevel(_assembly_level);
546  ApplyBoundaryBLFIntegrators<mfem::ParBilinearForm>(
547  test_var_name, test_var_name, td_blf, _integrated_bc_map);
548  ApplyDomainBLFIntegrators<mfem::ParBilinearForm>(
549  test_var_name, test_var_name, td_blf, _td_kernels_map);
550 
551  // Recover and scale integrators from blf. This is to apply the dt*du/dt contributions from the
552  // operator on the trial variable in the implicit integration scheme
553  auto blf = _blfs.Get(test_var_name);
554  auto integs = blf->GetDBFI();
555  auto b_integs = blf->GetBBFI();
556  auto markers = blf->GetBBFI_Marker();
557 
558  // If implicit contributions exist, scale them by timestep and add to td_blf
559  if (integs->Size() || b_integs->Size())
560  {
561  mfem::SumIntegrator * sum = new mfem::SumIntegrator(false);
562  ScaleIntegrator * scaled_sum = new ScaleIntegrator(sum, _dt_coef.constant, true);
563 
564  for (int i = 0; i < integs->Size(); ++i)
565  sum->AddIntegrator(*integs[i]);
566 
567  for (int i = 0; i < b_integs->Size(); ++i)
568  td_blf->AddBoundaryIntegrator(new ScaleIntegrator(*b_integs[i], _dt_coef.constant, false),
569  *(*markers[i]));
570 
571  // scaled_sum is owned by td_blf
572  td_blf->AddDomainIntegrator(scaled_sum);
573  }
574 
575  // Assemble form
576  td_blf->Assemble();
577  }
578 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
virtual void BuildBilinearForms()
Build bilinear forms.
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _td_kernels_map
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.
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< mfem::ParBilinearForm > _td_blfs
Container to store contributions to weak form of the form (F du/dt, v)
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
auto index_range(const T &sizable)

◆ BuildEquationSystem()

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

Definition at line 441 of file EquationSystem.C.

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

442 {
446 }
virtual void BuildBilinearForms()
Build bilinear forms.
virtual void BuildMixedBilinearForms()
virtual void BuildLinearForms()
Build linear forms and eliminate constrained DoFs.

◆ BuildJacobian()

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

Build linear system, with essential boundary conditions accounted for.

Definition at line 320 of file EquationSystem.C.

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

321 {
322  height = trueX.Size();
323  width = trueRHS.Size();
324  FormLinearSystem(_jacobian, trueX, trueRHS);
325 }
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 ( )
virtualinherited

Build linear forms and eliminate constrained DoFs.

Definition at line 354 of file EquationSystem.C.

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

355 {
356  // Register linear forms
357  for (const auto i : index_range(_test_var_names))
358  {
359  auto test_var_name = _test_var_names.at(i);
360  _lfs.Register(test_var_name, std::make_shared<mfem::ParLinearForm>(_test_pfespaces.at(i)));
361  _lfs.GetRef(test_var_name) = 0.0;
362  }
363 
364  // Apply boundary conditions
366 
367  for (auto & test_var_name : _test_var_names)
368  {
369  // Apply kernels
370  auto lf = _lfs.GetShared(test_var_name);
371  ApplyDomainLFIntegrators(test_var_name, lf, _kernels_map);
373  lf->Assemble();
374  }
375 
376  // Eliminate trivially eliminated variables by subtracting contributions from linear forms
378 }
virtual void EliminateCoupledVariables()
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()
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 ( )
virtualinherited

Definition at line 402 of file EquationSystem.C.

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

403 {
404  // Register mixed bilinear forms. Note that not all combinations may
405  // have a kernel
406 
407  // Create mblf for each test/coupled variable pair with an added kernel
408  for (const auto i : index_range(_test_var_names))
409  {
410  auto test_var_name = _test_var_names.at(i);
411  auto test_mblfs = std::make_shared<Moose::MFEM::NamedFieldsMap<mfem::ParMixedBilinearForm>>();
412  for (const auto j : index_range(_coupled_var_names))
413  {
414  const auto & coupled_var_name = _coupled_var_names.at(j);
415  auto mblf = std::make_shared<mfem::ParMixedBilinearForm>(_coupled_pfespaces.at(j),
416  _test_pfespaces.at(i));
417  // Register MixedBilinearForm if kernels exist for it, and assemble
418  // kernels
419  if (_kernels_map.Has(test_var_name) &&
420  _kernels_map.Get(test_var_name)->Has(coupled_var_name) &&
421  test_var_name != coupled_var_name)
422  {
423  mblf->SetAssemblyLevel(_assembly_level);
424  // Apply all mixed kernels with this test/trial pair
425  ApplyDomainBLFIntegrators<mfem::ParMixedBilinearForm>(
426  coupled_var_name, test_var_name, mblf, _kernels_map);
427  // Assemble mixed bilinear forms
428  mblf->Assemble();
429  // Register mixed bilinear forms associated with a single trial variable
430  // for the current test variable
431  test_mblfs->Register(coupled_var_name, mblf);
432  }
433  }
434  // Register all mixed bilinear form sets associated with a single test
435  // variable
436  _mblfs.Register(test_var_name, test_mblfs);
437  }
438 }
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 ( )
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 21 of file EquationSystem.C.

Referenced by Moose::MFEM::EquationSystem::FormLegacySystem(), FormLegacySystem(), and Moose::MFEM::EquationSystem::~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 ( )
virtualinherited

Definition at line 197 of file EquationSystem.C.

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

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  mblf->AddMult(*_eliminated_variables.Get(eliminated_var_name), *lf, -1.0);
208  }
209  }
210  }
211 }
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::TimeDependentEquationSystem::FormLegacySystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  truedXdt,
mfem::BlockVector &  trueRHS 
)
overridevirtual

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 581 of file EquationSystem.C.

584 {
585 
586  // Allocate block operator
587  DeleteAllBlocks();
588  _h_blocks.SetSize(_test_var_names.size(), _test_var_names.size());
589  // Form diagonal blocks.
590  for (const auto i : index_range(_test_var_names))
591  {
592  auto & test_var_name = _test_var_names.at(i);
593  auto td_blf = _td_blfs.Get(test_var_name);
594  auto blf = _blfs.Get(test_var_name);
595  auto lf = _lfs.Get(test_var_name);
596  // if implicit, add contribution to linear form from terms involving state
597  // variable at previous timestep: {
598  blf->AddMult(*_eliminated_variables.Get(test_var_name), *lf, -1.0);
599  // }
600  mfem::Vector aux_x, aux_rhs;
601  // Update solution values on Dirichlet values to be in terms of du/dt instead of u
602  mfem::Vector bc_x = *(_var_ess_constraints.at(i).get());
603  bc_x -= *_eliminated_variables.Get(test_var_name);
604  bc_x /= _dt_coef.constant;
605 
606  // Form linear system for operator acting on vector of du/dt
607  mfem::HypreParMatrix * aux_a = new mfem::HypreParMatrix;
608  td_blf->FormLinearSystem(_ess_tdof_lists.at(i), bc_x, *lf, *aux_a, aux_x, aux_rhs);
609  _h_blocks(i, i) = aux_a;
610  truedXdt.GetBlock(i) = aux_x;
611  trueRHS.GetBlock(i) = aux_rhs;
612  }
613 
614  truedXdt.SyncFromBlocks();
615  trueRHS.SyncFromBlocks();
616 
617  // Create monolithic matrix
618  op.Reset(mfem::HypreParMatrixFromBlocks(_h_blocks));
619 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
Moose::MFEM::GridFunctions _eliminated_variables
Pointers to coupled variables not part of the reduced EquationSystem.
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.
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...
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _td_blfs
Container to store contributions to weak form of the form (F du/dt, v)
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
auto index_range(const T &sizable)

◆ FormLinearSystem()

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

Form linear system, with essential boundary conditions accounted for.

Definition at line 214 of file EquationSystem.C.

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

217 {
218 
219  switch (_assembly_level)
220  {
221  case mfem::AssemblyLevel::LEGACY:
222  FormLegacySystem(op, trueX, trueRHS);
223  break;
224  default:
225  mooseAssert(_test_var_names.size() == 1,
226  "Non-legacy assembly is only supported for single-variable systems");
227  mooseAssert(
228  _test_var_names.size() == _trial_var_names.size(),
229  "Non-legacy assembly is only supported for single test and trial variable systems");
230  FormSystem(op, trueX, trueRHS);
231  }
232 }
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::TimeDependentEquationSystem::FormSystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  truedXdt,
mfem::BlockVector &  trueRHS 
)
overridevirtual

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 622 of file EquationSystem.C.

625 {
626  auto & test_var_name = _test_var_names.at(0);
627  auto td_blf = _td_blfs.Get(test_var_name);
628  auto blf = _blfs.Get(test_var_name);
629  auto lf = _lfs.Get(test_var_name);
630  // if implicit, add contribution to linear form from terms involving state
631  // variable at previous timestep: {
632 
633  // The AddMult method in mfem::BilinearForm is not defined for non-legacy assembly
634  mfem::Vector lf_prev(lf->Size());
635  blf->Mult(*_eliminated_variables.Get(test_var_name), lf_prev);
636  *lf -= lf_prev;
637  // }
638  mfem::Vector aux_x, aux_rhs;
639  // Update solution values on Dirichlet values to be in terms of du/dt instead of u
640  mfem::Vector bc_x = *(_var_ess_constraints.at(0).get());
641  bc_x -= *_eliminated_variables.Get(test_var_name);
642  bc_x /= _dt_coef.constant;
643 
644  // Form linear system for operator acting on vector of du/dt
645  mfem::OperatorPtr aux_a;
646  td_blf->FormLinearSystem(_ess_tdof_lists.at(0), bc_x, *lf, aux_a, aux_x, aux_rhs);
647 
648  truedXdt.GetBlock(0) = aux_x;
649  trueRHS.GetBlock(0) = aux_rhs;
650  truedXdt.SyncFromBlocks();
651  trueRHS.SyncFromBlocks();
652 
653  // Create monolithic matrix
654  op.Reset(aux_a.Ptr());
655  aux_a.SetOperatorOwner(false);
656 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
Moose::MFEM::GridFunctions _eliminated_variables
Pointers to coupled variables not part of the reduced EquationSystem.
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::ParBilinearForm > _td_blfs
Container to store contributions to weak form of the form (F du/dt, v)
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs

◆ GetGradient()

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

Compute J = M + grad_H(u)

Definition at line 336 of file EquationSystem.C.

337 {
338  return *_jacobian;
339 }
mfem::OperatorHandle _jacobian

◆ Init()

void Moose::MFEM::EquationSystem::Init ( Moose::MFEM::GridFunctions gridfunctions,
const Moose::MFEM::FESpaces fespaces,
mfem::AssemblyLevel  assembly_level 
)
virtualinherited

Initialise.

Definition at line 127 of file EquationSystem.C.

130 {
131  _assembly_level = assembly_level;
132 
133  for (auto & test_var_name : _test_var_names)
134  {
135  if (!gridfunctions.Has(test_var_name))
136  {
137  mooseError("MFEM variable ",
138  test_var_name,
139  " requested by equation system during initialisation was "
140  "not found in gridfunctions");
141  }
142  // Store pointers to test FESpaces
143  _test_pfespaces.push_back(gridfunctions.Get(test_var_name)->ParFESpace());
144  // Create auxiliary gridfunctions for storing essential constraints from Dirichlet conditions
145  _var_ess_constraints.emplace_back(
146  std::make_unique<mfem::ParGridFunction>(gridfunctions.Get(test_var_name)->ParFESpace()));
147  }
148 
149  // Store pointers to FESpaces of all coupled variables
150  for (auto & coupled_var_name : _coupled_var_names)
151  _coupled_pfespaces.push_back(gridfunctions.Get(coupled_var_name)->ParFESpace());
152 
153  // Extract which coupled variables are to be trivially eliminated and which are trial variables
155 
156  // Store pointers to coupled variable GridFunctions that are to be eliminated prior to forming the
157  // jacobian
158  for (auto & eliminated_var_name : _eliminated_var_names)
159  _eliminated_variables.Register(eliminated_var_name,
160  gridfunctions.GetShared(eliminated_var_name));
161 }
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:333
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
overrideinherited

Compute residual y = Mu.

Definition at line 328 of file EquationSystem.C.

329 {
330  _jacobian->Mult(x, residual);
331  x.HostRead();
332  residual.HostRead();
333 }
mfem::OperatorHandle _jacobian

◆ RecoverFEMSolution()

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

Update variable from solution vector after solve.

Definition at line 342 of file EquationSystem.C.

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

344 {
345  for (const auto i : index_range(_trial_var_names))
346  {
347  auto & trial_var_name = _trial_var_names.at(i);
348  trueX.GetBlock(i).SyncAliasMemory(trueX);
349  gridfunctions.Get(trial_var_name)->Distribute(&(trueX.GetBlock(i)));
350  }
351 }
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)

◆ SetTimeStep()

void Moose::MFEM::TimeDependentEquationSystem::SetTimeStep ( double  dt)
virtual

Definition at line 462 of file EquationSystem.C.

Referenced by Moose::MFEM::TimeDomainEquationSystemProblemOperator::BuildEquationSystemOperator().

463 {
464  if (fabs(dt - _dt_coef.constant) > 1.0e-12 * dt)
465  {
466  _dt_coef.constant = dt;
467  for (auto test_var_name : _test_var_names)
468  {
469  auto blf = _blfs.Get(test_var_name);
470  blf->Update();
471  blf->Assemble();
472  }
473  }
474 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
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::ParBilinearForm > _blfs

◆ SetTrialVariableNames()

void Moose::MFEM::TimeDependentEquationSystem::SetTrialVariableNames ( )
overrideprivatevirtual

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

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 477 of file EquationSystem.C.

478 {
479  // If a coupled variable has an equation associated with it,
480  // add it to the set of trial variables.
481  for (const auto & coupled_var_name : _coupled_var_names)
482  {
483  for (const auto & test_var_name : _test_var_names)
484  {
485  const auto time_derivative_test_var_name = GetTimeDerivativeName(test_var_name);
486  if (time_derivative_test_var_name == coupled_var_name)
487  {
488  if (!VectorContainsName(_trial_var_names, coupled_var_name))
489  _trial_var_names.push_back(coupled_var_name);
490  }
491  else
492  {
493  if (!VectorContainsName(_eliminated_var_names, coupled_var_name))
494  _eliminated_var_names.push_back(coupled_var_name);
495  }
496  }
497  }
498 }
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::string GetTimeDerivativeName(std::string name)
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
inlineinherited

Definition at line 92 of file EquationSystem.h.

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

92 { 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
inlineinherited

Definition at line 91 of file EquationSystem.h.

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

91 { 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 ...

◆ UpdateEquationSystem()

void Moose::MFEM::TimeDependentEquationSystem::UpdateEquationSystem ( )
virtual

◆ VectorContainsName()

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

Definition at line 30 of file EquationSystem.C.

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

32 {
33 
34  auto iter = std::find(the_vector.begin(), the_vector.end(), name);
35 
36  return (iter != the_vector.end());
37 }
std::string name(const ElemQuality q)

Member Data Documentation

◆ _assembly_level

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

◆ _blfs

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

◆ _coupled_pfespaces

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

Pointers to finite element spaces associated with coupled variables.

Definition at line 129 of file EquationSystem.h.

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

◆ _coupled_var_names

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

◆ _dt_coef

mfem::ConstantCoefficient Moose::MFEM::TimeDependentEquationSystem::_dt_coef
protected

Coefficient for timestep scaling.

Definition at line 319 of file EquationSystem.h.

Referenced by BuildBilinearForms(), FormLegacySystem(), FormSystem(), and SetTimeStep().

◆ _eliminated_var_names

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

Names of all coupled variables without a corresponding test variable.

Definition at line 121 of file EquationSystem.h.

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

◆ _eliminated_variables

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

Pointers to coupled variables not part of the reduced EquationSystem.

Definition at line 123 of file EquationSystem.h.

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

◆ _ess_tdof_lists

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

◆ _essential_bc_map

Moose::MFEM::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 188 of file EquationSystem.h.

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

◆ _h_blocks

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

◆ _integrated_bc_map

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

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

Named according to test and trial variables.

Definition at line 185 of file EquationSystem.h.

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

◆ _jacobian

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

◆ _kernels_map

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

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

Named according to test and trial variables.

Definition at line 180 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystem::AddKernel(), Moose::MFEM::EquationSystem::BuildBilinearForms(), Moose::MFEM::EquationSystem::BuildLinearForms(), and Moose::MFEM::EquationSystem::BuildMixedBilinearForms().

◆ _lfs

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

◆ _mblfs

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

◆ _nlfs

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

Definition at line 134 of file EquationSystem.h.

◆ _td_blfs

Moose::MFEM::NamedFieldsMap<mfem::ParBilinearForm> Moose::MFEM::TimeDependentEquationSystem::_td_blfs
protected

Container to store contributions to weak form of the form (F du/dt, v)

Definition at line 324 of file EquationSystem.h.

Referenced by BuildBilinearForms(), FormLegacySystem(), and FormSystem().

◆ _td_kernels_map

Moose::MFEM::NamedFieldsMap<Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel> > > > Moose::MFEM::TimeDependentEquationSystem::_td_kernels_map
protected

Definition at line 322 of file EquationSystem.h.

Referenced by AddKernel(), and BuildBilinearForms().

◆ _test_pfespaces

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

◆ _test_var_names

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

◆ _trial_var_names

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

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

Referenced by Moose::MFEM::EquationSystem::FormLegacySystem(), Moose::MFEM::EquationSystem::FormLinearSystem(), Moose::MFEM::EquationSystem::RecoverFEMSolution(), Moose::MFEM::EquationSystem::SetTrialVariableNames(), SetTrialVariableNames(), and Moose::MFEM::EquationSystem::TrialVarNames().

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