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;
48 mfem::ParComplexGridFunction & trial_gf,
49 mfem::Array<int> & global_ess_markers);
66 mfem::BlockVector & trueX,
67 mfem::BlockVector & trueRHS)
override;
72 mfem::BlockVector & trueX,
73 mfem::BlockVector & trueRHS)
override;
79 template <
class FormType>
81 const std::string & trial_var_name,
82 const std::string & test_var_name,
83 std::shared_ptr<FormType> form,
89 const std::string & test_var_name,
90 std::shared_ptr<mfem::ParComplexLinearForm> form,
95 template <
class FormType>
97 const std::string & trial_var_name,
98 const std::string & test_var_name,
99 std::shared_ptr<FormType> form,
105 const std::string & test_var_name,
106 std::shared_ptr<mfem::ParComplexLinearForm> form,
137template <
class FormType>
140 const std::string & trial_var_name,
141 const std::string & test_var_name,
142 std::shared_ptr<FormType> form,
145 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
147 auto kernels = kernels_map.
GetRef(test_var_name).GetRef(trial_var_name);
148 for (
auto & kernel : kernels)
150 mfem::BilinearFormIntegrator * integ_real = kernel->getRealBFIntegrator();
151 mfem::BilinearFormIntegrator * integ_imag = kernel->getImagBFIntegrator();
153 if (integ_real || integ_imag)
155 kernel->isSubdomainRestricted()
156 ? form->AddDomainIntegrator(
157 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
158 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
166 const std::string & test_var_name,
167 std::shared_ptr<mfem::ParComplexLinearForm> form,
170 if (kernels_map.Has(test_var_name))
172 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
173 for (
auto & kernel : kernels)
175 mfem::LinearFormIntegrator * integ_real = kernel->getRealLFIntegrator();
176 mfem::LinearFormIntegrator * integ_imag = kernel->getImagLFIntegrator();
178 if (integ_real || integ_imag)
180 kernel->isSubdomainRestricted()
181 ? form->AddDomainIntegrator(
182 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
183 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
189template <
class FormType>
192 const std::string & trial_var_name,
193 const std::string & test_var_name,
194 std::shared_ptr<FormType> form,
198 if (integrated_bc_map.Has(test_var_name) &&
199 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
201 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
202 for (
auto & bc : bcs)
204 mfem::BilinearFormIntegrator * integ_real = bc->getRealBFIntegrator();
205 mfem::BilinearFormIntegrator * integ_imag = bc->getImagBFIntegrator();
207 if (integ_real || integ_imag)
209 bc->isBoundaryRestricted()
210 ? form->AddBoundaryIntegrator(
211 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
212 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
220 const std::string & test_var_name,
221 std::shared_ptr<mfem::ParComplexLinearForm> form,
225 if (integrated_bc_map.Has(test_var_name))
227 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
228 for (
auto & bc : bcs)
230 mfem::LinearFormIntegrator * integ_real = bc->getRealLFIntegrator();
231 mfem::LinearFormIntegrator * integ_imag = bc->getImagLFIntegrator();
233 if (integ_real || integ_imag)
235 bc->isBoundaryRestricted()
236 ? form->AddBoundaryIntegrator(
237 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
238 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
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).