How to find all nodes ids associated to a given boundary id #32438
-
Check these boxes if you have followed the posting rules.
QuestionDear moose team, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I think I found a working solution (see below) - at least for the tests I did so far. It might not be the most elegant though. Any suggestion on how to improve it would be more than welcome. /// get the collector of the boundary ids from their names
std::vector<boundary_id_type> nodeset_ids =
MooseMeshUtils::getBoundaryIDs(_mesh, _excluded_boundaries, false);
/// get the nodes on existing boundaries
BoundaryInfo & boundary_info = _mesh.getMesh().get_boundary_info();
auto bc_nodes = boundary_info.build_node_list();
/// fill ids accordingly
for (const auto & t : bc_nodes)
{
auto nd_id = std::get<0>(t);
auto bc_id = std::get<1>(t);
for (unsigned int i = 0; i < nodeset_ids.size(); ++i)
if (bc_id == nodeset_ids[i])
_excluded_node_ids.push_back(nd_id);
}
|
Beta Was this translation helpful? Give feedback.
this looks fine actually.
I'd probably use std::find in the vector rather than a for loop but otherwise this is fine