https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMComplexVectorEssentialConstraint.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 vector "
22 "variable in the specified subdomain(s).");
23 params.addParam<MFEMVectorCoefficientName>(
24 "vector_coefficient_real",
25 "0. 0. 0.",
26 "The vector coefficient setting the real part of the constrained values");
27 params.addParam<MFEMVectorCoefficientName>(
28 "vector_coefficient_imag",
29 "0. 0. 0.",
30 "The vector coefficient setting the imaginary part of the constrained values");
31 return params;
32}
33
35 const InputParameters & parameters)
37 _vec_coef_real(getVectorCoefficient("vector_coefficient_real")),
38 _vec_coef_imag(getVectorCoefficient("vector_coefficient_imag"))
39{
40}
41
42void
43MFEMComplexVectorEssentialConstraint::ApplyConstraint(mfem::ParComplexGridFunction & gridfunc,
44 mfem::Array<int> & ess_tdofs)
45{
46 if (gridfunc.ParFESpace()->GetVectorDim() != _vec_coef_real.GetVDim())
47 paramError("vector_coefficient_real", "dimension does not match the variable's.");
48 else if (gridfunc.ParFESpace()->GetVectorDim() != _vec_coef_imag.GetVDim())
49 paramError("vector_coefficient_imag", "dimension does not match the variable's.");
50
51 // Bring the real and imaginary views up to date with the complex vector before
52 // writing through them, and hand their state back afterwards.
53 mfem::ParFiniteElementSpace & pfes = *gridfunc.ParFESpace();
54 const mfem::Array<int> & markers = getSubdomainMarkers();
55 const mfem::Array<int> & ldof_marker = getSubdomainLDofMarker(pfes);
56 gridfunc.Sync();
58 gridfunc.real(), _vec_coef_real, markers, ldof_marker);
60 gridfunc.imag(), _vec_coef_imag, markers, ldof_marker);
61 gridfunc.SyncAlias();
62 ess_tdofs.Append(getSubdomainTDofs(pfes));
63}
64
65#endif
registerMooseObject("MooseApp", MFEMComplexVectorEssentialConstraint)
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 MFEMVectorEssentialConstraint.
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...
MFEMComplexVectorEssentialConstraint(const InputParameters &parameters)
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 ...