19void writeMETIS(std::vector<MeshLib::Element*>
const& elements,
20 const std::string& file_name)
22 std::ofstream os(file_name, std::ios::trunc);
25 OGS_FATAL(
"Error: cannot open file {:s}.", file_name.data());
30 OGS_FATAL(
"Error: Cannot write in file {:s}.", file_name.data());
33 os << elements.size() <<
" \n";
34 for (
const auto* elem : elements)
36 os << getNodeIndex(*elem, 0) + 1;
37 for (
unsigned j = 1; j < elem->getNumberOfNodes(); j++)
39 os <<
" " << getNodeIndex(*elem, j) + 1;
45std::vector<std::size_t>
readMetisData(
const std::string& file_name_base,
46 long const number_of_partitions,
47 std::size_t
const number_of_nodes)
49 const std::string npartitions_str = std::to_string(number_of_partitions);
52 const std::string fname_parts =
53 file_name_base +
".mesh.npart." + npartitions_str;
55 std::ifstream npart_in(fname_parts);
56 if (!npart_in.is_open())
59 "Error: cannot open file {:s}. It may not exist!\n"
60 "Run mpmetis beforehand or use option -m",
64 std::vector<std::size_t> partition_ids(number_of_nodes);
66 std::size_t counter = 0;
67 while (!npart_in.eof())
69 npart_in >> partition_ids[counter++] >> std::ws;
70 if (counter == number_of_nodes)
78 OGS_FATAL(
"Error while reading file {:s}.", fname_parts.data());
81 if (counter != number_of_nodes)
83 OGS_FATAL(
"Error: data in {:s} are less than expected.",