19 std::pair<int,int> ij_id(0,0);
21 if (
Chi::mpi.process_count == 1){
return ij_id;}
25 auto& vol_mesher = mesh_handler.GetVolumeMesher();
28 size_t num_x_subsets = vol_mesher.options.xcuts.size()+1;
29 size_t num_y_subsets = vol_mesher.options.ycuts.size()+1;
31 size_t x_remainder = num_x_subsets%vol_mesher.options.partition_x;
32 size_t y_remainder = num_y_subsets%vol_mesher.options.partition_y;
37 <<
"When specifying x-partitioning, the number of grp_subsets in x "
38 "needs to be divisible by the number of partitions in x.";
45 <<
"When specifying y-partitioning, the number of grp_subsets in y "
46 "needs to be divisible by the number of partitions in y.";
50 size_t subsets_per_partitionx = num_x_subsets/vol_mesher.options.partition_x;
51 size_t subsets_per_partitiony = num_y_subsets/vol_mesher.options.partition_y;
56 for (
size_t i = subsets_per_partitionx-1;
57 i < vol_mesher.options.xcuts.size();
58 i += subsets_per_partitionx)
61 if (cell->
centroid_.
x <= vol_mesher.options.xcuts[i])
69 x = vol_mesher.options.partition_x-1;
75 for (
size_t i = subsets_per_partitiony-1;
76 i < vol_mesher.options.ycuts.size();
77 i += subsets_per_partitiony)
80 if (cell->
centroid_.
y <= vol_mesher.options.ycuts[i])
88 y = vol_mesher.options.partition_y - 1;
105 std::tuple<int,int,int> ijk_id(0,0,0);
106 bool found_partition =
false;
108 if (
Chi::mpi.process_count == 1){
return ijk_id;}
111 std::pair<int,int> ij_id = GetCellXYPartitionID(cell);
115 auto& vol_mesher = mesh_handler.GetVolumeMesher();
117 if (vol_mesher.options.partition_z == 1)
119 found_partition =
true;
120 std::get<0>(ijk_id) = ij_id.first;
121 std::get<1>(ijk_id) = ij_id.second;
122 std::get<2>(ijk_id) = 0;
129 if (vol_mesher.options.zcuts.empty())
131 size_t num_sub_layers = vertex_layers.size()-1;
133 if ((num_sub_layers%vol_mesher.options.partition_z) != 0)
136 <<
"Number of sub-layers in extruded mesh is not divisible "
137 <<
"by the requested number of z-partitions.";
141 int delta_zk = num_sub_layers/
142 vol_mesher.options.partition_z;
143 for (
int k=0; k<(vol_mesher.options.partition_z); k++)
145 int layer_index = k*delta_zk + delta_zk;
146 if (layer_index > (vertex_layers.size()-1))
148 layer_index = (int)vertex_layers.size()-1;
149 vol_mesher.options.zcuts.push_back(vertex_layers[layer_index]);
153 vol_mesher.options.zcuts.push_back(vertex_layers[layer_index]);
155 if (
Chi::log.GetVerbosity() == chi::ChiLog::LOG_LVL::LOG_0VERBOSE_2)
157 printf(
"Z-Cut %lu, %g\n",vol_mesher.options.zcuts.size(),
158 vertex_layers[layer_index]);
166 double zmin = -1.0e-16;
167 for (
int k=0; k<(vol_mesher.options.zcuts.size()); k++)
169 double zmax = vol_mesher.options.zcuts[k];
175 printf(
"zmax = %g, zmin = %g, cell_z = %g\n",zmax,zmin,z);
179 if ((z > zmin) && (z < zmax))
181 std::get<0>(ijk_id) = ij_id.first;
182 std::get<1>(ijk_id) = ij_id.second;
183 std::get<2>(ijk_id) = k;
185 found_partition =
true;
193 if (vol_mesher.options.zcuts.empty())
195 throw std::invalid_argument(
"Cell z-partitioning cannot be determined "
196 "because no z-cuts are supplied to volume "
201 std::vector<double> temp_zcuts = vol_mesher.options.zcuts;
202 double zmin = -1.0e16;
203 double zmax = 1.0e16;
204 temp_zcuts.push_back(zmax);
205 for (
int k=0; k<(temp_zcuts.size()); k++)
207 zmax = temp_zcuts[k];
213 printf(
"zmax = %g, zmin = %g, cell_z = %g\n",zmax,zmin,z);
217 if ((z > zmin) && (z < zmax))
219 std::get<0>(ijk_id) = ij_id.first;
220 std::get<1>(ijk_id) = ij_id.second;
221 std::get<2>(ijk_id) = k;
223 found_partition =
true;
231 if (!found_partition)
234 <<
"A cell was encountered for which "
235 "no zpartition id was found";
static void Exit(int error_code)
static chi::MPI_Info & mpi
@ LOG_0VERBOSE_2
Used only if verbosity level equals 2.
const std::vector< double > & GetVertexLayers() const
static std::tuple< int, int, int > GetCellXYZPartitionID(chi_mesh::Cell *cell)
static std::pair< int, int > GetCellXYPartitionID(chi_mesh::Cell *cell)
MeshHandler & GetCurrentHandler()