mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
partitionCells: drop indent for namespace
This commit is contained in:
parent
e8f04eec68
commit
b95b342517
@ -44,9 +44,9 @@
|
||||
|
||||
namespace {
|
||||
|
||||
std::pair<std::vector<int>, int>
|
||||
countDomains(std::vector<int> partition_vector)
|
||||
{
|
||||
std::pair<std::vector<int>, int>
|
||||
countDomains(std::vector<int> partition_vector)
|
||||
{
|
||||
auto maxPos = std::max_element(partition_vector.begin(),
|
||||
partition_vector.end());
|
||||
|
||||
@ -54,13 +54,13 @@ namespace {
|
||||
? 0 : *maxPos + 1;
|
||||
|
||||
return { std::move(partition_vector), num_domains };
|
||||
}
|
||||
}
|
||||
|
||||
template <typename, class = void>
|
||||
struct HasZoltanPartitioning : public std::false_type {};
|
||||
template <typename, class = void>
|
||||
struct HasZoltanPartitioning : public std::false_type {};
|
||||
|
||||
template <typename GridType>
|
||||
struct HasZoltanPartitioning<
|
||||
template <typename GridType>
|
||||
struct HasZoltanPartitioning<
|
||||
GridType,
|
||||
std::void_t<decltype(std::declval<const GridType&>().zoltanPartitionWithoutScatter
|
||||
(std::declval<const std::vector<Opm::Well>*>(),
|
||||
@ -73,13 +73,13 @@ namespace {
|
||||
|
||||
namespace Opm {
|
||||
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCells(const Grid& grid,
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCells(const Grid& grid,
|
||||
const std::vector<Well>& wells,
|
||||
const std::string& method,
|
||||
const int num_local_domains,
|
||||
const double partition_imbalance)
|
||||
{
|
||||
{
|
||||
if (method == "zoltan") {
|
||||
if constexpr (HasZoltanPartitioning<Grid>::value) {
|
||||
return partitionCellsZoltan(grid, wells, num_local_domains, partition_imbalance);
|
||||
@ -97,12 +97,12 @@ namespace Opm {
|
||||
} else {
|
||||
OPM_THROW(std::runtime_error, "Unknown local domain partitioning method requested: " + method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Read from file, containing one number per cell.
|
||||
std::pair<std::vector<int>, int> partitionCellsFromFile(const std::string& filename, const int num_cells)
|
||||
{
|
||||
// Read from file, containing one number per cell.
|
||||
std::pair<std::vector<int>, int> partitionCellsFromFile(const std::string& filename, const int num_cells)
|
||||
{
|
||||
// Read file into single vector.
|
||||
std::ifstream is(filename);
|
||||
const std::vector<int> cellpart{std::istream_iterator<int>(is), std::istream_iterator<int>()};
|
||||
@ -115,12 +115,12 @@ namespace Opm {
|
||||
// Create and return the output domain vector.
|
||||
const int num_domains = (*std::max_element(cellpart.begin(), cellpart.end())) + 1;
|
||||
return { cellpart, num_domains };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Trivially simple partitioner
|
||||
std::pair<std::vector<int>, int> partitionCellsSimple(const int num_cells, const int num_domains)
|
||||
{
|
||||
// Trivially simple partitioner
|
||||
std::pair<std::vector<int>, int> partitionCellsSimple(const int num_cells, const int num_domains)
|
||||
{
|
||||
// Build the partitions.
|
||||
const int dom_sz = num_cells / num_domains;
|
||||
std::vector<int> bounds(num_domains + 1, dom_sz);
|
||||
@ -135,30 +135,30 @@ namespace Opm {
|
||||
std::fill(part.begin() + bounds[i], part.begin() + bounds[i + 1], i);
|
||||
}
|
||||
return { part, num_domains };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCellsZoltan(const Grid& grid,
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCellsZoltan(const Grid& grid,
|
||||
const std::vector<Well>& wells,
|
||||
const int num_domains,
|
||||
const double domain_imbalance)
|
||||
{
|
||||
{
|
||||
auto partition_vector = grid.zoltanPartitionWithoutScatter
|
||||
(&wells, nullptr, num_domains, domain_imbalance);
|
||||
|
||||
return countDomains(std::move(partition_vector));
|
||||
}
|
||||
}
|
||||
|
||||
template std::pair<std::vector<int>,int>
|
||||
partitionCells<Dune::CpGrid>(const Dune::CpGrid&,
|
||||
template std::pair<std::vector<int>,int>
|
||||
partitionCells<Dune::CpGrid>(const Dune::CpGrid&,
|
||||
const std::vector<Well>&,
|
||||
const std::string&,
|
||||
const int,
|
||||
const double);
|
||||
|
||||
template std::pair<std::vector<int>,int>
|
||||
partitionCells<Dune::PolyhedralGrid<3,3,double>>(const Dune::PolyhedralGrid<3,3,double>&,
|
||||
template std::pair<std::vector<int>,int>
|
||||
partitionCells<Dune::PolyhedralGrid<3,3,double>>(const Dune::PolyhedralGrid<3,3,double>&,
|
||||
const std::vector<Well>&,
|
||||
const std::string&,
|
||||
const int,
|
||||
@ -166,18 +166,17 @@ namespace Opm {
|
||||
|
||||
#if HAVE_DUNE_ALUGRID
|
||||
#if HAVE_MPI
|
||||
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>;
|
||||
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>;
|
||||
#else
|
||||
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridNoComm>;
|
||||
using ALUGrid3CN = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridNoComm>;
|
||||
#endif //HAVE_MPI
|
||||
|
||||
template std::pair<std::vector<int>,int>
|
||||
partitionCells<ALUGrid3CN>(const ALUGrid3CN&,
|
||||
template std::pair<std::vector<int>,int>
|
||||
partitionCells<ALUGrid3CN>(const ALUGrid3CN&,
|
||||
const std::vector<Well>&,
|
||||
const std::string&,
|
||||
const int,
|
||||
const double);
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace Opm
|
||||
|
@ -24,35 +24,34 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
class Well;
|
||||
namespace Opm {
|
||||
|
||||
/// Partitions the grid using the specified method.
|
||||
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCells(const Grid& grid,
|
||||
class Well;
|
||||
|
||||
/// Partitions the grid using the specified method.
|
||||
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCells(const Grid& grid,
|
||||
const std::vector<Well>& wells,
|
||||
const std::string& method,
|
||||
const int num_local_domains,
|
||||
const double partition_imbalance);
|
||||
|
||||
/// 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.
|
||||
std::pair<std::vector<int>, int> partitionCellsFromFile(const std::string& filename, const int num_cells);
|
||||
/// 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.
|
||||
std::pair<std::vector<int>, int> partitionCellsFromFile(const std::string& filename, const int num_cells);
|
||||
|
||||
/// Trivially simple partitioner assigning partitions en bloc, consecutively by cell index.
|
||||
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
|
||||
std::pair<std::vector<int>, int> partitionCellsSimple(const int num_cells, const int num_domains);
|
||||
/// Trivially simple partitioner assigning partitions en bloc, consecutively by cell index.
|
||||
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
|
||||
std::pair<std::vector<int>, int> partitionCellsSimple(const int num_cells, const int num_domains);
|
||||
|
||||
/// Partitions the grid using the Zoltan graph partitioner.
|
||||
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCellsZoltan(const Grid& grid,
|
||||
/// Partitions the grid using the Zoltan graph partitioner.
|
||||
/// \return pair containing a partition vector (partition number for each cell), and the number of partitions.
|
||||
template<class Grid>
|
||||
std::pair<std::vector<int>, int> partitionCellsZoltan(const Grid& grid,
|
||||
const std::vector<Well>& wells,
|
||||
const int num_domains,
|
||||
const double domain_imbalance);
|
||||
} // namespace Opm
|
||||
|
||||
|
||||
#endif // OPM_ASPINPARTITION_HEADER_INCLUDED
|
||||
|
Loading…
Reference in New Issue
Block a user