mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5579 from bska/dont-count-cells-if-not-needed
Don't Count Cells Unless Needed
This commit is contained in:
commit
be94b037bc
@ -918,19 +918,25 @@ private:
|
|||||||
{
|
{
|
||||||
const auto& grid = this->model_.simulator().vanguard().grid();
|
const auto& grid = this->model_.simulator().vanguard().grid();
|
||||||
|
|
||||||
using GridView = std::remove_cv_t<std::remove_reference_t<decltype(grid.leafGridView())>>;
|
using GridView = std::remove_cv_t<std::remove_reference_t<
|
||||||
using Element = std::remove_cv_t<std::remove_reference_t<typename GridView::template Codim<0>::Entity>>;
|
decltype(grid.leafGridView())>>;
|
||||||
|
|
||||||
|
using Element = std::remove_cv_t<std::remove_reference_t<
|
||||||
|
typename GridView::template Codim<0>::Entity>>;
|
||||||
|
|
||||||
const auto& param = this->model_.param();
|
const auto& param = this->model_.param();
|
||||||
|
|
||||||
auto zoltan_ctrl = ZoltanPartitioningControl<Element>{};
|
auto zoltan_ctrl = ZoltanPartitioningControl<Element>{};
|
||||||
|
|
||||||
zoltan_ctrl.domain_imbalance = param.local_domain_partition_imbalance_;
|
zoltan_ctrl.domain_imbalance = param.local_domain_partition_imbalance_;
|
||||||
|
|
||||||
zoltan_ctrl.index =
|
zoltan_ctrl.index =
|
||||||
[elementMapper = &this->model_.simulator().model().elementMapper()]
|
[elementMapper = &this->model_.simulator().model().elementMapper()]
|
||||||
(const Element& element)
|
(const Element& element)
|
||||||
{
|
{
|
||||||
return elementMapper->index(element);
|
return elementMapper->index(element);
|
||||||
};
|
};
|
||||||
|
|
||||||
zoltan_ctrl.local_to_global =
|
zoltan_ctrl.local_to_global =
|
||||||
[cartMapper = &this->model_.simulator().vanguard().cartesianIndexMapper()]
|
[cartMapper = &this->model_.simulator().vanguard().cartesianIndexMapper()]
|
||||||
(const int elemIdx)
|
(const int elemIdx)
|
||||||
@ -940,23 +946,24 @@ private:
|
|||||||
|
|
||||||
// Forming the list of wells is expensive, so do this only if needed.
|
// Forming the list of wells is expensive, so do this only if needed.
|
||||||
const auto need_wells = param.local_domain_partition_method_ == "zoltan";
|
const auto need_wells = param.local_domain_partition_method_ == "zoltan";
|
||||||
|
|
||||||
const auto wells = need_wells
|
const auto wells = need_wells
|
||||||
? this->model_.simulator().vanguard().schedule().getWellsatEnd()
|
? this->model_.simulator().vanguard().schedule().getWellsatEnd()
|
||||||
: std::vector<Well>{};
|
: std::vector<Well>{};
|
||||||
|
|
||||||
const auto& possibleFutureConnectionSet = need_wells
|
const auto& possibleFutureConnectionSet = need_wells
|
||||||
? this->model_.simulator().vanguard().schedule().getPossibleFutureConnections()
|
? this->model_.simulator().vanguard().schedule().getPossibleFutureConnections()
|
||||||
: std::unordered_map<std::string, std::set<int>> {};
|
: std::unordered_map<std::string, std::set<int>> {};
|
||||||
|
|
||||||
// If defaulted parameter for number of domains, choose a reasonable default.
|
// If defaulted parameter for number of domains, choose a reasonable default.
|
||||||
constexpr int default_cells_per_domain = 1000;
|
constexpr int default_cells_per_domain = 1000;
|
||||||
const int num_cells = Opm::detail::countGlobalCells(grid);
|
const int num_domains = (param.num_local_domains_ > 0)
|
||||||
const int num_domains = param.num_local_domains_ > 0
|
|
||||||
? param.num_local_domains_
|
? param.num_local_domains_
|
||||||
: num_cells / default_cells_per_domain;
|
: detail::countGlobalCells(grid) / default_cells_per_domain;
|
||||||
|
|
||||||
return ::Opm::partitionCells(param.local_domain_partition_method_,
|
return ::Opm::partitionCells(param.local_domain_partition_method_,
|
||||||
num_domains,
|
num_domains, grid.leafGridView(), wells,
|
||||||
grid.leafGridView(), wells, possibleFutureConnectionSet, zoltan_ctrl);
|
possibleFutureConnectionSet, zoltan_ctrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> reconstitutePartitionVector() const
|
std::vector<int> reconstitutePartitionVector() const
|
||||||
|
Loading…
Reference in New Issue
Block a user