10#ifdef MOOSE_MFEM_ENABLED
19 params.
addParam<std::vector<SubdomainName>>(
22 "The list of subdomains (names or ids) that this object will be restricted to. "
23 "Leave empty to apply to all subdomains.");
28 const mfem::ParMesh & mfem_mesh)
29 : _mfem_mesh(mfem_mesh),
30 _subdomain_names(parameters.get<
std::vector<SubdomainName>>(
"block")),
31 _subdomain_attributes(subdomainsToAttributes(parameters)),
32 _subdomain_markers(_mfem_mesh.attributes.IsEmpty()
34 :
mfem::AttributeSets::AttrToMarker(_mfem_mesh.attributes.Max(),
35 _subdomain_attributes.IsEmpty()
36 ? _mfem_mesh.attributes
37 : _subdomain_attributes))
44 mfem::Array<int> attributes;
52 const int attribute_id = std::stoi(subdomain_name);
53 attributes.Append(attribute_id);
58 if (!
mesh.attribute_sets.AttributeSetExists(subdomain_name))
59 parameters.
paramError(
"block",
"the mesh has no block named '", subdomain_name,
"'.");
60 auto & subdomain_ids =
mesh.attribute_sets.GetAttributeSet(subdomain_name);
61 for (
const auto & subdomain_id : subdomain_ids)
62 attributes.Append(subdomain_id);
66 for (
const auto attribute : attributes)
67 if (
mesh.attributes.Find(attribute) == -1)
68 parameters.
paramError(
"block",
"the mesh has no block 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
std::vector< std::string > subdomainsToStrings()
std::vector< SubdomainName > _subdomain_names
Stores the names of the subdomains.
mfem::Array< int > subdomainsToAttributes(const InputParameters ¶meters)
Converts the block names and IDs to mesh attributes, checking that the mesh has them.
static InputParameters validParams()
const mfem::ParMesh & getMesh() const
MFEMBlockRestrictable(const InputParameters ¶meters, const mfem::ParMesh &mfem_mesh)
mfem::Array< int > _subdomain_attributes
Array storing subdomain attribute IDs for this object.