Merge pull request #6117 from jakobtorben/follow_up_comments_from_6103

Follow up comments from 6103 (NLDD partitioning)
This commit is contained in:
Atgeirr Flø Rasmussen authored and GitHub committed 2025-03-28 15:19:54 +01:00
commit 72024b18ce
5 files changed
+37 -21

No files matched your search

+7 -4
View File
@@ -120,7 +120,6 @@ public:
for (auto& domainId : partition_vector) {
if (domainId < 0) {
domainId = num_domains;
domains_to_skip_.push_back(domainId);
isolated_cells = true;
}
}
@@ -172,10 +171,13 @@ public:
Dune::SubGridPart<Grid> view{grid, std::move(seeds[index])};
// Mark the last domain for skipping if it contains isolated cells
const bool skip = isolated_cells && (index == num_domains - 1);
this->domains_.emplace_back(index,
std::move(partitions[index]),
std::move(interior),
std::move(view));
std::move(view),
skip);
}
// Set up container for the local system matrices.
@@ -241,7 +243,9 @@ public:
for (const int domain_index : domain_order) {
const auto& domain = domains_[domain_index];
SimulatorReportSingle local_report;
if (std::find(domains_to_skip_.begin(), domains_to_skip_.end(), domain.index) != domains_to_skip_.end()) {
if (domain.skip) {
local_report.converged = true;
domain_reports[domain.index] = local_report;
continue;
}
try {
@@ -1062,7 +1066,6 @@ private:
std::vector<Domain> domains_; //!< Vector of subdomains
std::vector<std::unique_ptr<Mat>> domain_matrices_; //!< Vector of matrix operator for each subdomain
std::vector<ISTLSolverType> domain_linsolvers_; //!< Vector of linear solvers for each domain
std::vector<int> domains_to_skip_; //!< Vector of domains to skip
SimulatorReportSingle local_reports_accumulated_; //!< Accumulated convergence report for subdomain solvers
int rank_ = 0; //!< MPI rank of this process
};
+6 -4
View File
@@ -69,10 +69,12 @@ namespace Opm
// of the subdomain. If empty, assumed to be all true. Not required for
// all nonlinear solver algorithms.
std::vector<bool> interior;
// Flag indicating if this domain should be skipped during solves
bool skip;
// Enables subdomain solves and linearization using the generic linearization
// approach (i.e. FvBaseLinearizer as opposed to TpfaLinearizer).
SubDomainIndices(const int i, std::vector<int>&& c, std::vector<bool>&& in)
: index(i), cells(std::move(c)), interior(std::move(in))
SubDomainIndices(const int i, std::vector<int>&& c, std::vector<bool>&& in, bool s)
: index(i), cells(std::move(c)), interior(std::move(in)), skip(s)
{}
};
@@ -83,8 +85,8 @@ namespace Opm
{
Dune::SubGridPart<Grid> view;
// Constructor that moves from its argument.
SubDomain(const int i, std::vector<int>&& c, std::vector<bool>&& in, Dune::SubGridPart<Grid>&& v)
: SubDomainIndices(i, std::move(c), std::move(in))
SubDomain(const int i, std::vector<int>&& c, std::vector<bool>&& in, Dune::SubGridPart<Grid>&& v, bool s)
: SubDomainIndices(i, std::move(c), std::move(in), s)
, view(std::move(v))
{}
};
+8 -5
View File
@@ -111,7 +111,7 @@ public:
/// partitioning.
///
/// \param[in] num_neighbor_levels Number of neighbor levels to include when connecting well cells.
/// Default is 0, which means only direct well connections are considered.
/// 0 means only direct well connections are considered, 1 means one level of neighbors, etc.
template <class GridView, class Element>
void buildLocalGraph(const GridView& grid_view,
const std::vector<Opm::Well>& wells,
@@ -121,10 +121,13 @@ public:
/// Connect neighbors of cells up to a specified level.
///
/// \param[in,out] cells Initial cells to find neighbors of. Updated to include all neighbors
/// up to specified level.
/// Starting from initial cells (level 0), adds their neighbors iteratively.
/// For each level k from 1 to num_levels, adds cells that are direct neighbors
/// of level k-1 cells.
///
/// \param[in] num_levels Number of neighbor levels to include.
/// \param[in,out] cells Initial cells (level 0). Returns these plus all neighbors
/// up to specified level.
/// \param[in] num_levels Number of neighbor levels to include. 0 keeps only initial cells.
void connectNeighbors(std::vector<int>& cells,
const int num_levels) const;
@@ -201,7 +204,7 @@ private:
/// on-rank active cell IDs. Return value from \c connectElements().
///
/// \param[in] num_neighbor_levels Number of neighbor levels to include when connecting well cells.
/// Default is 0, which means only direct well connections are considered.
/// 0 means only direct well connections are considered, 1 means one level of neighbors, etc.
template <typename Comm>
void connectWells(const Comm comm,
const std::vector<Opm::Well>& wells,
+2 -1
View File
@@ -85,6 +85,7 @@ struct ZoltanPartitioningControl
/// partitioning. Not used unless \code method == "zoltan" \endcode.
///
/// \param[in] num_neighbor_levels Number of neighbor levels to consider for partitioning.
/// 0 means only direct well connections are considered, 1 means one level of neighbors, etc.
///
/// \return Partition vector--subdomain ID for each cell in \p grid_view
/// traversal order for its interior cells--and the number of subdomains
@@ -97,7 +98,7 @@ partitionCells(const std::string& method,
const std::vector<Well>& wells,
const std::unordered_map<std::string, std::set<int>>& possibleFutureConnections,
const ZoltanPartitioningControl<Element>& zoltan_ctrl,
const int num_neighbor_levels = 0);
const int num_neighbor_levels);
/// Read a partitioning from file, assumed to contain one number per cell, its partition number.
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
+14 -7
View File
@@ -142,7 +142,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsTest)
auto [part, num_part] = Opm::partitionCells("simple", 3, grid.leafGridView(),
std::vector<Opm::Well>{},
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
BOOST_CHECK_EQUAL(num_part, 3);
BOOST_CHECK_EQUAL(part.size(), 12);
@@ -158,7 +159,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsTest)
auto [part, num_part] = Opm::partitionCells("zoltan", 3, grid.leafGridView(),
std::vector<Opm::Well>{},
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
BOOST_CHECK_EQUAL(num_part, 3);
BOOST_CHECK_EQUAL(part.size(), 12);
@@ -198,7 +200,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsWithWellMergeTest)
auto [part, num_part] = Opm::partitionCells("zoltan", 4, grid.leafGridView(),
wells,
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
// Verify number of partitions
BOOST_CHECK_EQUAL(num_part, 4);
@@ -241,7 +244,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsWithOverlappingWellsTest)
auto [part, num_part] = Opm::partitionCells("zoltan", 4, grid.leafGridView(),
wells,
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
// Verify number of partitions
BOOST_CHECK_EQUAL(num_part, 4);
@@ -321,7 +325,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsWithOverlappingWells3DTest)
auto [part, num_part] = Opm::partitionCells("zoltan", 10, grid.leafGridView(),
wells,
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
// Verify number of partitions
BOOST_CHECK_EQUAL(num_part, 10);
@@ -434,7 +439,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsComplexWellNetworkTest)
auto [part, num_part] = Opm::partitionCells("zoltan", 15, grid.leafGridView(),
wells,
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
// Verify number of partitions and grid size
BOOST_CHECK_EQUAL(num_part, 15);
@@ -591,7 +597,8 @@ BOOST_AUTO_TEST_CASE(PartitionCellsWithNonReachableCellsTest)
auto [part, num_part] = Opm::partitionCells("zoltan", 5, grid.leafGridView(),
wells,
std::unordered_map<std::string, std::set<int>>{},
zoltan_ctrl);
zoltan_ctrl,
0);
BOOST_CHECK_EQUAL(num_part, 5);
BOOST_CHECK_EQUAL(part.size(), 16);