45 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
46 auto & boundary_info =
mesh->get_boundary_info();
49 std::set<boundary_id_type> breaking_boundary_ids;
52 auto & boundary_names = getParam<std::vector<BoundaryName>>(
"boundaries");
53 for (
auto & boundary_name : boundary_names)
57 paramError(
"boundaries",
"The boundary '", boundary_name,
"' was not found in the mesh");
59 breaking_boundary_ids.insert(boundary_info.get_id_by_name(boundary_name));
64 breaking_boundary_ids = boundary_info.get_boundary_ids();
67 if (!
mesh->is_replicated())
72 std::set<std::string> new_boundary_name_set;
73 std::vector<boundary_id_type> side_boundary_ids;
74 for (
const auto & elem :
mesh->active_element_ptr_range())
76 auto subdomain_id = elem->subdomain_id();
79 auto subdomain_name = std::as_const(
mesh)->subdomain_name(subdomain_id);
80 if (subdomain_name ==
"")
81 subdomain_name = std::to_string(subdomain_id);
82 for (
unsigned int side = 0; side < elem->n_sides(); ++side)
84 boundary_info.boundary_ids(elem, side, side_boundary_ids);
85 for (
auto boundary_id : side_boundary_ids)
86 if (breaking_boundary_ids.count(boundary_id) > 0)
87 new_boundary_name_set.emplace(boundary_info.get_sideset_name(boundary_id) +
"_to_" +
94 if (!
mesh->is_replicated())
98 std::vector<BoundaryName> new_boundary_names(new_boundary_name_set.begin(),
99 new_boundary_name_set.end());
103 mooseAssert(new_boundary_ids.size() == new_boundary_names.size(),
104 "sizes of boundary names and boundary IDs mismatch");
105 for (MooseIndex(new_boundary_ids) i = 0; i < new_boundary_ids.size(); ++i)
107 boundary_info.sideset_name(new_boundary_ids[i]) = new_boundary_names[i];
108 boundary_info.nodeset_name(new_boundary_ids[i]) = new_boundary_names[i];
112 for (
const auto & elem :
mesh->active_element_ptr_range())
114 auto subdomain_id = elem->subdomain_id();
115 auto subdomain_name = std::as_const(
mesh)->subdomain_name(subdomain_id);
116 if (subdomain_name ==
"")
117 subdomain_name = std::to_string(subdomain_id);
118 for (MooseIndex(elem->n_sides()) side = 0; side < elem->n_sides(); ++side)
120 std::vector<boundary_id_type> side_boundary_ids;
121 boundary_info.boundary_ids(elem, side, side_boundary_ids);
122 for (
auto boundary_id : side_boundary_ids)
124 if (breaking_boundary_ids.count(boundary_id) > 0)
127 boundary_info.get_sideset_name(boundary_id) +
"_to_" + subdomain_name;
128 auto bid = boundary_info.get_id_by_name(bname);
129 boundary_info.add_side(elem, side, bid);
135 mesh->unset_is_prepared();
137 return dynamic_pointer_cast<MeshBase>(
mesh);
registerMooseObject("MooseApp", BreakBoundaryOnSubdomainGenerator)
MeshGenerator for breaking all boundaries based on which block they are attached to.
static InputParameters validParams()
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
std::unique_ptr< MeshBase > & _input
the input mesh to be modified
BreakBoundaryOnSubdomainGenerator(const InputParameters ¶meters)
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.