https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMScalarEssentialConstraint.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{
22 "Strongly constrains a scalar variable in the specified subdomain(s).");
23 params.addParam<MFEMScalarCoefficientName>(
24 "coefficient", "0.", "The coefficient setting the constrained values");
25 return params;
26}
27
29 : MFEMEssentialConstraint(parameters), _coef(getScalarCoefficient("coefficient"))
30{
31}
32
33void
34MFEMScalarEssentialConstraint::ApplyConstraint(mfem::ParGridFunction & gridfunc,
35 mfem::Array<int> & ess_tdofs)
36{
37 if (gridfunc.ParFESpace()->GetVectorDim() != 1)
38 paramError("variable", "not scalar; use MFEMVectorEssentialConstraint instead.");
39
40 mfem::ParFiniteElementSpace & pfes = *gridfunc.ParFESpace();
43 ess_tdofs.Append(getSubdomainTDofs(pfes));
44}
45
46#endif
registerMooseObject("MooseApp", MFEMScalarEssentialConstraint)
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()
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...
Base class for applying essential volumetric constraints to the trial ParGridFunction of an MFEM prob...
static InputParameters validParams()
Strongly constrains a scalar variable in the specified subdomain(s) to a scalar coefficient.
MFEMScalarEssentialConstraint(const InputParameters &parameters)
void ApplyConstraint(mfem::ParGridFunction &gridfunc, mfem::Array< int > &ess_tdofs) override
Apply the essential constraint, overwriting the values of gridfunc in the subdomain as desired and ap...
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 ...