1 #ifdef MOOSE_MFEM_ENABLED 5 #include "libmesh/ignore_warnings.h" 6 #include "mfem/miniapps/common/pfem_extras.hpp" 7 #include "libmesh/restore_warnings.h" 29 mfem::AssemblyLevel assembly_level)
override;
32 virtual void Mult(
const mfem::Vector & x, mfem::Vector & y)
const override;
46 mfem::ParComplexGridFunction & trial_gf,
47 mfem::Array<int> & global_ess_markers);
63 mfem::BlockVector & trueX,
64 mfem::BlockVector & trueRHS)
override;
69 mfem::BlockVector & trueX,
70 mfem::BlockVector & trueRHS)
override;
76 template <
class FormType>
78 const std::string & trial_var_name,
79 const std::string & test_var_name,
80 std::shared_ptr<FormType> form,
86 const std::string & test_var_name,
87 std::shared_ptr<mfem::ParComplexLinearForm> form,
92 template <
class FormType>
94 const std::string & trial_var_name,
95 const std::string & test_var_name,
96 std::shared_ptr<FormType> form,
102 const std::string & test_var_name,
103 std::shared_ptr<mfem::ParComplexLinearForm> form,
107 virtual bool Complex()
const override {
return true; }
133 template <
class FormType>
136 const std::string & trial_var_name,
137 const std::string & test_var_name,
138 std::shared_ptr<FormType> form,
141 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
143 auto kernels = kernels_map.GetRef(test_var_name).GetRef(trial_var_name);
144 for (
auto & kernel : kernels)
146 mfem::BilinearFormIntegrator * integ_real = kernel->getRealBFIntegrator();
147 mfem::BilinearFormIntegrator * integ_imag = kernel->getImagBFIntegrator();
149 if (integ_real || integ_imag)
151 kernel->isSubdomainRestricted()
152 ? form->AddDomainIntegrator(
153 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
154 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
162 const std::string & test_var_name,
163 std::shared_ptr<mfem::ParComplexLinearForm> form,
166 if (kernels_map.Has(test_var_name))
168 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
169 for (
auto & kernel : kernels)
171 mfem::LinearFormIntegrator * integ_real = kernel->getRealLFIntegrator();
172 mfem::LinearFormIntegrator * integ_imag = kernel->getImagLFIntegrator();
174 if (integ_real || integ_imag)
176 kernel->isSubdomainRestricted()
177 ? form->AddDomainIntegrator(
178 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
179 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
185 template <
class FormType>
188 const std::string & trial_var_name,
189 const std::string & test_var_name,
190 std::shared_ptr<FormType> form,
194 if (integrated_bc_map.Has(test_var_name) &&
195 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
197 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
198 for (
auto & bc : bcs)
200 mfem::BilinearFormIntegrator * integ_real = bc->getRealBFIntegrator();
201 mfem::BilinearFormIntegrator * integ_imag = bc->getImagBFIntegrator();
203 if (integ_real || integ_imag)
205 bc->isBoundaryRestricted()
206 ? form->AddBoundaryIntegrator(
207 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
208 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
216 const std::string & test_var_name,
217 std::shared_ptr<mfem::ParComplexLinearForm> form,
221 if (integrated_bc_map.Has(test_var_name))
223 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
224 for (
auto & bc : bcs)
226 mfem::LinearFormIntegrator * integ_real = bc->getRealLFIntegrator();
227 mfem::LinearFormIntegrator * integ_imag = bc->getImagLFIntegrator();
229 if (integ_real || integ_imag)
231 bc->isBoundaryRestricted()
232 ? form->AddBoundaryIntegrator(
233 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
234 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
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...
virtual void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Nonlinear Mult (Used by Newton-solver not necessarily nonlinear)
virtual void SetTrialVariablesFromTrueVectors(const mfem::BlockVector &trueX) const override
Update variable from solution vector after solve.
std::vector< std::unique_ptr< mfem::ParComplexGridFunction > > _cmplx_var_ess_constraints
Complex Gridfunctions holding essential constraints from Dirichlet BCs.
virtual void BuildLinearForms() override
Build linear forms and eliminate constrained DoFs.
~ComplexEquationSystem()=default
NamedFieldsMap< mfem::ParComplexLinearForm > _clfs
virtual void FormSystemOperator(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS) override
Form matrix-free representation of system operator.
ComplexGridFunctions _cmplx_eliminated_variables
Pointers to coupled variables not part of the reduced EquationSystem.
Class to store weak form components (bilinear and linear forms, and optionally mixed and nonlinear fo...
virtual void ApplyComplexEssentialBC(const std::string &var_name, mfem::ParComplexGridFunction &trial_gf, mfem::Array< int > &global_ess_markers)
Apply essential BC(s) associated with var_name to set true DoFs of trial_gf and update markers of all...
void AddComplexEssentialBCs(std::shared_ptr< MFEMComplexEssentialBC > bc)
Add complex essential BCs.
virtual void ApplyEssentialBCs() override
Update all essentially constrained true DoF markers and values on boundaries.
NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexEssentialBC > > > _cmplx_essential_bc_map
virtual void BuildEquationSystem() override
Build all forms comprising this EquationSystem.
virtual void FormSystemMatrix(mfem::OperatorHandle &op, mfem::BlockVector &trueX, mfem::BlockVector &trueRHS) override
Form matrix representation of system operator as a HypreParMatrix.
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexKernel > > > > _cmplx_kernels_map
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.
virtual void BuildBilinearForms() override
Build bilinear forms (diagonal Jacobian contributions)
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...
virtual bool Complex() const override
Whether this a complex equation system.
void AddComplexIntegratedBC(std::shared_ptr< MFEMComplexIntegratedBC > bc)
Add complex integrated BCs.
virtual void Init(GridFunctions &gridfunctions, ComplexGridFunctions &cmplx_gridfunctions, mfem::AssemblyLevel assembly_level) override
Initialise.
NamedFieldsMap< mfem::ParSesquilinearForm > _slfs
Moose::MFEM::ComplexGridFunctions * _complex_gfuncs
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.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > _cmplx_integrated_bc_map
ComplexEquationSystem()=default
void AddComplexKernel(std::shared_ptr< MFEMComplexKernel > kernel)
Add complex kernels.