29 std::string mesh_name, std::vector<MeshLib::Element*>
const& elements)
31 auto ids_vector =
views::ids | ranges::to<std::vector>();
33 DBUG(
"Found {:d} elements in the mesh", elements.size());
36 auto bulk_element_ids = elements | ids_vector;
39 std::unordered_map<std::size_t, MeshLib::Node*> id_node_hash_map;
40 id_node_hash_map.reserve(
43 for (
auto& e : elements)
46 unsigned const n_nodes = e->getNumberOfNodes();
47 for (
unsigned i = 0; i < n_nodes; ++i)
50 auto const it = id_node_hash_map.find(n->
getID());
51 if (it == id_node_hash_map.end())
53 auto new_node_in_map = id_node_hash_map[n->
getID()] =
55 e->setNode(i, new_node_in_map);
59 e->setNode(i, it->second);
64 std::map<std::size_t, MeshLib::Node*> nodes_map;
65 for (
const auto& n : id_node_hash_map)
67 nodes_map[n.first] = n.second;
72 nodes_map | ranges::views::values | ranges::to<std::vector>;
76 nodes_map | ranges::views::keys | ranges::to<std::vector>;
78 auto mesh = std::make_unique<MeshLib::Mesh>(
79 std::move(mesh_name), std::move(element_nodes), std::move(elements),
81 assert(mesh !=
nullptr);