10#ifdef MOOSE_MFEM_ENABLED
14#include "libmesh/ignore_warnings.h"
15#include "mfem/miniapps/common/pfem_extras.hpp"
16#include "libmesh/restore_warnings.h"
38 mfem::AssemblyLevel assembly_level)
override;
41 virtual void Mult(
const mfem::Vector & x, mfem::Vector & y)
const override;
57 mfem::ParComplexGridFunction & trial_gf,
58 mfem::Array<int> & global_ess_markers);
75 mfem::BlockVector & trueX,
76 mfem::BlockVector & trueRHS)
override;
81 mfem::BlockVector & trueX,
82 mfem::BlockVector & trueRHS)
override;
88 template <
class FormType>
90 const std::string & trial_var_name,
91 const std::string & test_var_name,
92 std::shared_ptr<FormType> form,
98 const std::string & test_var_name,
99 std::shared_ptr<mfem::ParComplexLinearForm> form,
104 template <
class FormType>
106 const std::string & trial_var_name,
107 const std::string & test_var_name,
108 std::shared_ptr<FormType> form,
114 const std::string & test_var_name,
115 std::shared_ptr<mfem::ParComplexLinearForm> form,
146template <
class FormType>
149 const std::string & trial_var_name,
150 const std::string & test_var_name,
151 std::shared_ptr<FormType> form,
154 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
156 auto kernels = kernels_map.
GetRef(test_var_name).GetRef(trial_var_name);
157 for (
auto & kernel : kernels)
159 mfem::BilinearFormIntegrator * integ_real = kernel->getRealBFIntegrator();
160 mfem::BilinearFormIntegrator * integ_imag = kernel->getImagBFIntegrator();
162 if (integ_real || integ_imag)
164 kernel->isSubdomainRestricted()
165 ? form->AddDomainIntegrator(
166 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
167 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
175 const std::string & test_var_name,
176 std::shared_ptr<mfem::ParComplexLinearForm> form,
179 if (kernels_map.Has(test_var_name))
181 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
182 for (
auto & kernel : kernels)
184 mfem::LinearFormIntegrator * integ_real = kernel->getRealLFIntegrator();
185 mfem::LinearFormIntegrator * integ_imag = kernel->getImagLFIntegrator();
187 if (integ_real || integ_imag)
189 kernel->isSubdomainRestricted()
190 ? form->AddDomainIntegrator(
191 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
192 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
198template <
class FormType>
201 const std::string & trial_var_name,
202 const std::string & test_var_name,
203 std::shared_ptr<FormType> form,
207 if (integrated_bc_map.Has(test_var_name) &&
208 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
210 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
211 for (
auto & bc : bcs)
213 mfem::BilinearFormIntegrator * integ_real = bc->getRealBFIntegrator();
214 mfem::BilinearFormIntegrator * integ_imag = bc->getImagBFIntegrator();
216 if (integ_real || integ_imag)
218 bc->isBoundaryRestricted()
219 ? form->AddBoundaryIntegrator(
220 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
221 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
229 const std::string & test_var_name,
230 std::shared_ptr<mfem::ParComplexLinearForm> form,
234 if (integrated_bc_map.Has(test_var_name))
236 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
237 for (
auto & bc : bcs)
239 mfem::LinearFormIntegrator * integ_real = bc->getRealLFIntegrator();
240 mfem::LinearFormIntegrator * integ_imag = bc->getImagLFIntegrator();
242 if (integ_real || integ_imag)
244 bc->isBoundaryRestricted()
245 ? form->AddBoundaryIntegrator(
246 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
247 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
Class to store weak form components (bilinear and linear forms, and optionally mixed and nonlinear fo...
void EliminateCoupledVariables() override
Perform trivial eliminations of coupled variables lacking corresponding test variables.
virtual void BuildLinearForms() override
Build linear forms and eliminate constrained DoFs.
std::vector< std::unique_ptr< mfem::ParComplexGridFunction > > _cmplx_var_ess_constraints
Complex Gridfunctions holding essential constraints from Dirichlet BCs.
Moose::MFEM::ComplexGridFunctions * _complex_gfuncs
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > _cmplx_kernels_map
~ComplexEquationSystem()=default
virtual void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Nonlinear Mult (Used by Newton-solver not necessarily nonlinear)
virtual void FormSystemOperator(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS) override
Form matrix-free representation of system operator.
virtual void BuildMixedBilinearForms() override
Build mixed bilinear forms (off-diagonal Jacobian contributions)
virtual void SetTrialVariablesFromTrueVectors(const mfem::BlockVector &trueX) const override
Update variable from solution vector after solve.
bool IsComplex() const override
void ApplyDomainBLFIntegrators(const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &kernels_map)
Template method for applying BilinearFormIntegrators on domains from kernels to a SesquilinearForm.
NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexEssentialBC > > > _cmplx_essential_bc_map
NamedFieldsMap< mfem::ParSesquilinearForm > _slfs
virtual void BuildBilinearForms() override
Build bilinear forms (diagonal Jacobian contributions)
virtual void Init(GridFunctions &gridfunctions, ComplexGridFunctions &cmplx_gridfunctions, mfem::AssemblyLevel assembly_level) override
Initialise.
void ApplyBoundaryLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParComplexLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &integrated_bc_map)
Method for applying LinearFormIntegrators on boundaries from kernels to a ParComplexLinearForm.
void ApplyBoundaryBLFIntegrators(const std::string &trial_var_name, const std::string &test_var_name, std::shared_ptr< FormType > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > &integrated_bc_map)
Template method for applying BilinearFormIntegrators on boudaries from kernels to a SesquilinearForm.
void AddComplexKernel(std::shared_ptr< MFEMComplexKernel > kernel)
Add complex kernels.
virtual void ApplyComplexEssentialBC(const std::string &var_name, mfem::ParComplexGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
Applies complex BCs to a single trial variable.
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > _cmplx_integrated_bc_map
virtual void ApplyEssentialBCs() override
Update all essentially constrained true DoF markers and values on boundaries.
ComplexEquationSystem()=default
void ApplyDomainLFIntegrators(const std::string &test_var_name, std::shared_ptr< mfem::ParComplexLinearForm > form, NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > &kernels_map)
Method for applying LinearFormIntegrators on domains from kernels to a ParComplexLinearForm.
NamedFieldsMap< mfem::ParComplexLinearForm > _clfs
NamedFieldsMap< NamedFieldsMap< mfem::ParMixedSesquilinearForm > > _mslfs
virtual void FormSystemMatrix(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS) override
Form matrix representation of system operator as a HypreParMatrix.
void AddComplexIntegratedBC(std::shared_ptr< MFEMComplexIntegratedBC > bc)
Add complex integrated BCs.
ComplexGridFunctions _cmplx_eliminated_variables
Pointers to coupled variables not part of the reduced ComplexEquationSystem.
void AddComplexEssentialBCs(std::shared_ptr< MFEMComplexEssentialBC > bc)
Add complex essential BCs.
Owns the weak-form mathematics of a MOOSE MFEM problem.
T & GetRef(const std::string &field_name) const
Returns a reference to a field.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).