https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMComplexScalarEssentialConstraint.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#ifdef MOOSE_MFEM_ENABLED
11
13#include "MFEMConstraintUtils.h"
14
16
19{
21 params.addClassDescription("Strongly constrains the real and imaginary parts of a complex scalar "
22 "variable in the specified subdomain(s).");
23 params.addParam<MFEMScalarCoefficientName>(
24 "coefficient_real", "0.", "The coefficient setting the real part of the constrained values");
25 params.addParam<MFEMScalarCoefficientName>(
26 "coefficient_imag",
27 "0.",
28 "The coefficient setting the imaginary part of the constrained values");
29 return params;
30}
31
33 const InputParameters & parameters)
35 _coef_real(getScalarCoefficient("coefficient_real")),
36 _coef_imag(getScalarCoefficient("coefficient_imag"))
37{
38}
39
40void
41MFEMComplexScalarEssentialConstraint::ApplyConstraint(mfem::ParComplexGridFunction & gridfunc,
42 mfem::Array<int> & ess_tdofs)
43{
44 if (gridfunc.ParFESpace()->GetVectorDim() != 1)
45 paramError("variable", "not scalar; use MFEMComplexVectorEssentialConstraint instead.");
46
47 // Bring the real and imaginary views up to date with the complex vector before
48 // writing through them, and hand their state back afterwards.
49 mfem::ParFiniteElementSpace & pfes = *gridfunc.ParFESpace();
50 const mfem::Array<int> & markers = getSubdomainMarkers();
51 const mfem::Array<int> & ldof_marker = getSubdomainLDofMarker(pfes);
52 gridfunc.Sync();
53 Moose::MFEM::projectCoefficientOnSubdomains(gridfunc.real(), _coef_real, markers, ldof_marker);
54 Moose::MFEM::projectCoefficientOnSubdomains(gridfunc.imag(), _coef_imag, markers, ldof_marker);
55 gridfunc.SyncAlias();
56 ess_tdofs.Append(getSubdomainTDofs(pfes));
57}
58
59#endif
registerMooseObject("MooseApp", MFEMComplexScalarEssentialConstraint)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
mfem::Array< int > & getSubdomainMarkers()
Base class for applying essential volumetric constraints to the trial ParComplexGridFunction of a com...
Complex counterpart of MFEMScalarEssentialConstraint.
MFEMComplexScalarEssentialConstraint(const InputParameters &parameters)
void ApplyConstraint(mfem::ParComplexGridFunction &gridfunc, mfem::Array< int > &ess_tdofs) override
Apply the essential constraint, overwriting the values of gridfunc in the subdomain as desired and ap...
const mfem::Array< int > & getSubdomainTDofs(mfem::ParFiniteElementSpace &pfes)
True dofs of pfes the constraint fixes: those of the constrained subdomains, less the subdomain bound...
const mfem::Array< int > & getSubdomainLDofMarker(mfem::ParFiniteElementSpace &pfes)
Local dof marker of the dofs of pfes the constraint fixes, matching getSubdomainTDofs() and cached al...
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:466
void projectCoefficientOnSubdomains(mfem::ParGridFunction &gf, mfem::Coefficient &coef, const mfem::Array< int > &subdomain_markers, const mfem::Array< int > &ldof_marker)
Overwrite the degrees of freedom of grid function gf marked in the local dof marker ldof_marker with ...