23 "Koch, Baker and Alcouffe based partitioning. "
24 "This is an overlayed ortho-grid based partitioner");
33 std::vector<double>{},
34 "Location of the internal x-cuts. Require nx-1 entries");
37 std::vector<double>{},
38 "Location of the internal y-cuts. Require ny-1 entries");
41 std::vector<double>{},
42 "Location of the internal z-cuts. Require nz-1 entries");
49 nx_(params.GetParamValue<size_t>(
"nx")),
50 ny_(params.GetParamValue<size_t>(
"ny")),
51 nz_(params.GetParamValue<size_t>(
"nz")),
52 xcuts_(params.GetParamVectorValue<double>(
"xcuts")),
53 ycuts_(params.GetParamVectorValue<double>(
"ycuts")),
54 zcuts_(params.GetParamVectorValue<double>(
"zcuts")),
61 const auto& cuts = *cuts_ptr;
64 if (cuts.size() != (n - 1))
66 "cuts\" is not equal to n" + name +
"-1.");
67 if (cuts.empty())
continue;
71 double prev_value = 0.0;
72 for (
const double cut_value : *cuts_ptr)
75 cut_value <= prev_value,
76 "Parameter \"" + name +
77 "\" requires monotonically increasing values");
78 prev_value = cut_value;
86 const std::vector<chi_mesh::Vector3>& centroids,
92 centroids.size() != graph.size(),
93 "Graph number of entries not equal to centroids' number of entries.");
94 const size_t num_cells = graph.size();
95 std::vector<int64_t> pids(num_cells, 0);
96 for (
size_t c = 0; c < num_cells; ++c)
98 const auto& point = centroids[c];
100 std::array<size_t, 3> p_vals = {0, 0, 0};
101 for (
size_t i = 0; i < 3; ++i)
104 const size_t num_cuts = cuts.size();
107 bool home_found =
false;
108 for (
size_t j = 0; j < num_cuts; ++j)
109 if (cuts[j] > point[i])
122 const int64_t i =
static_cast<int64_t
>(p_vals[0]);
123 const int64_t j =
static_cast<int64_t
>(p_vals[1]);
124 const int64_t k =
static_cast<int64_t
>(p_vals[2]);
126 pids[c] = nx * ny * k + nx * j + i;
129 if ((
nx_ *
ny_ *
nz_) != number_of_parts)
131 <<
"KBAGraphPartitioner::Partition nx_*ny_*nz_ != number_of_parts";
135 std::vector<int64_t> real_pids(num_cells, 0);
136 for (
size_t c = 0; c < num_cells; ++c)
138 for (
size_t p = 0; p < number_of_parts; ++p)
140 if (pids[c] >= pid_subsets[p].ss_begin and
141 pids[c] <= pid_subsets[p].ss_end)
142 real_pids[c] =
static_cast<int64_t
>(p);
#define ChiLogicalErrorIf(condition, message)
#define ChiInvalidArgumentIf(condition, message)
#define ChiInvalidArgument(message)
static InputParameters GetInputParameters()
std::array< CoordinateInfo, 3 > coordinate_infos_
static InputParameters GetInputParameters()
std::vector< int64_t > Partition(const std::vector< std::vector< uint64_t > > &graph, const std::vector< chi_mesh::Vector3 > ¢roids, int number_of_parts) override
KBAGraphPartitioner(const InputParameters ¶ms)
std::vector< SubSetInfo > MakeSubSets(size_t num_items, size_t desired_num_subsets)
RegisterChiObject(chi, KBAGraphPartitioner)