mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Enable Loading Parallel NLDD Partition From File
This commit adds support for loading a three-column NLDD
partitioning scheme of the form
MPI_Rank Cartesian_Index NLDD_Domain_ID
from a text file. In an MPI run it is assumed that the first column
holds integers in the range 0..MPI_Size()-1, and typically that each
such integer is listed at least once. In a sequential run, the MPI
rank column is ignored.
With this scheme we can load the same partition files that we write,
for increased repeatability and determinism, and we can also
experiment with externally generated NLDD partitions.
This commit is contained in:
@@ -34,16 +34,9 @@ namespace {
|
||||
return { *mmPos.first, *mmPos.second };
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
std::pair<std::vector<int>, int>
|
||||
Opm::util::compressAndCountPartitionIDs(std::vector<int>&& parts0)
|
||||
{
|
||||
auto parts = std::pair<std::vector<int>, int> { std::move(parts0), 0 };
|
||||
|
||||
auto& [partition, num_domains] = parts;
|
||||
|
||||
if (! partition.empty()) {
|
||||
void compressAndCountPartitionIDs(std::vector<int>& partition,
|
||||
int& num_domains)
|
||||
{
|
||||
const auto& [low, high] = valueRange(partition);
|
||||
|
||||
auto seen = std::vector<bool>(high - low + 1, false);
|
||||
@@ -64,6 +57,16 @@ Opm::util::compressAndCountPartitionIDs(std::vector<int>&& parts0)
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Anonymous namespace
|
||||
|
||||
std::pair<std::vector<int>, int>
|
||||
Opm::util::compressAndCountPartitionIDs(std::vector<int>&& parts0)
|
||||
{
|
||||
auto parts = std::pair<std::vector<int>, int> { std::move(parts0), 0 };
|
||||
|
||||
if (! parts.first.empty()) {
|
||||
::compressAndCountPartitionIDs(parts.first, parts.second);
|
||||
}
|
||||
|
||||
return parts;
|
||||
}
|
||||
@@ -72,3 +75,9 @@ std::vector<int> Opm::util::compressPartitionIDs(std::vector<int>&& parts0)
|
||||
{
|
||||
return compressAndCountPartitionIDs(std::move(parts0)).first;
|
||||
}
|
||||
|
||||
void Opm::util::compressPartitionIDs(std::vector<int>& parts0)
|
||||
{
|
||||
[[maybe_unused]] auto num_domains = 0;
|
||||
::compressAndCountPartitionIDs(parts0, num_domains);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace Opm { namespace util {
|
||||
compressAndCountPartitionIDs(std::vector<int>&& parts0);
|
||||
|
||||
std::vector<int> compressPartitionIDs(std::vector<int>&& parts0);
|
||||
void compressPartitionIDs(std::vector<int>& parts0);
|
||||
}} // namespace Opm::util
|
||||
|
||||
#endif // OPM_UTIL_COMPRESS_PARTITION_HPP_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user