10 #ifdef MOOSE_MFEM_ENABLED 13 #include "libmesh/ignore_warnings.h" 14 #include "mfem/miniapps/common/pfem_extras.hpp" 15 #include "libmesh/restore_warnings.h" 46 virtual void AddKernel(std::shared_ptr<MFEMKernel> kernel);
54 mfem::AssemblyLevel assembly_level);
62 mfem::BlockVector & trueX,
63 mfem::BlockVector & trueRHS);
66 FormSystem(mfem::OperatorHandle & op, mfem::BlockVector & trueX, mfem::BlockVector & trueRHS);
68 mfem::BlockVector & trueX,
69 mfem::BlockVector & trueRHS);
72 virtual void BuildJacobian(mfem::BlockVector & trueX, mfem::BlockVector & trueRHS);
75 void Mult(
const mfem::Vector & u, mfem::Vector & residual)
const override;
78 mfem::Operator &
GetGradient(
const mfem::Vector & u)
const override;
91 using mfem::Operator::RecoverFEMSolution;
100 const std::string & name)
const;
126 template <
class FormType>
128 const std::string & trial_var_name,
129 const std::string & test_var_name,
130 std::shared_ptr<FormType> form,
135 const std::string & test_var_name,
136 std::shared_ptr<mfem::ParLinearForm> form,
140 template <
class FormType>
142 const std::string & trial_var_name,
143 const std::string & test_var_name,
144 std::shared_ptr<FormType> form,
150 const std::string & test_var_name,
151 std::shared_ptr<mfem::ParLinearForm> form,
157 std::vector<std::unique_ptr<mfem::ParGridFunction>>
_xs;
158 std::vector<std::unique_ptr<mfem::ParGridFunction>>
_dxdts;
180 template <
class FormType>
183 const std::string & trial_var_name,
184 const std::string & test_var_name,
185 std::shared_ptr<FormType> form,
189 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
191 auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
192 for (
auto & kernel : kernels)
194 mfem::BilinearFormIntegrator * integ = kernel->createBFIntegrator();
195 if (integ !=
nullptr)
197 kernel->isSubdomainRestricted()
198 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
199 : form->AddDomainIntegrator(std::move(integ));
207 const std::string & test_var_name,
208 std::shared_ptr<mfem::ParLinearForm> form,
212 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(test_var_name))
214 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
215 for (
auto & kernel : kernels)
217 mfem::LinearFormIntegrator * integ = kernel->createLFIntegrator();
218 if (integ !=
nullptr)
220 kernel->isSubdomainRestricted()
221 ? form->AddDomainIntegrator(std::move(integ), kernel->getSubdomainMarkers())
222 : form->AddDomainIntegrator(std::move(integ));
228 template <
class FormType>
231 const std::string & trial_var_name,
232 const std::string & test_var_name,
233 std::shared_ptr<FormType> form,
238 if (integrated_bc_map.Has(test_var_name) &&
239 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
241 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
242 for (
auto & bc : bcs)
244 mfem::BilinearFormIntegrator * integ = bc->createBFIntegrator();
245 if (integ !=
nullptr)
247 bc->isBoundaryRestricted()
248 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
249 : form->AddBoundaryIntegrator(std::move(integ));
257 const std::string & test_var_name,
258 std::shared_ptr<mfem::ParLinearForm> form,
263 if (integrated_bc_map.Has(test_var_name) &&
264 integrated_bc_map.Get(test_var_name)->Has(test_var_name))
266 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
267 for (
auto & bc : bcs)
269 mfem::LinearFormIntegrator * integ = bc->createLFIntegrator();
270 if (integ !=
nullptr)
272 bc->isBoundaryRestricted()
273 ? form->AddBoundaryIntegrator(std::move(integ), bc->getBoundaryMarkers())
274 : form->AddBoundaryIntegrator(std::move(integ));
293 virtual void AddKernel(std::shared_ptr<MFEMKernel> kernel)
override;
296 mfem::BlockVector & truedXdt,
297 mfem::BlockVector & trueRHS)
override;
298 virtual void FormSystem(mfem::OperatorHandle & op,
299 mfem::BlockVector & truedXdt,
300 mfem::BlockVector & trueRHS)
override;
315 inline const std::vector<std::string> &
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...
mfem::ConstantCoefficient _dt_coef
Coefficient for timestep scaling.
virtual void AddKernel(std::shared_ptr< MFEMKernel > kernel) override
Add kernels.
virtual void AddTestVariableNameIfMissing(const std::string &test_var_name)
Add test variable to EquationSystem.
virtual void AddKernel(std::shared_ptr< MFEMKernel > kernel)
Add kernels.
virtual void RecoverFEMSolution(mfem::BlockVector &trueX, Moose::MFEM::GridFunctions &gridfunctions)
Update variable from solution vector after solve.
virtual void BuildBilinearForms()
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< std::vector< std::shared_ptr< MFEMKernel > > > > _td_kernels_map
const std::vector< std::string > & TestVarNames() const
Moose::MFEM::NamedFieldsMap< mfem::ParNonlinearForm > _nlfs
virtual void FormSystem(mfem::OperatorHandle &op, mfem::BlockVector &truedXdt, mfem::BlockVector &trueRHS) override
const std::vector< std::string > & TrialVarNames() const
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)
bool VectorContainsName(const std::vector< std::string > &the_vector, const std::string &name) const
std::vector< std::unique_ptr< mfem::ParGridFunction > > _xs
Gridfunctions for setting Dirichlet BCs.
virtual void UpdateEquationSystem()
~EquationSystem() override
Moose::MFEM::NamedFieldsMap< Moose::MFEM::NamedFieldsMap< mfem::ParMixedBilinearForm > > _mblfs
Class to store weak form components (bilinear and linear forms, and optionally mixed and nonlinear fo...
std::vector< std::unique_ptr< mfem::ParGridFunction > > _dxdts
TimeDependentEquationSystem()
virtual void AddEssentialBC(std::shared_ptr< MFEMEssentialBC > bc)
Problem operator for time-dependent problems with an equation system.
std::vector< mfem::Array< int > > _ess_tdof_lists
mfem::AssemblyLevel _assembly_level
void AddTrialVariableNameIfMissing(const std::string &trial_var_name) override
Add trial variable to EquationSystem.
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.
const std::vector< std::string > & TrialVarTimeDerivativeNames() const
Class to store weak form components for time dependent PDEs.
void Mult(const mfem::Vector &u, mfem::Vector &residual) const override
Compute residual y = Mu.
std::vector< std::string > _trial_var_names
Names of all variables corresponding to gridfunctions.
virtual void FormLegacySystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
mfem::OperatorHandle _jacobian
virtual void AddTrialVariableNameIfMissing(const std::string &trial_var_name)
Add trial variable to EquationSystem.
std::vector< std::string > _test_var_names
Names of all test variables corresponding to linear forms in this equation system.
Steady-state problem operator with an equation system.
virtual void BuildEquationSystem()
virtual void Init(Moose::MFEM::GridFunctions &gridfunctions, const Moose::MFEM::FESpaces &fespaces, mfem::AssemblyLevel assembly_level)
Build forms.
virtual void FormLegacySystem(mfem::OperatorHandle &op, mfem::BlockVector &truedXdt, mfem::BlockVector &trueRHS) override
virtual void BuildMixedBilinearForms()
mfem::Array2D< const mfem::HypreParMatrix * > _h_blocks
virtual void FormLinearSystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Form linear system, with essential boundary conditions accounted for.
std::vector< std::string > _trial_var_time_derivative_names
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 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::GridFunctions _trial_variables
Pointers to trial variables.
virtual void BuildLinearForms()
virtual void BuildJacobian(mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Build linear system, with essential boundary conditions accounted for.
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
virtual void BuildBilinearForms() override
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.
virtual void SetTimeStep(double dt)
mfem::Operator & GetGradient(const mfem::Vector &u) const override
Compute J = M + grad_H(u)
virtual void FormSystem(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Moose::MFEM::NamedFieldsMap< mfem::ParBilinearForm > _blfs
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)
virtual void AddIntegratedBC(std::shared_ptr< MFEMIntegratedBC > kernel)