8#include <range/v3/algorithm/transform.hpp>
9#include <range/v3/range/conversion.hpp>
10#include <unordered_map>
37 OGS_FATAL(
"Unsupported MeshItemType {:s}.",
43 std::ostream& os, std::vector<std::size_t>
const& global_node_ids)
const
45 std::vector<MeshLib::IO::NodeData> nodes_buffer;
46 nodes_buffer.reserve(
nodes.size());
48 for (
const auto* node :
nodes)
50 double const* coords = node->data();
51 nodes_buffer.emplace_back(global_node_ids[node->getID()], coords[0],
52 coords[1], coords[2]);
54 return os.write(
reinterpret_cast<const char*
>(nodes_buffer.data()),
63 std::vector<const MeshLib::Element*>
const& elements)
65 return 3 * elements.size() +
66 std::accumulate(begin(elements), end(elements), 0,
67 [](
auto const nnodes,
auto const* e)
68 {
return nnodes + e->getNumberOfNodes(); });
74 static_cast<long>(
nodes.size()),
88 return os.write(
reinterpret_cast<const char*
>(data),
sizeof(data));
92 std::vector<std::size_t>
const& partition_ids,
93 std::span<std::size_t const>
const node_id_mapping)
95 return partition_ids[node_id_mapping[node_id]];
98std::pair<std::vector<MeshLib::Node const*>, std::vector<MeshLib::Node const*>>
103 std::vector<MeshLib::Node const*> base_nodes;
106 base_nodes.reserve(nodes.size() / 2);
107 std::vector<MeshLib::Node const*> higher_order_nodes;
110 higher_order_nodes.reserve(nodes.size() / 2);
114 begin(nodes), end(nodes), std::back_inserter(base_nodes),
115 std::back_inserter(higher_order_nodes),
119 return {base_nodes, higher_order_nodes};
125std::tuple<std::vector<MeshLib::Node*>, std::vector<MeshLib::Node*>>
127 std::size_t
const part_id,
128 std::vector<MeshLib::Node*>
const& nodes,
129 std::vector<MeshLib::Element const*>
const& ghost_elements,
130 std::vector<std::size_t>
const& partition_ids,
132 std::span<std::size_t const>
const node_id_mapping)
134 std::vector<MeshLib::Node*> base_ghost_nodes;
135 std::vector<MeshLib::Node*> higher_order_ghost_nodes;
137 std::vector<bool> is_ghost_node(nodes.size(),
false);
138 for (
const auto* ghost_elem : ghost_elements)
140 for (
unsigned i = 0; i < ghost_elem->getNumberOfNodes(); i++)
142 auto const& n = ghost_elem->getNode(i);
143 auto const node_id = n->getID();
144 if (is_ghost_node[node_id])
154 base_ghost_nodes.push_back(nodes[node_id]);
158 higher_order_ghost_nodes.push_back(nodes[node_id]);
160 is_ghost_node[node_id] =
true;
164 return std::tuple<std::vector<MeshLib::Node*>, std::vector<MeshLib::Node*>>{
165 base_ghost_nodes, higher_order_ghost_nodes};
173 std::size_t
const offset,
177 auto const& nodes = p.
nodes;
178 auto const nnodes = nodes.size();
180 for (std::size_t i = 0; i < nnodes; ++i)
182 const auto global_id = nodes[i]->getID();
183 std::copy_n(&pv[n_components * global_id], n_components,
184 &partitioned_pv[offset + n_components * i]);
186 return n_components * nnodes;
195 std::size_t
const offset,
201 for (std::size_t i = 0; i < n_regular; ++i)
204 std::copy_n(&pv[n_components *
id], n_components,
205 &partitioned_pv[offset + n_components * i]);
209 for (std::size_t i = 0; i < n_ghost; ++i)
212 std::copy_n(&pv[n_components *
id], n_components,
213 &partitioned_pv[offset + n_components * (n_regular + i)]);
215 return n_components * (n_regular + n_ghost);
226 std::size_t
const id_offset_partition,
227 std::vector<std::size_t>
const& element_ip_data_offsets,
236 std::copy_n(&pv[0], pv.
size(), &partitioned_pv[id_offset_partition]);
242 std::size_t id_offset = 0;
247 [&](std::vector<const MeshLib::Element*>
const& elements)
249 for (
auto const element : elements)
251 int const number_of_element_field_data =
256 auto const element_id = element->getID();
257 int const begin_pos = element_ip_data_offsets[element_id];
258 int const end_pos = element_ip_data_offsets[element_id + 1];
260 std::copy(pv.
begin() + begin_pos, pv.
begin() + end_pos,
261 &partitioned_pv[id_offset + id_offset_partition]);
262 id_offset += number_of_element_field_data;
273 std::vector<Partition>& partitions)
275 auto const& opt_ip_meta_data_all =
277 for (
auto const& [name, property] : properties)
279 auto const item_type =
property->getMeshItemType();
288 if (property->getPropertyName().find(
"_ip") == std::string::npos)
293 auto const& ip_meta_data =
295 opt_ip_meta_data_all, property->getPropertyName());
296 auto countIntegrationPoints =
297 [&](std::vector<const MeshLib::Element*>
const& elements)
299 std::size_t counter = 0;
300 for (
auto const element : elements)
302 int const number_of_integration_points =
304 ip_meta_data, *element);
305 counter += number_of_integration_points;
310 for (
auto& p : partitions)
312 p.number_of_integration_points =
313 countIntegrationPoints(p.regular_elements) +
314 countIntegrationPoints(p.ghost_elements);
322 std::vector<MeshLib::Element*>
const& global_mesh_elements,
325 std::vector<Partition>
const& partitions,
327 std::map<MeshLib::MeshItemType, std::size_t>
const& total_number_of_tuples)
335 std::size_t partitioned_pv_size = total_number_of_tuples.at(item_type) *
338 std::vector<std::size_t> element_ip_data_offsets;
346 partitioned_pv_size = pv->
size() * partitions.size();
349 element_ip_data_offsets =
351 global_mesh_elements, *pv, properties);
357 if (partitioned_pv ==
nullptr)
360 "Could not create partitioned property vector {:s} for {} data "
364 partitioned_pv->resize(partitioned_pv_size);
366 auto copy_property_vector_values =
367 [&](
Partition const& p, std::size_t offset)
372 element_ip_data_offsets,
373 *pv, *partitioned_pv);
388 "Copying of property vector values for mesh item type {:s} is not "
390 toString(item_type));
393 std::size_t position_offset(0);
394 for (
auto p : partitions)
396 position_offset += copy_property_vector_values(p, position_offset);
402 std::vector<Partition>
const& partitions,
403 std::size_t
const total_number_of_cells)
405 auto* vtk_ghost_type =
408 total_number_of_cells, 1);
409 if (vtk_ghost_type ==
nullptr)
411 OGS_FATAL(
"Could not create '{}' cell data array.",
415 assert(vtk_ghost_type->size() == total_number_of_cells);
416 std::size_t offset = 0;
417 for (
auto const& partition : partitions)
419 offset += partition.regular_elements.size();
420 for (std::size_t i = 0; i < partition.ghost_elements.size(); ++i)
422 if (partition.duplicate_ghost_cell[i])
424 (*vtk_ghost_type)[offset + i] |=
425 vtkDataSetAttributes::DUPLICATECELL;
428 offset += partition.ghost_elements.size();
434 std::unique_ptr<MeshLib::Mesh>
const& mesh,
435 std::vector<Partition>& partitions)
445 auto count_tuples = [&](
MeshItemType const mesh_item_type)
447 return std::accumulate(
448 begin(partitions), end(partitions), 0,
449 [&](std::size_t
const sum,
Partition const& p)
453 std::map<MeshItemType, std::size_t>
const total_number_of_tuples = {
460 "total number of tuples after partitioning defined for cells is {:d} "
461 "and for nodes {:d} and for integration points {:d}.",
471 [&](
auto type,
auto const property)
474 mesh->getElements(), partitioned_properties, properties,
477 total_number_of_tuples);
484 return partitioned_properties;
488 std::vector<Partition>& partitions)
490 std::vector<bool> cell_visited(mesh.
getElements().size(),
false);
492 for (
auto& partition : partitions)
494 partition.duplicate_ghost_cell.resize(partition.ghost_elements.size(),
497 for (std::size_t i = 0; i < partition.ghost_elements.size(); i++)
499 const auto& ghost_element = *partition.ghost_elements[i];
500 if (!cell_visited[ghost_element.getID()])
502 cell_visited[ghost_element.getID()] =
true;
503 partition.duplicate_ghost_cell[i] =
false;
510 std::vector<MeshLib::Element*>
const& global_mesh_elements,
513 auto const& opt_ip_meta_data_all =
515 for (
auto const& [name, property] : properties)
517 auto const item_type =
property->getMeshItemType();
526 if (property->getPropertyName().find(
"_ip") == std::string::npos)
531 std::size_t number_of_total_integration_points = 0;
532 auto const ip_meta_data =
534 opt_ip_meta_data_all, property->getPropertyName());
535 for (
auto const element : global_mesh_elements)
537 int const number_of_integration_points =
540 number_of_total_integration_points += number_of_integration_points;
546 if (pv->size() != number_of_total_integration_points * component_number)
549 "The property vector's size {:d} for integration point data "
550 "{:s} does not match its actual size {:d}. The field data in "
551 "the vtu file are wrong.",
553 number_of_total_integration_points * component_number);
559 std::vector<std::size_t>
const& node_partition_map,
560 std::vector<MeshLib::Element*>
const& elements,
561 std::span<std::size_t const>
const bulk_node_ids)
563 auto node_partition_ids = ranges::views::transform(
566 auto node_lookup = ranges::views::transform(
567 [&](std::size_t
const i)
568 {
return node_partition_map[bulk_node_ids[i]]; });
571 ranges::to<std::vector>;
574 return elements | node_partition_ids | ranges::to<std::vector>;
578 std::vector<Partition>& partitions,
579 std::vector<std::size_t>
const& nodes_partition_ids,
580 std::vector<MeshLib::Node*>
const& nodes,
581 std::span<std::size_t const>
const bulk_node_ids)
583 for (
auto const*
const node : nodes)
585 partitions[nodes_partition_ids[bulk_node_ids[node->getID()]]]
586 .nodes.push_back(node);
593 std::vector<MeshLib::Node const*> higher_order_nodes;
596 std::tie(partition.
nodes, higher_order_nodes) =
599 std::copy(begin(higher_order_nodes), end(higher_order_nodes),
600 std::back_inserter(partition.
nodes));
605 std::vector<Partition>& partitions,
MeshLib::Mesh const& mesh)
607 for (
auto& partition : partitions)
618 for (
auto& partition : partitions)
620 partition.number_of_regular_nodes = partition.nodes.size();
621 partition.number_of_mesh_base_nodes = number_of_mesh_base_nodes;
622 partition.number_of_mesh_all_nodes = number_of_mesh_all_nodes;
627 std::vector<Partition>& partitions,
629 std::vector<std::vector<std::size_t>>
const& partition_ids_per_element)
633 auto const element_id = element->getID();
634 auto node_partition_ids = partition_ids_per_element[element_id];
636 std::sort(node_partition_ids.begin(), node_partition_ids.end());
638 std::unique(node_partition_ids.begin(), node_partition_ids.end());
639 node_partition_ids.erase(last, node_partition_ids.end());
642 if (node_partition_ids.size() == 1)
644 partitions[node_partition_ids[0]].regular_elements.push_back(
649 for (
auto const partition_id : node_partition_ids)
651 partitions[partition_id].ghost_elements.push_back(element);
661 std::vector<Partition>& partitions,
MeshLib::Mesh const& mesh,
662 std::vector<std::size_t>
const& nodes_partition_ids,
663 std::span<std::size_t const>
const node_id_mapping)
665 for (std::size_t part_id = 0; part_id < partitions.size(); part_id++)
667 auto& partition = partitions[part_id];
668 std::vector<MeshLib::Node*> base_ghost_nodes;
669 std::vector<MeshLib::Node*> higher_order_ghost_nodes;
670 std::tie(base_ghost_nodes, higher_order_ghost_nodes) =
672 part_id, mesh.
getNodes(), partition.ghost_elements,
673 nodes_partition_ids, mesh, node_id_mapping);
675 std::copy(begin(base_ghost_nodes), end(base_ghost_nodes),
676 std::back_inserter(partition.nodes));
678 partition.number_of_base_nodes =
679 partition.number_of_regular_base_nodes + base_ghost_nodes.size();
681 std::copy(begin(higher_order_ghost_nodes),
682 end(higher_order_ghost_nodes),
683 std::back_inserter(partition.nodes));
689 std::vector<std::size_t>
const& nodes_partition_ids,
690 std::span<std::size_t const>
const bulk_node_ids)
695 nodes_partition_ids, mesh.
getElements(), bulk_node_ids);
696 INFO(
"partitionMesh(): Partition IDs per element computed in {:g} s",
702 INFO(
"partitionMesh(): distribute nodes to partitions took {:g} s",
708 "partitionMesh(): sorting [base nodes | higher order nodes] took {:g} "
715 "partitionMesh(): setting number of nodes and of all mesh base nodes "
721 partition_ids_per_element);
722 INFO(
"partitionMesh(): distribute elements into partitions took {:g} s",
727 partitions, mesh, nodes_partition_ids, bulk_node_ids);
728 INFO(
"partitionMesh(): determine / append ghost nodes took {:g} s",
733 INFO(
"partitionMesh(): markDuplicateGhostCells took {:g} s",
739 std::vector<std::size_t> bulk_node_ids(
_mesh->getNumberOfNodes());
740 std::iota(bulk_node_ids.begin(), bulk_node_ids.end(), 0);
756 std::vector<Partition>
const& partitions,
759 auto const bulk_node_ids_string =
768 auto const bulk_element_ids_string =
771 static_cast<std::string
>(bulk_element_ids_string),
783 std::vector<Partition>
const& local_partitions)
const
785 if (bulk_node_ids_pv ==
nullptr)
790 auto& bulk_node_ids = *bulk_node_ids_pv;
792 std::size_t offset = 0;
794 assert(
_partitions.size() == local_partitions.size());
795 int const n_partitions =
static_cast<int>(
_partitions.size());
796 for (
int partition_id = 0; partition_id < n_partitions; ++partition_id)
798 auto const& bulk_partition =
_partitions[partition_id];
799 auto const& local_partition = local_partitions[partition_id];
802 auto const& bulk_nodes = bulk_partition.nodes;
803 auto const n_bulk_nodes = bulk_nodes.size();
804 std::map<std::size_t, std::size_t> global_to_local;
805 for (std::size_t local_node_id = 0; local_node_id < n_bulk_nodes;
808 global_to_local[bulk_nodes[local_node_id]->getID()] = local_node_id;
811 auto const& local_nodes = local_partition.nodes;
812 auto const n_local_nodes = local_nodes.size();
813 for (std::size_t local_node_id = 0; local_node_id < n_local_nodes;
816 bulk_node_ids[offset + local_node_id] =
817 global_to_local[bulk_node_ids[offset + local_node_id]];
819 offset += n_local_nodes;
825 std::vector<Partition>
const& local_partitions)
const
827 if (bulk_element_ids_pv ==
nullptr)
832 auto& bulk_element_ids = *bulk_element_ids_pv;
834 std::size_t offset = 0;
836 assert(
_partitions.size() == local_partitions.size());
837 int const n_partitions =
static_cast<int>(
_partitions.size());
838 for (
int partition_id = 0; partition_id < n_partitions; ++partition_id)
840 auto const& bulk_partition =
_partitions[partition_id];
841 auto const& local_partition = local_partitions[partition_id];
844 std::map<std::size_t, std::size_t> global_to_local;
847 std::vector<MeshLib::Element const*>
const& elements,
848 std::size_t
const offset)
850 auto const n_elements = elements.size();
851 for (std::size_t e = 0; e < n_elements; ++e)
853 global_to_local[elements[e]->getID()] = offset + e;
857 map_elements(bulk_partition.regular_elements, 0);
858 map_elements(bulk_partition.ghost_elements,
859 bulk_partition.regular_elements.size());
862 auto renumber_elements =
863 [&bulk_element_ids, &global_to_local](
864 std::vector<MeshLib::Element const*>
const& elements,
865 std::size_t
const offset)
867 auto const n_elements = elements.size();
868 for (std::size_t e = 0; e < n_elements; ++e)
870 bulk_element_ids[offset + e] =
871 global_to_local[bulk_element_ids[offset + e]];
876 offset += renumber_elements(local_partition.regular_elements, offset);
877 offset += renumber_elements(local_partition.ghost_elements, offset);
884 auto const bulk_node_ids_string =
886 auto const& bulk_node_ids =
887 mesh.getProperties().getPropertyVector<std::size_t>(
890 std::vector<Partition> partitions(
_partitions.size());
899 std::size_t node_global_id_offset = 0;
903 for (std::size_t i = 0; i < partition.number_of_regular_nodes; i++)
906 node_global_id_offset++;
915 os.write(
reinterpret_cast<const char*
>(pv.
data()), pv.
size() *
sizeof(T));
921 std::ostream& out_val, std::ostream& out_meta)
946 std::vector<Partition>
const& partitions,
949 auto const number_of_properties =
950 partitioned_properties.
size(mesh_item_type);
951 if (number_of_properties == 0)
956 auto const file_name_infix =
toString(mesh_item_type);
958 auto const file_name_cfg = file_name_base +
"_partitioned_" +
959 file_name_infix +
"_properties_cfg" +
960 std::to_string(partitions.size()) +
".bin";
961 std::ofstream out(file_name_cfg, std::ios::binary);
964 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_cfg);
967 auto const file_name_val = file_name_base +
"_partitioned_" +
968 file_name_infix +
"_properties_val" +
969 std::to_string(partitions.size()) +
".bin";
970 std::ofstream out_val(file_name_val, std::ios::binary);
973 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_val);
979 partitioned_properties,
980 [&](
auto type,
auto const& property)
985 mesh_item_type, out_val, out);
988 unsigned long offset = 0;
989 for (
const auto& partition : partitions)
992 offset,
static_cast<unsigned long>(
993 partition.numberOfMeshItems(mesh_item_type))};
995 "Write meta data for node-based PropertyVector: global offset "
996 "{:d}, number of tuples {:d}",
1009 std::ostream&
writeConfig(std::ostream& os)
const;
1014 os.write(
reinterpret_cast<const char*
>(
this),
sizeof(
ConfigOffsets));
1016 static long reserved = 0;
1018 return os.write(
reinterpret_cast<const char*
>(&reserved),
sizeof(
long));
1030 return {
static_cast<long>(partition.
nodes.size()),
1062 const std::string& file_name_base, std::vector<Partition>
const& partitions)
1064 auto const file_name_cfg = file_name_base +
"_partitioned_msh_cfg" +
1065 std::to_string(partitions.size()) +
".bin";
1066 std::ofstream of_bin_cfg(file_name_cfg, std::ios::binary);
1069 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_cfg);
1072 std::vector<long> partitions_element_offsets;
1073 partitions_element_offsets.reserve(partitions.size());
1074 std::vector<long> partitions_ghost_element_offsets;
1075 partitions_ghost_element_offsets.reserve(partitions.size());
1078 for (
const auto& partition : partitions)
1080 partition.writeConfig(of_bin_cfg);
1087 partitions_element_offsets.push_back(
1088 partition_offsets.regular_elements);
1089 partitions_ghost_element_offsets.push_back(
1090 partition_offsets.ghost_elements);
1093 return std::make_tuple(partitions_element_offsets,
1094 partitions_ghost_element_offsets);
1106 const std::unordered_map<std::size_t, long>& local_node_ids,
1107 std::vector<long>& elem_info,
1110 constexpr unsigned mat_id =
1113 elem_info[counter++] = mat_id;
1114 elem_info[counter++] =
static_cast<long>(elem.
getCellType());
1115 elem_info[counter++] = nn;
1117 for (
long i = 0; i < nn; i++)
1119 auto const& n = *elem.
getNode(i);
1120 elem_info[counter++] = local_node_ids.at(n.getID());
1126 std::vector<MeshLib::Node const*>
const& nodes)
1128 std::unordered_map<std::size_t, long> local_ids;
1129 local_ids.reserve(nodes.size());
1131 long local_node_id = 0;
1132 for (
const auto* node : nodes)
1134 local_ids[node->getID()] = local_node_id++;
1146 std::vector<Partition>
const& partitions,
1147 std::vector<long>
const& regular_element_offsets,
1148 std::vector<long>
const& ghost_element_offsets)
1150 const std::string npartitions_str = std::to_string(partitions.size());
1152 auto const file_name_ele =
1153 file_name_base +
"_partitioned_msh_ele" + npartitions_str +
".bin";
1154 std::ofstream element_info_os(file_name_ele, std::ios::binary);
1155 if (!element_info_os)
1157 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_ele);
1160 auto const file_name_ele_g =
1161 file_name_base +
"_partitioned_msh_ele_g" + npartitions_str +
".bin";
1162 std::ofstream ghost_element_info_os(file_name_ele_g, std::ios::binary);
1163 if (!ghost_element_info_os)
1165 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name_ele_g);
1168 for (std::size_t i = 0; i < partitions.size(); i++)
1170 const auto& partition = partitions[i];
1175 std::vector<long> ele_info(regular_element_offsets[i]);
1177 auto writeElementData =
1179 std::vector<MeshLib::Element const*>
const& elements,
1180 long const element_offsets,
1181 std::ofstream& output_stream)
1183 long counter = elements.size();
1184 std::vector<long> ele_info(element_offsets);
1186 for (std::size_t j = 0; j < elements.size(); j++)
1188 const auto* elem = elements[j];
1189 ele_info[j] = counter;
1194 output_stream.write(
reinterpret_cast<const char*
>(ele_info.data()),
1195 ele_info.size() *
sizeof(
long));
1199 writeElementData(partition.regular_elements, regular_element_offsets[i],
1202 writeElementData(partition.ghost_elements, ghost_element_offsets[i],
1203 ghost_element_info_os);
1212 std::vector<Partition>
const& partitions,
1213 std::vector<std::size_t>
const& global_node_ids)
1215 auto const file_name = file_name_base +
"_partitioned_msh_nod" +
1216 std::to_string(partitions.size()) +
".bin";
1217 std::ofstream os(file_name, std::ios::binary);
1220 OGS_FATAL(
"Could not open file '{:s}' for output.", file_name);
1223 for (
const auto& partition : partitions)
1225 partition.writeNodes(os, global_node_ids);
1240 const std::vector<IntegerType>& regular_element_offsets =
1241 std::get<0>(elements_offsets);
1242 const std::vector<IntegerType>& ghost_element_offsets =
1243 std::get<1>(elements_offsets);
1245 ghost_element_offsets);
1251 std::string
const& output_filename_base,
1252 std::vector<Partition>
const& partitions,
1257 const auto elem_integers =
1260 const std::vector<IntegerType>& num_elem_integers =
1261 std::get<0>(elem_integers);
1262 const std::vector<IntegerType>& num_g_elem_integers =
1263 std::get<1>(elem_integers);
1264 writeElements(output_filename_base, partitions, num_elem_integers,
1265 num_g_elem_integers);
1267 writeProperties(output_filename_base, partitioned_properties, partitions,
1269 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)
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.
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
constexpr std::size_t getNumberOfTuples() const
constexpr PROP_VAL_TYPE * begin()
constexpr std::size_t size() const
constexpr const PROP_VAL_TYPE * data() const
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)
std::vector< std::vector< std::size_t > > computePartitionIDPerElement(std::vector< std::size_t > const &node_partition_map, std::vector< MeshLib::Element * > const &elements, std::span< std::size_t const > const bulk_node_ids)
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::span< std::size_t const > const node_id_mapping)
void setIntegrationPointNumberOfPartition(MeshLib::Properties const &properties, std::vector< Partition > &partitions)
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)
void distributeNodesToPartitions(std::vector< Partition > &partitions, std::vector< std::size_t > const &nodes_partition_ids, std::vector< MeshLib::Node * > const &nodes, std::span< std::size_t const > const bulk_node_ids)
PartitionOffsets computePartitionOffsets(Partition const &partition)
std::size_t partitionLookup(std::size_t const &node_id, std::vector< std::size_t > const &partition_ids, std::span< std::size_t const > const node_id_mapping)
NodeWiseMeshPartitioner::IntegerType getNumberOfIntegerVariablesOfElements(std::vector< const MeshLib::Element * > const &elements)
void partitionMesh(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh, std::vector< std::size_t > const &nodes_partition_ids, std::span< std::size_t const > 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)
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 determineAndAppendGhostNodesToPartitions(std::vector< Partition > &partitions, MeshLib::Mesh const &mesh, std::vector< std::size_t > const &nodes_partition_ids, std::span< std::size_t const > const node_id_mapping)
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)
void applyToPropertyVectors(Properties const &properties, Function f)
constexpr std::string vtkGhostTypeString
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