@@ -1484,6 +1484,37 @@ namespace
14841484 Core::Communication::broadcast (node_sets, 0 , mesh_reader.get_comm ());
14851485 }
14861486 }
1487+
1488+ void get_element_block_nodes_from_mesh (
1489+ std::map<int , std::vector<int >>& element_block_nodes, const Core::IO::MeshReader& mesh_reader)
1490+ {
1491+ element_block_nodes.clear ();
1492+ const int my_rank = Core::Communication::my_mpi_rank (mesh_reader.get_comm ());
1493+
1494+ // Data is available on rank zero: bring it into the right shape and broadcast it.
1495+ if (my_rank == 0 )
1496+ {
1497+ auto * exodus_mesh = mesh_reader.get_exodus_mesh_on_rank_zero ();
1498+ if (exodus_mesh)
1499+ {
1500+ const auto & element_blocks = exodus_mesh->get_element_blocks ();
1501+ for (const auto & [id, eb] : element_blocks)
1502+ {
1503+ std::set<int > nodes;
1504+ for (const auto & connectivity : *eb.get_ele_conn () | std::views::values)
1505+ {
1506+ nodes.insert (connectivity.begin (), connectivity.end ());
1507+ }
1508+ element_block_nodes[id] = std::vector<int >(nodes.begin (), nodes.end ());
1509+ }
1510+ }
1511+ Core::Communication::broadcast (element_block_nodes, 0 , mesh_reader.get_comm ());
1512+ }
1513+ else
1514+ {
1515+ Core::Communication::broadcast (element_block_nodes, 0 , mesh_reader.get_comm ());
1516+ }
1517+ }
14871518} // namespace
14881519
14891520/* ----------------------------------------------------------------------*/
@@ -1521,6 +1552,9 @@ void Global::read_conditions(
15211552 std::map<int , std::vector<int >> node_sets;
15221553 get_node_sets_from_mesh (node_sets, mesh_reader);
15231554
1555+ std::map<int , std::vector<int >> element_block_nodes;
1556+ get_element_block_nodes_from_mesh (element_block_nodes, mesh_reader);
1557+
15241558 // check for meshfree discretisation to add node set topologies
15251559 std::vector<std::vector<std::vector<int >>*> nodeset (4 );
15261560 nodeset[0 ] = &dnode_fenode;
@@ -1614,7 +1648,12 @@ void Global::read_conditions(
16141648 }
16151649 case Core::Conditions::EntityType::element_block_id:
16161650 {
1617- FOUR_C_THROW (" Not implemented." );
1651+ const int eb_id = entity_id + 1 ;
1652+ FOUR_C_ASSERT_ALWAYS (element_block_nodes.contains (eb_id),
1653+ " Cannot apply condition '{}' to element block {} which is not specified in the mesh "
1654+ " file." ,
1655+ condition_definition.name (), eb_id);
1656+ condition->set_nodes (element_block_nodes[eb_id]);
16181657 break ;
16191658 }
16201659 }
0 commit comments