19#include <range/v3/algorithm/transform.hpp>
20#include <range/v3/range/conversion.hpp>
21#include <unordered_map>
48 OGS_FATAL(
"Unsupported MeshItemType {:s}.",
54 std::ostream& os, std::vector<std::size_t>
const& global_node_ids)
const
56 std::vector<MeshLib::IO::NodeData> nodes_buffer;
57 nodes_buffer.reserve(
nodes.size());
59 for (
const auto* node :
nodes)
61 double const* coords = node->data();
62 nodes_buffer.emplace_back(global_node_ids[node->getID()], coords[0],
63 coords[1], coords[2]);
65 return os.write(
reinterpret_cast<const char*
>(nodes_buffer.data()),
74 std::vector<const MeshLib::Element*>
const& elements)
76 return 3 * elements.size() +
77 std::accumulate(begin(elements), end(elements), 0,
78 [](
auto const nnodes,
auto const* e)
79 {
return nnodes + e->getNumberOfNodes(); });
85 static_cast<long>(
nodes.size()),
99 return os.write(
reinterpret_cast<const char*
>(data),
sizeof(data));
103 std::vector<std::size_t>
const& partition_ids,
104 std::vector<std::size_t>
const& node_id_mapping)
106 return partition_ids[node_id_mapping[node_id]];
109std::pair<std::vector<MeshLib::Node const*>, std::vector<MeshLib::Node const*>>
114 std::vector<MeshLib::Node const*> base_nodes;
117 base_nodes.reserve(nodes.size() / 2);
118 std::vector<MeshLib::Node const*> higher_order_nodes;
121 higher_order_nodes.reserve(nodes.size() / 2);
125 begin(nodes), end(nodes), std::back_inserter(base_nodes),
126 std::back_inserter(higher_order_nodes),
130 return {base_nodes, higher_order_nodes};
136std::tuple<std::vector<MeshLib::Node*>, std::vector<MeshLib::Node*>>
138 std::size_t
const part_id,
139 std::vector<MeshLib::Node*>
const& nodes,
140 std::vector<MeshLib::Element const*>
const& ghost_elements,
141 std::vector<std::size_t>
const& partition_ids,
143 std::vector<std::size_t>
const& node_id_mapping)
145 std::vector<MeshLib::Node*> base_ghost_nodes;
146 std::vector<MeshLib::Node*> higher_order_ghost_nodes;
148 std::vector<bool> is_ghost_node(nodes.size(),
false);
149 for (
const auto* ghost_elem : ghost_elements)
151 for (
unsigned i = 0; i < ghost_elem->getNumberOfNodes(); i++)
153 auto const& n = ghost_elem->getNode(i);
154 auto const node_id = n->getID();
155 if (is_ghost_node[node_id])
165 base_ghost_nodes.push_back(nodes[node_id]);
169 higher_order_ghost_nodes.push_back(nodes[node_id]);
171 is_ghost_node[node_id] =
true;
175 return std::tuple<std::vector<MeshLib::Node*>, std::vector<MeshLib::Node*>>{
176 base_ghost_nodes, higher_order_ghost_nodes};
184 std::size_t
const offset,
188 auto const& nodes = p.nodes;
189 auto const nnodes = nodes.size();
191 for (std::size_t i = 0; i < nnodes; ++i)
193 const auto global_id = nodes[i]->getID();
194 std::copy_n(&pv[n_components * global_id], n_components,
195 &partitioned_pv[offset + n_components * i]);
197 return n_components * nnodes;
206 std::size_t
const offset,
210 std::size_t
const n_regular(p.regular_elements.size());
212 for (std::size_t i = 0; i < n_regular; ++i)
214 const auto id = p.regular_elements[i]->getID();
215 std::copy_n(&pv[n_components *
id], n_components,
216 &partitioned_pv[offset + n_components * i]);
219 std::size_t
const n_ghost(p.ghost_elements.size());
220 for (std::size_t i = 0; i < n_ghost; ++i)
222 const auto id = p.ghost_elements[i]->getID();
223 std::copy_n(&pv[n_components *
id], n_components,
224 &partitioned_pv[offset + n_components * (n_regular + i)]);
226 return n_components * (n_regular + n_ghost);
237 std::size_t
const id_offset_partition,
238 std::vector<std::size_t>
const& element_ip_data_offsets,
247 std::copy_n(&pv[0], pv.
size(), &partitioned_pv[id_offset_partition]);
253 std::size_t id_offset = 0;
258 [&](std::vector<const MeshLib::Element*>
const& elements)
260 for (
auto const element : elements)
262 int const number_of_element_field_data =
267 auto const element_id = element->getID();
268 int const begin_pos = element_ip_data_offsets[element_id];
269 int const end_pos = element_ip_data_offsets[element_id + 1];
271 std::copy(pv.begin() + begin_pos, pv.begin() + end_pos,
272 &partitioned_pv[id_offset + id_offset_partition]);
273 id_offset += number_of_element_field_data;
277 copyFieldData(p.regular_elements);
278 copyFieldData(p.ghost_elements);
284 std::vector<Partition>& partitions)
286 auto const& opt_ip_meta_data_all =
288 for (
auto const& [name, property] : properties)
290 auto const item_type =
property->getMeshItemType();
299 if (property->getPropertyName().find(
"_ip") == std::string::npos)
304 auto const& ip_meta_data =
306 opt_ip_meta_data_all, property->getPropertyName());
307 auto countIntegrationPoints =
308 [&](std::vector<const MeshLib::Element*>
const& elements)
310 std::size_t counter = 0;
311 for (
auto const element : elements)
313 int const number_of_integration_points =
315 ip_meta_data, *element);
316 counter += number_of_integration_points;
321 for (
auto& p : partitions)
323 p.number_of_integration_points =
324 countIntegrationPoints(p.regular_elements) +
325 countIntegrationPoints(p.ghost_elements);
333 std::vector<MeshLib::Element*>
const& global_mesh_elements,
336 std::vector<Partition>
const& partitions,
338 std::map<MeshLib::MeshItemType, std::size_t>
const& total_number_of_tuples)
346 std::size_t partitioned_pv_size = total_number_of_tuples.at(item_type) *
349 std::vector<std::size_t> element_ip_data_offsets;
357 partitioned_pv_size = pv->
size() * partitions.size();
360 element_ip_data_offsets =
362 global_mesh_elements, *pv, properties);
368 if (partitioned_pv ==
nullptr)
371 "Could not create partitioned property vector {:s} for {} data "
375 partitioned_pv->resize(partitioned_pv_size);
377 auto copy_property_vector_values =
378 [&](
Partition const& p, std::size_t offset)
383 element_ip_data_offsets,
384 *pv, *partitioned_pv);
399 "Copying of property vector values for mesh item type {:s} is not "
401 toString(item_type));
404 std::size_t position_offset(0);
405 for (
auto p : partitions)
407 position_offset += copy_property_vector_values(p, position_offset);
413 std::vector<Partition>
const& partitions,
414 std::size_t
const total_number_of_cells)
416 auto* vtk_ghost_type =
419 if (vtk_ghost_type ==
nullptr)
421 OGS_FATAL(
"Could not create vtkGhostType cell data array.");
424 vtk_ghost_type->resize(total_number_of_cells);
425 std::size_t offset = 0;
426 for (
auto const& partition : partitions)
428 offset += partition.regular_elements.size();
429 for (std::size_t i = 0; i < partition.ghost_elements.size(); ++i)
431 if (partition.duplicate_ghost_cell[i])
433 (*vtk_ghost_type)[offset + i] |=
434 vtkDataSetAttributes::DUPLICATECELL;
437 offset += partition.ghost_elements.size();
443 std::unique_ptr<MeshLib::Mesh>
const& mesh,
444 std::vector<Partition>& partitions)
454 auto count_tuples = [&](
MeshItemType const mesh_item_type)
456 return std::accumulate(
457 begin(partitions), end(partitions), 0,
458 [&](std::size_t
const sum,
Partition const& p)
459 {
return sum + p.numberOfMeshItems(mesh_item_type); });
462 std::map<MeshItemType, std::size_t>
const total_number_of_tuples = {
463 {MeshItemType::Cell, count_tuples(MeshItemType::Cell)},
464 {MeshItemType::Node, count_tuples(MeshItemType::Node)},
465 {MeshItemType::IntegrationPoint,
466 count_tuples(MeshItemType::IntegrationPoint)}};
469 "total number of tuples after partitioning defined for cells is {:d} "
470 "and for nodes {:d} and for integration points {:d}.",
471 total_number_of_tuples.at(MeshItemType::Cell),
472 total_number_of_tuples.at(MeshItemType::Node),
473 total_number_of_tuples.at(MeshItemType::IntegrationPoint));
480 [&](
auto type,
auto const property)
483 mesh->getElements(), partitioned_properties, properties,
486 total_number_of_tuples);
491 total_number_of_tuples.at(MeshItemType::Cell));
493 return partitioned_properties;
497 std::vector<Partition>& partitions)
499 std::vector<bool> cell_visited(mesh.
getElements().size(),
false);
501 for (
auto& partition : partitions)
503 partition.duplicate_ghost_cell.resize(partition.ghost_elements.size(),
506 for (std::size_t i = 0; i < partition.ghost_elements.size(); i++)
508 const auto& ghost_element = *partition.ghost_elements[i];
509 if (!cell_visited[ghost_element.getID()])
511 cell_visited[ghost_element.getID()] =
true;
512 partition.duplicate_ghost_cell[i] =
false;
519 std::vector<MeshLib::Element*>
const& global_mesh_elements,
522 auto const& opt_ip_meta_data_all =
524 for (
auto const& [name, property] : properties)
526 auto const item_type =
property->getMeshItemType();
535 if (property->getPropertyName().find(
"_ip") == std::string::npos)
540 std::size_t number_of_total_integration_points = 0;
541 auto const ip_meta_data =
543 opt_ip_meta_data_all, property->getPropertyName());
544 for (
auto const element : global_mesh_elements)
546 int const number_of_integration_points =
549 number_of_total_integration_points += number_of_integration_points;
555 if (pv->size() != number_of_total_integration_points * component_number)
558 "The property vector's size {:d} for integration point data "
559 "{:s} does not match its actual size {:d}. The field data in "
560 "the vtu file are wrong.",
562 number_of_total_integration_points * component_number);
568 std::vector<std::size_t>
const& node_partition_map,
569 std::vector<MeshLib::Element*>
const& elements,
570 std::vector<std::size_t>
const& bulk_node_ids)
572 auto node_partition_ids = ranges::views::transform(
575 auto node_lookup = ranges::views::transform(
576 [&](std::size_t
const i)
577 {
return node_partition_map[bulk_node_ids[i]]; });
580 ranges::to<std::vector>;
583 return elements | node_partition_ids | ranges::to<std::vector>;
587 std::vector<Partition>& partitions,
588 std::vector<std::size_t>
const& nodes_partition_ids,
589 std::vector<MeshLib::Node*>
const& nodes,
590 std::vector<std::size_t>
const& bulk_node_ids)
592 for (
auto const*
const node : nodes)
594 partitions[nodes_partition_ids[bulk_node_ids[node->getID()]]]
595 .nodes.push_back(node);
602 std::vector<MeshLib::Node const*> higher_order_nodes;
605 std::tie(partition.
nodes, higher_order_nodes) =
608 std::copy(begin(higher_order_nodes), end(higher_order_nodes),
609 std::back_inserter(partition.
nodes));
614 std::vector<Partition>& partitions,
MeshLib::Mesh const& mesh)
616 for (
auto& partition : partitions)
627 for (
auto& partition : partitions)
629 partition.number_of_regular_nodes = partition.nodes.size();
630 partition.number_of_mesh_base_nodes = number_of_mesh_base_nodes;
631 partition.number_of_mesh_all_nodes = number_of_mesh_all_nodes;
636 std::vector<Partition>& partitions,
638 std::vector<std::vector<std::size_t>>
const& partition_ids_per_element)
642 auto const element_id = element->getID();
643 auto node_partition_ids = partition_ids_per_element[element_id];
645 std::sort(node_partition_ids.begin(), node_partition_ids.end());
647 std::unique(node_partition_ids.begin(), node_partition_ids.end());
648 node_partition_ids.erase(last, node_partition_ids.end());
651 if (node_partition_ids.size() == 1)
653 partitions[node_partition_ids[0]].regular_elements.push_back(
658 for (
auto const partition_id : node_partition_ids)
660 partitions[partition_id].ghost_elements.push_back(element);
670 std::vector<Partition>& partitions,
MeshLib::Mesh const& mesh,
671 std::vector<std::size_t>
const& nodes_partition_ids,
672 std::vector<std::size_t>
const& node_id_mapping)
674 for (std::size_t part_id = 0; part_id < partitions.size(); part_id++)
676 auto& partition = partitions[part_id];
677 std::vector<MeshLib::Node*> base_ghost_nodes;
678 std::vector<MeshLib::Node*> higher_order_ghost_nodes;
679 std::tie(base_ghost_nodes, higher_order_ghost_nodes) =
681 part_id, mesh.
getNodes(), partition.ghost_elements,
682 nodes_partition_ids, mesh, node_id_mapping);
684 std::copy(begin(base_ghost_nodes), end(base_ghost_nodes),
685 std::back_inserter(partition.nodes));
687 partition.number_of_base_nodes =
688 partition.number_of_regular_base_nodes + base_ghost_nodes.size();
690 std::copy(begin(higher_order_ghost_nodes),
691 end(higher_order_ghost_nodes),
692 std::back_inserter(partition.nodes));
698 std::vector<std::size_t>
const& nodes_partition_ids,
699 std::vector<std::size_t>
const& bulk_node_ids)
704 nodes_partition_ids, mesh.
getElements(), bulk_node_ids);
705 INFO(
"partitionMesh(): Partition IDs per element computed in {:g} s",
711 INFO(
"partitionMesh(): distribute nodes to partitions took {:g} s",
717 "partitionMesh(): sorting [base nodes | higher order nodes] took {:g} "
724 "partitionMesh(): setting number of nodes and of all mesh base nodes "
730 partition_ids_per_element);
731 INFO(
"partitionMesh(): distribute elements into partitions took {:g} s",
736 partitions, mesh, nodes_partition_ids, bulk_node_ids);
737 INFO(
"partitionMesh(): determine / append ghost nodes took {:g} s",
742 INFO(
"partitionMesh(): markDuplicateGhostCells took {:g} s",
748 std::vector<std::size_t> bulk_node_ids(
_mesh->getNumberOfNodes());
749 std::iota(bulk_node_ids.begin(), bulk_node_ids.end(), 0);
765 std::vector<Partition>
const& partitions,
768 auto const bulk_node_ids_string =
777 auto const bulk_element_ids_string =
780 static_cast<std::string
>(bulk_element_ids_string),
792 std::vector<Partition>
const& local_partitions)
const
794 if (bulk_node_ids_pv ==
nullptr)
799 auto& bulk_node_ids = *bulk_node_ids_pv;
801 std::size_t offset = 0;
803 assert(
_partitions.size() == local_partitions.size());
804 int const n_partitions =
static_cast<int>(
_partitions.size());
805 for (
int partition_id = 0; partition_id < n_partitions; ++partition_id)
807 auto const& bulk_partition =
_partitions[partition_id];
808 auto const& local_partition = local_partitions[partition_id];
811 auto const& bulk_nodes = bulk_partition.nodes;
812 auto const n_bulk_nodes = bulk_nodes.size();
813 std::map<std::size_t, std::size_t> global_to_local;
814 for (std::size_t local_node_id = 0; local_node_id < n_bulk_nodes;
817 global_to_local[bulk_nodes[local_node_id]->getID()] = local_node_id;
820 auto const& local_nodes = local_partition.nodes;
821 auto const n_local_nodes = local_nodes.size();
822 for (std::size_t local_node_id = 0; local_node_id < n_local_nodes;
825 bulk_node_ids[offset + local_node_id] =
826 global_to_local[bulk_node_ids[offset + local_node_id]];
828 offset += n_local_nodes;
834 std::vector<Partition>
const& local_partitions)
const
836 if (bulk_element_ids_pv ==
nullptr)
841 auto& bulk_element_ids = *bulk_element_ids_pv;
843 std::size_t offset = 0;
845 assert(
_partitions.size() == local_partitions.size());
846 int const n_partitions =
static_cast<int>(
_partitions.size());
847 for (
int partition_id = 0; partition_id < n_partitions; ++partition_id)
849 auto const& bulk_partition =
_partitions[partition_id];
850 auto const& local_partition = local_partitions[partition_id];
853 std::map<std::size_t, std::size_t> global_to_local;
856 std::vector<MeshLib::Element const*>
const& elements,
857 std::size_t
const offset)
859 auto const n_elements = elements.size();
860 for (std::size_t e = 0; e < n_elements; ++e)
862 global_to_local[elements[e]->getID()] = offset + e;
866 map_elements(bulk_partition.regular_elements, 0);
867 map_elements(bulk_partition.ghost_elements,
868 bulk_partition.regular_elements.size());
871 auto renumber_elements =
872 [&bulk_element_ids, &global_to_local](
873 std::vector<MeshLib::Element const*>
const& elements,
874 std::size_t
const offset)
876 auto const n_elements = elements.size();
877 for (std::size_t e = 0; e < n_elements; ++e)
879 bulk_element_ids[offset + e] =
880 global_to_local[bulk_element_ids[offset + e]];
885 offset += renumber_elements(local_partition.regular_elements, offset);
886 offset += renumber_elements(local_partition.ghost_elements, offset);
893 auto const bulk_node_ids_string =
895 auto const& bulk_node_ids =
899 std::vector<Partition> partitions(
_partitions.size());
908 std::size_t node_global_id_offset = 0;
912 for (std::size_t i = 0; i < partition.number_of_regular_nodes; i++)
915 node_global_id_offset++;
924 os.write(
reinterpret_cast<const char*
>(pv.data()), pv.
size() *
sizeof(T));
930 std::ostream& out_val, std::ostream& out_meta)
955 std::vector<Partition>
const& partitions,
958 auto const number_of_properties =
959 partitioned_properties.
size(mesh_item_type);
960 if (number_of_properties == 0)
965 auto const file_name_infix = toString(mesh_item_type);
967 auto const file_name_cfg = file_name_base +
"_partitioned_" +
968 file_name_infix +
"_properties_cfg" +
969 std::to_string(partitions.size()) +
".bin";
970 std::ofstream out(file_name_cfg, std::ios::binary);
973 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_cfg);
976 auto const file_name_val = file_name_base +
"_partitioned_" +
977 file_name_infix +
"_properties_val" +
978 std::to_string(partitions.size()) +
".bin";
979 std::ofstream out_val(file_name_val, std::ios::binary);
982 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_val);
988 partitioned_properties,
989 [&](
auto type,
auto const& property)
994 mesh_item_type, out_val, out);
997 unsigned long offset = 0;
998 for (
const auto& partition : partitions)
1001 offset,
static_cast<unsigned long>(
1002 partition.numberOfMeshItems(mesh_item_type))};
1004 "Write meta data for node-based PropertyVector: global offset "
1005 "{:d}, number of tuples {:d}",
1006 pvpmd.offset, pvpmd.number_of_tuples);
1008 offset += pvpmd.number_of_tuples;
1018 std::ostream&
writeConfig(std::ostream& os)
const;
1023 os.write(
reinterpret_cast<const char*
>(
this),
sizeof(
ConfigOffsets));
1025 static long reserved = 0;
1027 return os.write(
reinterpret_cast<const char*
>(&reserved),
sizeof(
long));
1039 return {
static_cast<long>(partition.
nodes.size()),
1071 const std::string& file_name_base, std::vector<Partition>
const& partitions)
1073 auto const file_name_cfg = file_name_base +
"_partitioned_msh_cfg" +
1074 std::to_string(partitions.size()) +
".bin";
1075 std::ofstream of_bin_cfg(file_name_cfg, std::ios::binary);
1078 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_cfg);
1081 std::vector<long> partitions_element_offsets;
1082 partitions_element_offsets.reserve(partitions.size());
1083 std::vector<long> partitions_ghost_element_offsets;
1084 partitions_ghost_element_offsets.reserve(partitions.size());
1087 for (
const auto& partition : partitions)
1089 partition.writeConfig(of_bin_cfg);
1096 partitions_element_offsets.push_back(
1097 partition_offsets.regular_elements);
1098 partitions_ghost_element_offsets.push_back(
1099 partition_offsets.ghost_elements);
1102 return std::make_tuple(partitions_element_offsets,
1103 partitions_ghost_element_offsets);
1115 const std::unordered_map<std::size_t, long>& local_node_ids,
1116 std::vector<long>& elem_info,
1119 constexpr unsigned mat_id =
1122 elem_info[counter++] = mat_id;
1123 elem_info[counter++] =
static_cast<long>(elem.
getCellType());
1124 elem_info[counter++] = nn;
1126 for (
long i = 0; i < nn; i++)
1128 auto const& n = *elem.
getNode(i);
1129 elem_info[counter++] = local_node_ids.at(n.getID());
1135 std::vector<MeshLib::Node const*>
const& nodes)
1137 std::unordered_map<std::size_t, long> local_ids;
1138 local_ids.reserve(nodes.size());
1140 long local_node_id = 0;
1141 for (
const auto* node : nodes)
1143 local_ids[node->getID()] = local_node_id++;
1155 std::vector<Partition>
const& partitions,
1156 std::vector<long>
const& regular_element_offsets,
1157 std::vector<long>
const& ghost_element_offsets)
1159 const std::string npartitions_str = std::to_string(partitions.size());
1161 auto const file_name_ele =
1162 file_name_base +
"_partitioned_msh_ele" + npartitions_str +
".bin";
1163 std::ofstream element_info_os(file_name_ele, std::ios::binary);
1164 if (!element_info_os)
1166 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_ele);
1169 auto const file_name_ele_g =
1170 file_name_base +
"_partitioned_msh_ele_g" + npartitions_str +
".bin";
1171 std::ofstream ghost_element_info_os(file_name_ele_g, std::ios::binary);
1172 if (!ghost_element_info_os)
1174 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_ele_g);
1177 for (std::size_t i = 0; i < partitions.size(); i++)
1179 const auto& partition = partitions[i];
1184 std::vector<long> ele_info(regular_element_offsets[i]);
1186 auto writeElementData =
1188 std::vector<MeshLib::Element const*>
const& elements,
1189 long const element_offsets,
1190 std::ofstream& output_stream)
1192 long counter = elements.size();
1193 std::vector<long> ele_info(element_offsets);
1195 for (std::size_t j = 0; j < elements.size(); j++)
1197 const auto* elem = elements[j];
1198 ele_info[j] = counter;
1203 output_stream.write(
reinterpret_cast<const char*
>(ele_info.data()),
1204 ele_info.size() *
sizeof(
long));
1208 writeElementData(partition.regular_elements, regular_element_offsets[i],
1211 writeElementData(partition.ghost_elements, ghost_element_offsets[i],
1212 ghost_element_info_os);
1221 std::vector<Partition>
const& partitions,
1222 std::vector<std::size_t>
const& global_node_ids)
1224 auto const file_name = file_name_base +
"_partitioned_msh_nod" +
1225 std::to_string(partitions.size()) +
".bin";
1226 std::ofstream os(file_name, std::ios::binary);
1229 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name);
1232 for (
const auto& partition : partitions)
1234 partition.writeNodes(os, global_node_ids);
1249 const std::vector<IntegerType>& regular_element_offsets =
1250 std::get<0>(elements_offsets);
1251 const std::vector<IntegerType>& ghost_element_offsets =
1252 std::get<1>(elements_offsets);
1254 ghost_element_offsets);
1260 std::string
const& output_filename_base,
1261 std::vector<Partition>
const& partitions,
1266 const auto elem_integers =
1269 const std::vector<IntegerType>& num_elem_integers =
1270 std::get<0>(elem_integers);
1271 const std::vector<IntegerType>& num_g_elem_integers =
1272 std::get<1>(elem_integers);
1273 writeElements(output_filename_base, partitions, num_elem_integers,
1274 num_g_elem_integers);
1276 writeProperties(output_filename_base, partitioned_properties, partitions,
1278 writeProperties(output_filename_base, partitioned_properties, partitions,
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of mesh-related Enumerations.
Declare a class to perform node wise mesh partitioning.
void applyToPropertyVectors(Properties const &properties, Function f)
Definition of the RunTime class.
Implementation of the VtuInterface class.
void renumberBulkElementIdsProperty(MeshLib::PropertyVector< std::size_t > *const bulk_element_ids_pv, std::vector< Partition > const &local_partitions) const
std::vector< Partition > partitionOtherMesh(MeshLib::Mesh const &mesh) const
MeshLib::Mesh const & mesh() const
void write(const std::string &file_name_base)
void renumberBulkIdsProperty(std::vector< Partition > const &partitions, MeshLib::Properties &partitioned_properties)
void renumberBulkNodeIdsProperty(MeshLib::PropertyVector< std::size_t > *const bulk_node_ids, std::vector< Partition > const &local_partitions) const
void renumberNodeIndices()
std::unique_ptr< MeshLib::Mesh > _mesh
Pointer to a mesh object.
MeshLib::Properties _partitioned_properties
Properties where values at ghost nodes and extra nodes are inserted.
std::vector< std::size_t > _nodes_global_ids
Global IDs of all nodes after partitioning.
void partitionByMETIS()
Partition by node.
std::vector< Partition > _partitions
Data for all partitions.
std::vector< std::size_t > _nodes_partition_ids
Partition IDs of each nodes.
void writeOtherMesh(std::string const &output_filename_base, std::vector< Partition > const &partitions, MeshLib::Properties const &partitioned_properties) const
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
virtual CellType getCellType() const =0
virtual unsigned getNumberOfNodes() const =0
virtual const Node * getNode(unsigned idx) const =0
constexpr std::span< Node *const > nodes() const
Span of element's nodes, their pointers actually.
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
std::size_t computeNumberOfBaseNodes() const
Get the number of base nodes.
Properties & getProperties()
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
Property manager on mesh items. Class Properties manages scalar, vector or matrix properties....
bool hasPropertyVector(std::string_view name) const
std::map< std::string, PropertyVectorBase * >::size_type size() const
PropertyVector< T > * createNewPropertyVector(std::string_view name, MeshItemType mesh_item_type, std::size_t n_components=1)
PropertyVector< T > const * getPropertyVector(std::string_view name) const
MeshItemType getMeshItemType() const
int getNumberOfGlobalComponents() const
std::string const & getPropertyName() const
std::size_t getNumberOfTuples() const
std::tuple< std::vector< MeshLib::Node * >, std::vector< MeshLib::Node * > > findGhostNodesInPartition(std::size_t const part_id, std::vector< MeshLib::Node * > const &nodes, std::vector< MeshLib::Element const * > const &ghost_elements, std::vector< std::size_t > const &partition_ids, MeshLib::Mesh const &mesh, std::vector< std::size_t > const &node_id_mapping)
std::size_t copyCellPropertyVectorValues(Partition const &p, std::size_t const offset, MeshLib::PropertyVector< T > const &pv, MeshLib::PropertyVector< T > &partitioned_pv)
std::unordered_map< std::size_t, long > enumerateLocalNodeIds(std::vector< MeshLib::Node const * > const &nodes)
Generates a mapping of given node ids to a new local (renumbered) node ids.
void addVtkGhostTypeProperty(MeshLib::Properties &partitioned_properties, std::vector< Partition > const &partitions, std::size_t const total_number_of_cells)
bool writePropertyVector(MeshLib::PropertyVector< T > const *const pv, MeshLib::MeshItemType const mesh_item_type, std::ostream &out_val, std::ostream &out_meta)
void checkFieldPropertyVectorSize(std::vector< MeshLib::Element * > const &global_mesh_elements, MeshLib::Properties const &properties)
void writeNodes(const std::string &file_name_base, std::vector< Partition > const &partitions, std::vector< std::size_t > const &global_node_ids)
ConfigOffsets incrementConfigOffsets(ConfigOffsets const &oldConfig, PartitionOffsets const &offsets)
void setIntegrationPointNumberOfPartition(MeshLib::Properties const &properties, std::vector< Partition > &partitions)
void distributeNodesToPartitions(std::vector< Partition > &partitions, std::vector< std::size_t > const &nodes_partition_ids, std::vector< MeshLib::Node * > const &nodes, std::vector< std::size_t > const &bulk_node_ids)
void reorderNodesIntoBaseAndHigherOrderNodes(Partition &partition, MeshLib::Mesh const &mesh)
void reorderNodesIntoBaseAndHigherOrderNodesPerPartition(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh)
MeshLib::Properties partitionProperties(std::unique_ptr< MeshLib::Mesh > const &mesh, std::vector< Partition > &partitions)
Partition existing properties and add vtkGhostType cell data array property.
void setNumberOfNodesInPartitions(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh)
std::pair< std::vector< MeshLib::Node const * >, std::vector< MeshLib::Node const * > > splitIntoBaseAndHigherOrderNodes(std::vector< MeshLib::Node const * > const &nodes, MeshLib::Mesh const &mesh)
PartitionOffsets computePartitionOffsets(Partition const &partition)
NodeWiseMeshPartitioner::IntegerType getNumberOfIntegerVariablesOfElements(std::vector< const MeshLib::Element * > const &elements)
void determineAndAppendGhostNodesToPartitions(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh, std::vector< std::size_t > const &nodes_partition_ids, std::vector< std::size_t > const &node_id_mapping)
void partitionMesh(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh, std::vector< std::size_t > const &nodes_partition_ids, std::vector< std::size_t > const &bulk_node_ids)
std::tuple< std::vector< long >, std::vector< long > > writeConfigData(const std::string &file_name_base, std::vector< Partition > const &partitions)
std::size_t copyFieldPropertyDataToPartitions(MeshLib::Properties const &properties, Partition const &p, std::size_t const id_offset_partition, std::vector< std::size_t > const &element_ip_data_offsets, MeshLib::PropertyVector< T > const &pv, MeshLib::PropertyVector< T > &partitioned_pv)
void writePropertyVectorValues(std::ostream &os, MeshLib::PropertyVector< T > const &pv)
void getElementIntegerVariables(const MeshLib::Element &elem, const std::unordered_map< std::size_t, long > &local_node_ids, std::vector< long > &elem_info, long &counter)
void markDuplicateGhostCells(MeshLib::Mesh const &mesh, std::vector< Partition > &partitions)
void distributeElementsIntoPartitions(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh, std::vector< std::vector< std::size_t > > const &partition_ids_per_element)
std::size_t copyNodePropertyVectorValues(Partition const &p, std::size_t const offset, MeshLib::PropertyVector< T > const &pv, MeshLib::PropertyVector< T > &partitioned_pv)
std::size_t partitionLookup(std::size_t const &node_id, std::vector< std::size_t > const &partition_ids, std::vector< std::size_t > const &node_id_mapping)
std::vector< std::vector< std::size_t > > computePartitionIDPerElement(std::vector< std::size_t > const &node_partition_map, std::vector< MeshLib::Element * > const &elements, std::vector< std::size_t > const &bulk_node_ids)
void writeProperties(const std::string &file_name_base, MeshLib::Properties const &partitioned_properties, std::vector< Partition > const &partitions, MeshLib::MeshItemType const mesh_item_type)
void writeElements(std::string const &file_name_base, std::vector< Partition > const &partitions, std::vector< long > const ®ular_element_offsets, std::vector< long > const &ghost_element_offsets)
bool copyPropertyVector(std::vector< MeshLib::Element * > const &global_mesh_elements, MeshLib::Properties &partitioned_properties, MeshLib::Properties const &properties, std::vector< Partition > const &partitions, MeshLib::PropertyVector< T > const *const pv, std::map< MeshLib::MeshItemType, std::size_t > const &total_number_of_tuples)
void writeValueBinary(std::ostream &out, T const &val)
write value as binary into the given output stream
void writePropertyVectorPartitionMetaData(std::ostream &os, PropertyVectorPartitionMetaData const &pvpmd)
void writePropertyVectorMetaData(std::ostream &os, PropertyVectorMetaData const &pvmd)
constexpr ranges::views::view_closure ids
For an element of a range view return its id.
std::optional< IntegrationPointMetaData > getIntegrationPointMetaData(MeshLib::Properties const &properties)
constexpr std::string_view getBulkIDString(MeshItemType mesh_item_type)
static constexpr char const * toString(const MeshItemType t)
Returns a char array for a specific MeshItemType.
IntegrationPointMetaDataSingleField getIntegrationPointMetaDataSingleField(std::optional< IntegrationPointMetaData > const &ip_meta_data, std::string const &field_name)
long ghost_element_rank_offset
std::ostream & writeConfig(std::ostream &os) const
std::size_t number_of_mesh_base_nodes
std::size_t number_of_base_nodes
std::size_t number_of_regular_nodes
std::ostream & writeConfig(std::ostream &os) const
std::size_t number_of_mesh_all_nodes
std::size_t numberOfMeshItems(MeshLib::MeshItemType const item_type) const
std::size_t number_of_regular_base_nodes
std::vector< const MeshLib::Element * > regular_elements
Non ghost elements.
std::vector< const MeshLib::Element * > ghost_elements
std::ostream & writeNodes(std::ostream &os, std::vector< std::size_t > const &global_node_ids) const
std::vector< MeshLib::Node const * > nodes
nodes.
std::size_t number_of_integration_points
struct NodeData used for parallel reading and also partitioning