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 (const Moose::MFEM::TimeDerivativeMap &time_derivative_map)
 
virtual void Init (Moose::MFEM::GridFunctions &gridfunctions, mfem::AssemblyLevel assembly_level) override
 Initialise. More...
 
virtual void SetTimeStep (mfem::real_t dt)
 
virtual void UpdateEquationSystem ()
 
virtual void AddKernel (std::shared_ptr< MFEMKernel > kernel) override
 Add kernels. More...
 
virtual void BuildBilinearForms () override
 Build bilinear forms (diagonal Jacobian contributions) More...
 
virtual void BuildMixedBilinearForms () override
 Build mixed bilinear forms (off-diagonal Jacobian contributions) More...
 
virtual void ApplyEssentialBCs () override
 Update all essentially constrained true DoF markers and values on boundaries. More...
 
virtual void EliminateCoupledVariables () override
 Perform trivial eliminations of coupled variables lacking corresponding test variables. 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
 
template<class FormType >
void ScaleAndAddBLFIntegrators (std::shared_ptr< FormType > source_blf, std::shared_ptr< FormType > target_blf, mfem::real_t scale_factor)
 Fetch all integrators on a source bilinear form, scale them by a real factor, and add to a second target bilienar form. More...
 
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 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 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 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 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
 Containers to store contributions to weak form of the form (F du/dt, v) More...
 
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _td_mblfs
 
std::vector< std::unique_ptr< mfem::ParGridFunction > > _td_var_ess_constraints
 Gridfunctions holding essential constraints from Dirichlet BCs. More...
 
const Moose::MFEM::TimeDerivativeMap_time_derivative_map
 Map between variable names and their time derivatives. 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 322 of file EquationSystem.h.

Constructor & Destructor Documentation

◆ TimeDependentEquationSystem()

Moose::MFEM::TimeDependentEquationSystem::TimeDependentEquationSystem ( const Moose::MFEM::TimeDerivativeMap time_derivative_map)

Definition at line 464 of file EquationSystem.C.

466  : _dt_coef(1.0), _time_derivative_map(time_derivative_map)
467 {
468 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
const Moose::MFEM::TimeDerivativeMap & _time_derivative_map
Map between variable names and their time derivatives.

Member Function Documentation

◆ AddCoupledVariableNameIfMissing()

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

Add coupled variable to EquationSystem.

Definition at line 38 of file EquationSystem.C.

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

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)
virtualinherited

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::TimeDependentEquationSystem::AddKernel ( std::shared_ptr< MFEMKernel kernel)
overridevirtual

Add kernels.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 526 of file EquationSystem.C.

527 {
528  const auto & trial_var_name = kernel->getTrialVariableName();
529  const auto & test_var_name = kernel->getTestVariableName();
530 
531  if (_time_derivative_map.isTimeDerivative(trial_var_name))
532  {
533  AddTestVariableNameIfMissing(test_var_name);
534  AddCoupledVariableNameIfMissing(trial_var_name);
535 
536  // Register new kernels map if not present for the test variable
537  if (!_td_kernels_map.Has(test_var_name))
538  {
539  auto kernel_field_map =
540  std::make_shared<Moose::MFEM::NamedFieldsMap<std::vector<std::shared_ptr<MFEMKernel>>>>();
541  _td_kernels_map.Register(test_var_name, std::move(kernel_field_map));
542  }
543  if (!_td_kernels_map.Get(test_var_name)->Has(trial_var_name))
544  {
545  auto kernels = std::make_shared<std::vector<std::shared_ptr<MFEMKernel>>>();
546  _td_kernels_map.Get(test_var_name)->Register(trial_var_name, std::move(kernels));
547  }
548  _td_kernels_map.GetRef(test_var_name).Get(trial_var_name)->push_back(std::move(kernel));
549  }
550  else
551  {
553  }
554 }
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
bool isTimeDerivative(const std::string &time_derivative_var_name) const
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer...
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.
const Moose::MFEM::TimeDerivativeMap & _time_derivative_map
Map between variable names and their time derivatives.
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 45 of file EquationSystem.C.

Referenced by Moose::MFEM::EquationSystem::AddIntegratedBC(), Moose::MFEM::EquationSystem::AddKernel(), and 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 
)
protectedinherited

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 
)
inlineprotectedinherited

Definition at line 295 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystem::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 
)
protectedinherited

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 
)
inlineprotectedinherited

Definition at line 245 of file EquationSystem.h.

Referenced by Moose::MFEM::EquationSystem::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 
)
virtualinherited

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 Moose::MFEM::EquationSystem::ApplyEssentialBCs(), and 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::TimeDependentEquationSystem::ApplyEssentialBCs ( )
overridevirtual

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

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 646 of file EquationSystem.C.

647 {
648  _ess_tdof_lists.resize(_test_var_names.size());
649  for (const auto i : index_range(_test_var_names))
650  {
651  const auto & test_var_name = _test_var_names.at(i);
652  const auto time_derivative_test_var_name =
654  mfem::ParGridFunction & trial_gf = *(_var_ess_constraints.at(i));
655  mfem::ParGridFunction & trial_gf_time_derivative = *(_td_var_ess_constraints.at(i));
656  mfem::Array<int> global_ess_markers(trial_gf.ParFESpace()->GetParMesh()->bdr_attributes.Max());
657  global_ess_markers = 0;
658  // Set strongly constrained DoFs of trial_gf on essential boundaries and add markers for all
659  // essential boundaries to the global_ess_markers array
660  EquationSystem::ApplyEssentialBC(test_var_name, trial_gf, global_ess_markers);
661  // Update solution values on Dirichlet values to be in terms of du/dt instead of u
662  *_td_var_ess_constraints.at(i).get() = *(_var_ess_constraints.at(i).get());
663  *_td_var_ess_constraints.at(i).get() -= *_eliminated_variables.Get(test_var_name);
664  *_td_var_ess_constraints.at(i).get() /= _dt_coef.constant;
665  // Apply any remaining Dirichlet BCs specified directly on du/dt
667  time_derivative_test_var_name, trial_gf_time_derivative, global_ess_markers);
668  trial_gf.ParFESpace()->GetEssentialTrueDofs(global_ess_markers, _ess_tdof_lists.at(i));
669  }
670 }
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
std::vector< std::unique_ptr< mfem::ParGridFunction > > _td_var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
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.
const Moose::MFEM::TimeDerivativeMap & _time_derivative_map
Map between variable names and their time derivatives.
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)
const std::string & getTimeDerivativeName(const std::string &var_name) const

◆ 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 
)
inherited

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 Moose::MFEM::EquationSystem::FormLegacySystem(), and 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::TimeDependentEquationSystem::BuildBilinearForms ( )
overridevirtual

Build bilinear forms (diagonal Jacobian contributions)

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 557 of file EquationSystem.C.

558 {
560 
561  // Build and assemble bilinear forms acting on time derivatives
562  for (const auto i : index_range(_test_var_names))
563  {
564  auto test_var_name = _test_var_names.at(i);
565 
566  _td_blfs.Register(test_var_name,
567  std::make_shared<mfem::ParBilinearForm>(_test_pfespaces.at(i)));
568 
569  // Apply kernels to td_blf
570  auto td_blf = _td_blfs.GetShared(test_var_name);
571  td_blf->SetAssemblyLevel(_assembly_level);
572  ApplyBoundaryBLFIntegrators<mfem::ParBilinearForm>(
573  test_var_name, test_var_name, td_blf, _integrated_bc_map);
574  ApplyDomainBLFIntegrators<mfem::ParBilinearForm>(
576  test_var_name,
577  td_blf,
579 
580  // Recover and scale integrators from blf. This is to apply the dt*du/dt contributions from the
581  // operator on the trial variable in the implicit integration scheme
582  auto blf = _blfs.GetShared(test_var_name);
583  ScaleAndAddBLFIntegrators(blf, td_blf, _dt_coef.constant);
584  // Assemble form
585  td_blf->Assemble();
586  }
587 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
virtual void BuildBilinearForms()
Build bilinear forms (diagonal Jacobian contributions)
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.
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...
void ScaleAndAddBLFIntegrators(std::shared_ptr< FormType > source_blf, std::shared_ptr< FormType > target_blf, mfem::real_t scale_factor)
Fetch all integrators on a source bilinear form, scale them by a real factor, and add to a second tar...
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
Containers to store contributions to weak form of the form (F du/dt, v)
const Moose::MFEM::TimeDerivativeMap & _time_derivative_map
Map between variable names and their time derivatives.
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
auto index_range(const T &sizable)
const std::string & getTimeDerivativeName(const std::string &var_name) const

◆ BuildEquationSystem()

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

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 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 
)
virtualinherited

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 ( )
virtualinherited

Build linear forms and eliminate constrained DoFs.

Definition at line 368 of file EquationSystem.C.

Referenced by Moose::MFEM::EquationSystem::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::TimeDependentEquationSystem::BuildMixedBilinearForms ( )
overridevirtual

Build mixed bilinear forms (off-diagonal Jacobian contributions)

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 590 of file EquationSystem.C.

591 {
593  // Register mixed bilinear forms. Note that not all combinations may
594  // have a kernel.
595 
596  // Create mblf for each test/trial variable pair with an added kernel
597  for (const auto i : index_range(_test_var_names))
598  {
599  const auto & test_var_name = _test_var_names.at(i);
600  auto test_td_mblfs =
601  std::make_shared<Moose::MFEM::NamedFieldsMap<mfem::ParMixedBilinearForm>>();
602  for (const auto j : index_range(_trial_var_names))
603  {
604  const auto & trial_var_name = _trial_var_names.at(j);
605  auto td_mblf = std::make_shared<mfem::ParMixedBilinearForm>(_test_pfespaces.at(j),
606  _test_pfespaces.at(i));
607  // Register MixedBilinearForm if kernels exist for it, and assemble
608  // kernels
609  if (_td_kernels_map.Has(test_var_name) &&
610  _td_kernels_map.Get(test_var_name)->Has(trial_var_name) &&
611  _time_derivative_map.getTimeDerivativeName(test_var_name) != trial_var_name)
612  {
613  // Apply all mixed kernels with this test/trial pair
614  ApplyDomainBLFIntegrators<mfem::ParMixedBilinearForm>(
615  trial_var_name, test_var_name, td_mblf, _td_kernels_map);
616  }
617  // Recover and scale integrators from the mblf acting on the time integral of the trial
618  // variable corresponding to coupled_var_name. This is to apply the dt*du/dt contributions
619  // from the operator on the trial variable in the implicit integration scheme
620  const auto & trial_var_time_integral_name =
622  if (_mblfs.Has(test_var_name) && _mblfs.Get(test_var_name)->Has(trial_var_time_integral_name))
623  {
624  // Recover and scale integrators from mblf. This is to apply the dt*du/dt contributions
625  // from the operator on the trial variable in the implicit integration scheme
626  auto mblf = _mblfs.Get(test_var_name)->GetShared(trial_var_time_integral_name);
627  ScaleAndAddBLFIntegrators(mblf, td_mblf, _dt_coef.constant);
628  }
629  // If implicit contributions exist, scale them by timestep and add to td_mblf
630  if (td_mblf->GetDBFI()->Size() || td_mblf->GetBBFI()->Size())
631  {
632  // Assemble mixed bilinear form
633  td_mblf->SetAssemblyLevel(_assembly_level);
634  td_mblf->Assemble();
635  // Register mixed bilinear forms associated with a single trial variable
636  // for the current test variable
637  test_td_mblfs->Register(trial_var_name, td_mblf);
638  }
639  }
640  // Register all mixed bilinear forms associated with a single test variable
641  _td_mblfs.Register(test_var_name, test_td_mblfs);
642  }
643 }
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
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
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
const std::string & getTimeIntegralName(const std::string &time_derivative_var_name) const
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _td_mblfs
mfem::AssemblyLevel _assembly_level
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...
void ScaleAndAddBLFIntegrators(std::shared_ptr< FormType > source_blf, std::shared_ptr< FormType > target_blf, mfem::real_t scale_factor)
Fetch all integrators on a source bilinear form, scale them by a real factor, and add to a second tar...
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
virtual void BuildMixedBilinearForms()
Build mixed bilinear forms (off-diagonal Jacobian contributions)
void Register(const std::string &field_name, FieldArgs &&... args)
Construct new field with name field_name and register.
const Moose::MFEM::TimeDerivativeMap & _time_derivative_map
Map between variable names and their time derivatives.
auto index_range(const T &sizable)
const std::string & getTimeDerivativeName(const std::string &var_name) const

◆ 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::AssembleJacobian(), 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::TimeDependentEquationSystem::EliminateCoupledVariables ( )
overridevirtual

Perform trivial eliminations of coupled variables lacking corresponding test variables.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 673 of file EquationSystem.C.

674 {
675  // Eliminate contributions from variables at previous timestep.
676  for (const auto i : index_range(_test_var_names))
677  {
678  auto & test_var_name = _test_var_names.at(i);
679  auto blf = _blfs.Get(test_var_name);
680  auto lf = _lfs.Get(test_var_name);
681  // if implicit, add contribution to linear form from terms involving state
682  // The AddMult method in mfem::BilinearForm is not defined for non-legacy assembly
683  mfem::Vector lf_prev(lf->Size());
684  blf->Mult(*_eliminated_variables.Get(test_var_name), lf_prev);
685  *lf -= lf_prev;
686  }
687  // Eliminate contributions from other coupled variables.
689 }
virtual void EliminateCoupledVariables()
Perform trivial eliminations of coupled variables lacking corresponding test variables.
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
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
auto index_range(const T &sizable)

◆ FormLegacySystem()

void Moose::MFEM::TimeDependentEquationSystem::FormLegacySystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  truedXdt,
mfem::BlockVector &  trueRHS 
)
overridevirtual

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 692 of file EquationSystem.C.

695 {
696  // Form linear system for operator acting on vector of du/dt
698  _td_blfs, _td_mblfs, _lfs, _ess_tdof_lists, _td_var_ess_constraints, op, truedXdt, trueRHS);
699 }
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...
std::vector< mfem::Array< int > > _ess_tdof_lists
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _td_mblfs
std::vector< std::unique_ptr< mfem::ParGridFunction > > _td_var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _td_blfs
Containers to store contributions to weak form of the form (F du/dt, v)
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs

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

Referenced by Moose::MFEM::EquationSystem::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::TimeDependentEquationSystem::FormSystem ( mfem::OperatorHandle &  op,
mfem::BlockVector &  truedXdt,
mfem::BlockVector &  trueRHS 
)
overridevirtual

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 702 of file EquationSystem.C.

705 {
706  auto & test_var_name = _test_var_names.at(0);
707  auto td_blf = _td_blfs.Get(test_var_name);
708  auto lf = _lfs.Get(test_var_name);
709 
710  // Form linear system for operator acting on vector of du/dt
711  mfem::OperatorPtr aux_a;
712  mfem::Vector aux_x, aux_rhs;
713  td_blf->FormLinearSystem(
714  _ess_tdof_lists.at(0), *(_td_var_ess_constraints.at(0)), *lf, aux_a, aux_x, aux_rhs);
715 
716  truedXdt.GetBlock(0) = aux_x;
717  trueRHS.GetBlock(0) = aux_rhs;
718  truedXdt.SyncFromBlocks();
719  trueRHS.SyncFromBlocks();
720 
721  // Create monolithic matrix
722  op.Reset(aux_a.Ptr());
723  aux_a.SetOperatorOwner(false);
724 }
std::vector< mfem::Array< int > > _ess_tdof_lists
std::vector< std::unique_ptr< mfem::ParGridFunction > > _td_var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
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 > _td_blfs
Containers to store contributions to weak form of the form (F du/dt, v)
Moose::MFEM::NamedFieldsMap< mfem::ParLinearForm > _lfs

◆ GetGradient()

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

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::TimeDependentEquationSystem::Init ( Moose::MFEM::GridFunctions gridfunctions,
mfem::AssemblyLevel  assembly_level 
)
overridevirtual

Initialise.

Reimplemented from Moose::MFEM::EquationSystem.

Definition at line 471 of file EquationSystem.C.

473 {
474  EquationSystem::Init(gridfunctions, assembly_level);
475  for (auto & test_var_name : _test_var_names)
476  _td_var_ess_constraints.emplace_back(
477  std::make_unique<mfem::ParGridFunction>(gridfunctions.Get(test_var_name)->ParFESpace()));
478 }
std::vector< std::unique_ptr< mfem::ParGridFunction > > _td_var_ess_constraints
Gridfunctions holding essential constraints from Dirichlet BCs.
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 Init(Moose::MFEM::GridFunctions &gridfunctions, mfem::AssemblyLevel assembly_level)
Initialise.
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.

◆ Mult()

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

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 
)
virtualinherited

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)

◆ ScaleAndAddBLFIntegrators()

template<class FormType >
void Moose::MFEM::TimeDependentEquationSystem::ScaleAndAddBLFIntegrators ( std::shared_ptr< FormType >  source_blf,
std::shared_ptr< FormType >  target_blf,
mfem::real_t  scale_factor 
)
inline

Fetch all integrators on a source bilinear form, scale them by a real factor, and add to a second target bilienar form.

Useful for scaling bilinear form integrators by timesteps.

Definition at line 349 of file EquationSystem.h.

Referenced by BuildBilinearForms(), and BuildMixedBilinearForms().

352  {
353  // Add and scale all domain integrators existing on source_blf to target_blf
354  auto domain_integrators = source_blf->GetDBFI();
355  auto domain_markers = source_blf->GetDBFI_Marker();
356  for (int i = 0; i < domain_integrators->Size(); ++i)
357  target_blf->AddDomainIntegrator(
358  new ScaleIntegrator(*domain_integrators[i], scale_factor, false), *(*domain_markers[i]));
359  // Add and scale all boundary integrators existing on source_blf to target_blf
360  auto boundary_integrators = source_blf->GetBBFI();
361  auto boundary_markers = source_blf->GetBBFI_Marker();
362  for (int i = 0; i < boundary_integrators->Size(); ++i)
363  target_blf->AddBoundaryIntegrator(
364  new ScaleIntegrator(*boundary_integrators[i], scale_factor, false),
365  *(*boundary_markers[i]));
366  }

◆ SetTimeStep()

void Moose::MFEM::TimeDependentEquationSystem::SetTimeStep ( mfem::real_t  dt)
virtual

Definition at line 481 of file EquationSystem.C.

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

482 {
483  if (fabs(dt - _dt_coef.constant) > 1.0e-12 * dt)
484  {
485  _dt_coef.constant = dt;
486  for (auto test_var_name : _test_var_names)
487  {
488  auto blf = _blfs.Get(test_var_name);
489  blf->Update();
490  blf->Assemble();
491  }
492  }
493 }
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 496 of file EquationSystem.C.

497 {
498  // The TimeDependentEquationSystem operator expects to act on a vector of variable time
499  // derivatives, so the trial variable must be the time derivative of the 'base' variable. The base
500  // variable (test_var_name) without derivatives applied must also be coupled in implicit
501  // timestepping schemes for the elimination of 'old' variable values from the previous timestep
502  for (const auto & test_var_name : _test_var_names)
503  {
504  AddCoupledVariableNameIfMissing(test_var_name);
506  }
507 
508  // If a coupled variable does not have an equation associated with it,
509  // add it to the set of eliminated variables.
510  for (const auto & test_var_name : _test_var_names)
511  {
512  const auto time_derivative_test_var_name =
514  for (const auto & coupled_var_name : _coupled_var_names)
515  {
516  if (time_derivative_test_var_name != coupled_var_name &&
517  !VectorContainsName(_eliminated_var_names, coupled_var_name))
518  _eliminated_var_names.push_back(coupled_var_name);
519  }
520  if (!VectorContainsName(_trial_var_names, time_derivative_test_var_name))
521  _trial_var_names.push_back(time_derivative_test_var_name);
522  }
523 }
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.
virtual void AddCoupledVariableNameIfMissing(const std::string &coupled_var_name)
Add coupled variable to EquationSystem.
std::vector< std::string > _coupled_var_names
Names of all trial variables of kernels and boundary conditions added to this EquationSystem.
const Moose::MFEM::TimeDerivativeMap & _time_derivative_map
Map between variable names and their time derivatives.
const std::string & getTimeDerivativeName(const std::string &var_name) const

◆ TestVarNames()

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

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
inlineinherited

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

◆ UpdateEquationSystem()

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

Definition at line 727 of file EquationSystem.C.

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

728 {
730 }
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.

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

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

Referenced by ApplyEssentialBCs(), BuildBilinearForms(), BuildMixedBilinearForms(), 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 145 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

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

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

◆ _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 209 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 204 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 158 of file EquationSystem.h.

◆ _td_blfs

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

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

Definition at line 375 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 373 of file EquationSystem.h.

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

◆ _td_mblfs

Moose::MFEM::NamedFieldsMap<Moose::MFEM::NamedFieldsMap<mfem::ParMixedBilinearForm> > Moose::MFEM::TimeDependentEquationSystem::_td_mblfs
protected

Definition at line 377 of file EquationSystem.h.

Referenced by BuildMixedBilinearForms(), and FormLegacySystem().

◆ _td_var_ess_constraints

std::vector<std::unique_ptr<mfem::ParGridFunction> > Moose::MFEM::TimeDependentEquationSystem::_td_var_ess_constraints
protected

Gridfunctions holding essential constraints from Dirichlet BCs.

Definition at line 380 of file EquationSystem.h.

Referenced by ApplyEssentialBCs(), FormLegacySystem(), FormSystem(), and Init().

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

◆ _time_derivative_map

const Moose::MFEM::TimeDerivativeMap& Moose::MFEM::TimeDependentEquationSystem::_time_derivative_map
protected

Map between variable names and their time derivatives.

Definition at line 383 of file EquationSystem.h.

Referenced by AddKernel(), ApplyEssentialBCs(), BuildBilinearForms(), BuildMixedBilinearForms(), and SetTrialVariableNames().

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

Referenced by Moose::MFEM::EquationSystem::AssembleJacobian(), BuildMixedBilinearForms(), 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: