25 MeshLib::Mesh& mesh, std::vector<int>
const& selected_material_ids)
27 auto const materialIds = materialIDs(mesh);
31 "Mesh contains no int-property vector named 'MaterialIDs' needed "
32 "by the 'zero_mesh_field_data_by_materialIDs'");
35 std::vector<std::size_t> element_ids_for_selected_materials;
36 for (std::size_t i = 0; i < materialIds->size(); ++i)
38 if (std::find(selected_material_ids.begin(),
39 selected_material_ids.end(),
40 (*materialIds)[i]) != selected_material_ids.end())
42 element_ids_for_selected_materials.push_back(i);
48 std::vector<std::size_t> element_ip_data_offsets;
50 for (
auto const& [name, property] : properties)
52 if (
auto const item_type = property->getMeshItemType();
61 if (!property->getPropertyName().ends_with(
"_ip"))
66 if (properties.template hasPropertyVector<double>(
69 auto& pv = *properties.template getPropertyVector<double>(name);
70 const int n_components = pv.getNumberOfGlobalComponents();
72 if (element_ip_data_offsets.empty())
76 element_ip_data_offsets =
81 std::transform(element_ip_data_offsets.begin(),
82 element_ip_data_offsets.end(),
83 element_ip_data_offsets.begin(),
84 [n = n_components](std::size_t
const v)
88 for (
auto const element_id : element_ids_for_selected_materials)
92 n_components * element_ip_data_offsets[element_id],
94 n_components * element_ip_data_offsets[element_id + 1],