https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMConstraint.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
12#include "MFEMConstraint.h"
13#include "MFEMProblem.h"
14#include "MFEMConstraintUtils.h"
15
18{
21
22 params.addClassDescription("Base class for constraining an MFEM variable within one or more mesh "
23 "subdomains.");
24 params.registerBase("Constraint");
25 params.registerSystemAttributeName("Constraint");
26 params.addParam<VariableName>("variable", "Variable on which to apply the constraint");
27 params.addParam<bool>(
28 "constrain_subdomain_boundary",
29 true,
30 "Whether to constrain the degrees of freedom on the boundary of the subdomains given by "
31 "'block', both on interfaces with other subdomains and on the exterior boundary of the "
32 "mesh. If false, only the degrees of freedom interior to the subdomains are constrained.");
33 return params;
34}
35
37 : MFEMObject(parameters),
38 MFEMBlockRestrictable(parameters,
39 getMFEMProblem().getMFEMVariableMesh(getParam<VariableName>("variable"))),
40 _trial_var_name(getParam<VariableName>("variable")),
41 _constrain_subdomain_boundary(getParam<bool>("constrain_subdomain_boundary"))
42{
43}
44
45void
47{
48 // Both marker arrays are built from the mesh of the same variable, so they have
49 // the same size. An empty 'block' marks every subdomain.
50 const auto & markers = getSubdomainMarkers();
51 const auto & other_markers = other.getSubdomainMarkers();
52 for (const auto i : make_range(markers.Size()))
53 if (markers[i] && other_markers[i])
54 paramError("block",
55 "shares subdomain ",
56 i + 1,
57 " with the constraint '",
58 other.name(),
59 "' on variable '",
61 "'. Essential constraints on the same variable must be restricted to disjoint "
62 "sets of subdomains.");
63}
64
65const mfem::Array<int> &
66MFEMConstraint::getSubdomainTDofs(mfem::ParFiniteElementSpace & pfes)
67{
69 return _subdomain_tdofs;
70}
71
72const mfem::Array<int> &
73MFEMConstraint::getSubdomainLDofMarker(mfem::ParFiniteElementSpace & pfes)
74{
77}
78
79void
80MFEMConstraint::updateSubdomainTDofs(mfem::ParFiniteElementSpace & pfes)
81{
82 // MFEM bumps the sequence number whenever the space is updated, including after
83 // refinement of the mesh, so it invalidates the cache exactly when needed.
84 if (_subdomain_tdofs_sequence != pfes.GetSequence())
85 {
91 _subdomain_tdofs_sequence = pfes.GetSequence();
92 }
93}
94
95#endif
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
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 registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
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.
Base class for construction of an object that is restricted to a subset of subdomains of the problem ...
static InputParameters validParams()
mfem::Array< int > & getSubdomainMarkers()
Base class for objects constraining the value an MFEM variable may take within one or more mesh subdo...
mfem::Array< int > _subdomain_ldof_marker
Local dof marker matching _subdomain_tdofs.
const mfem::Array< int > & getSubdomainTDofs(mfem::ParFiniteElementSpace &pfes)
True dofs of pfes the constraint fixes: those of the constrained subdomains, less the subdomain bound...
long _subdomain_tdofs_sequence
FE space sequence number _subdomain_tdofs was built for; -1 marks "never built".
virtual const std::string & getTrialVariableName() const
Name of the trial variable (gridfunction) the constraint acts on.
mfem::Array< int > _subdomain_tdofs
Constrained true dofs of the most recent updateSubdomainTDofs() call.
static InputParameters validParams()
void checkDisjointSubdomains(MFEMConstraint &other)
Reports an error if this constraint shares a subdomain with other, a constraint on the same variable.
const mfem::Array< int > & getSubdomainLDofMarker(mfem::ParFiniteElementSpace &pfes)
Local dof marker of the dofs of pfes the constraint fixes, matching getSubdomainTDofs() and cached al...
MFEMConstraint(const InputParameters &parameters)
void updateSubdomainTDofs(mfem::ParFiniteElementSpace &pfes)
Rebuilds the cached constrained dofs if pfes was updated since they were built.
const bool _constrain_subdomain_boundary
Whether the dofs on the boundary of the constrained subdomains are constrained.
Thin base for MFEM objects backed directly by MooseObject instead of UserObject.
Definition MFEMObject.h:30
static InputParameters validParams()
Declare the common parameters required by MFEM MooseObject-backed classes.
Definition MFEMObject.C:17
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
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 subdomainTDofs(mfem::ParFiniteElementSpace &pfes, const mfem::Array< int > &subdomain_markers, bool include_boundary, mfem::Array< int > &ldof_marker, mfem::Array< int > &tdofs)
Degrees of freedom of pfes belonging to elements whose mesh attribute is set in the attribute marker ...