10#ifdef MOOSE_MFEM_ENABLED
19 params.
addParam<std::vector<BoundaryName>>(
22 "The list of boundaries (names or ids) that this object will be restricted to. "
23 "Leave empty to apply to all boundaries.");
28 const mfem::ParMesh & mfem_mesh)
29 : _mfem_mesh(mfem_mesh),
30 _boundary_names(parameters.get<
std::vector<BoundaryName>>(
"boundary")),
31 _boundary_attributes(boundariesToAttributes(parameters)),
32 _boundary_markers(_mfem_mesh.bdr_attributes.IsEmpty()
34 :
mfem::AttributeSets::AttrToMarker(_mfem_mesh.bdr_attributes.Max(),
35 _boundary_attributes.IsEmpty()
36 ? _mfem_mesh.bdr_attributes
37 : _boundary_attributes))
44 mfem::Array<int> attributes;
52 const int attribute_id = std::stoi(boundary_name);
53 attributes.Append(attribute_id);
58 if (!
mesh.bdr_attribute_sets.AttributeSetExists(boundary_name))
59 parameters.
paramError(
"boundary",
"the mesh has no boundary named '", boundary_name,
"'.");
60 auto & subdomain_ids =
mesh.bdr_attribute_sets.GetAttributeSet(boundary_name);
61 for (
const auto & subdomain_id : subdomain_ids)
62 attributes.Append(subdomain_id);
66 for (
const auto attribute : attributes)
67 if (
mesh.bdr_attributes.Find(attribute) == -1)
68 parameters.
paramError(
"boundary",
"the mesh has no boundary with ID ", attribute,
".");
72std::vector<std::string>
76 std::vector<std::string> strs(attrs.Size());
77 std::transform(attrs.begin(), attrs.end(), strs.begin(), [](
int n) { return std::to_string(n); });
void ErrorVector unsigned int
mfem::Array< int > _boundary_attributes
Array storing boundary attribute IDs for this object.
std::vector< BoundaryName > _boundary_names
Stores the names of the boundaries.
std::vector< std::string > boundariesToStrings()
const mfem::ParMesh & getMesh()
mfem::Array< int > boundariesToAttributes(const InputParameters ¶meters)
Converts the boundary names and IDs to mesh attributes, checking that the mesh has them.
MFEMBoundaryRestrictable(const InputParameters ¶meters, const mfem::ParMesh &mfem_mesh)
static InputParameters validParams()