11void writeMETIS(std::vector<MeshLib::Element*>
const& elements,
12 const std::string& file_name)
14 std::ofstream os(file_name, std::ios::trunc);
17 OGS_FATAL(
"Error: cannot open file {:s}.", file_name.data());
22 OGS_FATAL(
"Error: Cannot write in file {:s}.", file_name.data());
25 os << elements.size() <<
" \n";
26 for (
const auto* elem : elements)
28 os << getNodeIndex(*elem, 0) + 1;
29 for (
unsigned j = 1; j < elem->getNumberOfNodes(); j++)
31 os <<
" " << getNodeIndex(*elem, j) + 1;
37std::vector<std::size_t>
readMetisData(
const std::string& file_name_base,
38 long const number_of_partitions,
39 std::size_t
const number_of_nodes)
41 const std::string npartitions_str = std::to_string(number_of_partitions);
44 const std::string fname_parts =
45 file_name_base +
".mesh.npart." + npartitions_str;
47 std::ifstream npart_in(fname_parts);
48 if (!npart_in.is_open())
51 "Error: cannot open file {:s}. It may not exist!\n"
52 "Run mpmetis beforehand or use option -m",
56 std::vector<std::size_t> partition_ids(number_of_nodes);
58 std::size_t counter = 0;
59 while (!npart_in.eof())
61 npart_in >> partition_ids[counter++] >> std::ws;
62 if (counter == number_of_nodes)
70 OGS_FATAL(
"Error while reading file {:s}.", fname_parts.data());
73 if (counter != number_of_nodes)
75 OGS_FATAL(
"Error: data in {:s} are less than expected.",