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"
39 mfem::AssemblyLevel assembly_level)
override;
42 virtual void Mult(
const mfem::Vector & x, mfem::Vector & y)
const override;
59 mfem::ParComplexGridFunction & trial_gf,
60 mfem::Array<int> & global_bdr_markers,
61 mfem::Array<int> & global_ess_tdofs);
83 mfem::BlockVector & trueX,
84 mfem::BlockVector & trueRHS)
override;
89 mfem::BlockVector & trueX,
90 mfem::BlockVector & trueRHS)
override;
96 template <
class FormType>
98 const std::string & trial_var_name,
99 const std::string & test_var_name,
100 std::shared_ptr<FormType> form,
106 const std::string & test_var_name,
107 std::shared_ptr<mfem::ParComplexLinearForm> form,
112 template <
class FormType>
114 const std::string & trial_var_name,
115 const std::string & test_var_name,
116 std::shared_ptr<FormType> form,
122 const std::string & test_var_name,
123 std::shared_ptr<mfem::ParComplexLinearForm> form,
158template <
class FormType>
161 const std::string & trial_var_name,
162 const std::string & test_var_name,
163 std::shared_ptr<FormType> form,
166 if (kernels_map.Has(test_var_name) && kernels_map.Get(test_var_name)->Has(trial_var_name))
168 auto kernels = kernels_map.
GetRef(test_var_name).GetRef(trial_var_name);
169 for (
auto & kernel : kernels)
171 mfem::BilinearFormIntegrator * integ_real = kernel->getRealBFIntegrator();
172 mfem::BilinearFormIntegrator * integ_imag = kernel->getImagBFIntegrator();
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));
187 const std::string & test_var_name,
188 std::shared_ptr<mfem::ParComplexLinearForm> form,
191 if (kernels_map.Has(test_var_name))
193 auto kernels = kernels_map.GetRef(test_var_name).GetRef(test_var_name);
194 for (
auto & kernel : kernels)
196 mfem::LinearFormIntegrator * integ_real = kernel->getRealLFIntegrator();
197 mfem::LinearFormIntegrator * integ_imag = kernel->getImagLFIntegrator();
199 if (integ_real || integ_imag)
201 kernel->isSubdomainRestricted()
202 ? form->AddDomainIntegrator(
203 std::move(integ_real), std::move(integ_imag), kernel->getSubdomainMarkers())
204 : form->AddDomainIntegrator(std::move(integ_real), std::move(integ_imag));
210template <
class FormType>
213 const std::string & trial_var_name,
214 const std::string & test_var_name,
215 std::shared_ptr<FormType> form,
219 if (integrated_bc_map.Has(test_var_name) &&
220 integrated_bc_map.Get(test_var_name)->Has(trial_var_name))
222 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(trial_var_name);
223 for (
auto & bc : bcs)
225 mfem::BilinearFormIntegrator * integ_real = bc->getRealBFIntegrator();
226 mfem::BilinearFormIntegrator * integ_imag = bc->getImagBFIntegrator();
228 if (integ_real || integ_imag)
230 bc->isBoundaryRestricted()
231 ? form->AddBoundaryIntegrator(
232 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
233 : form->AddBoundaryIntegrator(std::move(integ_real), std::move(integ_imag));
241 const std::string & test_var_name,
242 std::shared_ptr<mfem::ParComplexLinearForm> form,
246 if (integrated_bc_map.Has(test_var_name))
248 auto bcs = integrated_bc_map.GetRef(test_var_name).GetRef(test_var_name);
249 for (
auto & bc : bcs)
251 mfem::LinearFormIntegrator * integ_real = bc->getRealLFIntegrator();
252 mfem::LinearFormIntegrator * integ_imag = bc->getImagLFIntegrator();
254 if (integ_real || integ_imag)
256 bc->isBoundaryRestricted()
257 ? form->AddBoundaryIntegrator(
258 std::move(integ_real), std::move(integ_imag), bc->getBoundaryMarkers())
259 : 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...
NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexEssentialConstraint > > > _cmplx_essential_constraint_map
virtual void ApplyComplexEssentialConstraint(const std::string &var_name, mfem::ParComplexGridFunction &trial_gf, mfem::Array< int > &global_bdr_markers, mfem::Array< int > &global_ess_tdofs)
Apply essential constraints associated with var_name to set true DoFs of trial_gf,...
bool HasEssentialConstraints(const std::string &var_name) const override
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.
void AddComplexEssentialConstraint(std::shared_ptr< MFEMComplexEssentialConstraint > constraint)
Add complex essential (volumetric) constraints.
NamedFieldsMap< NamedFieldsMap< std::vector< std::shared_ptr< MFEMComplexIntegratedBC > > > > _cmplx_integrated_bc_map
virtual void ApplyEssentialConstraints() override
Update essential boundary markers and all constrained true DoF lists and values.
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).