17 const size_t num_raw_cells = raw_cells.size();
22 typedef std::vector<uint64_t> CellGraphNode;
23 typedef std::vector<CellGraphNode> CellGraph;
25 std::vector<chi_mesh::Vector3> cell_centroids;
27 cell_graph.reserve(num_raw_cells);
28 cell_centroids.reserve(num_raw_cells);
30 for (
const auto& raw_cell_ptr : raw_cells)
32 CellGraphNode cell_graph_node;
33 for (
auto& face : raw_cell_ptr->faces)
34 if (face.has_neighbor) cell_graph_node.push_back(face.neighbor);
36 cell_graph.push_back(cell_graph_node);
37 cell_centroids.push_back(raw_cell_ptr->centroid);
45 std::vector<int64_t> cell_pids =
48 std::vector<size_t> partI_num_cells(num_partitions, 0);
49 for (int64_t pid : cell_pids)
50 partI_num_cells[pid] += 1;
52 size_t max_num_cells = partI_num_cells.front();
53 size_t min_num_cells = partI_num_cells.front();
54 size_t avg_num_cells = 0;
55 for (
size_t count : partI_num_cells)
57 max_num_cells = std::max(max_num_cells, count);
58 min_num_cells = std::min(min_num_cells, count);
59 avg_num_cells += count;
61 avg_num_cells /= num_partitions;
63 Chi::log.
Log() <<
"Partitioner num_cells allocated max,min,avg = "
64 << max_num_cells <<
"," << min_num_cells <<
"," << avg_num_cells;
70std::shared_ptr<MeshContinuum>
72 const std::vector<int64_t>& cell_pids)
77 grid_ptr->GetBoundaryIDMap() =
78 input_umesh_ptr->GetMeshOptions().boundary_id_map;
80 auto& vertex_subs = input_umesh_ptr->GetVertextCellSubscriptions();
81 size_t cell_globl_id = 0;
82 for (
auto& raw_cell : input_umesh_ptr->GetRawCells())
93 cell_pids[cell_globl_id],
96 for (uint64_t vid : cell->vertex_ids_)
97 grid_ptr->vertices.Insert(vid, input_umesh_ptr->GetVertices()[vid]);
99 grid_ptr->cells.push_back(std::move(cell));
109 input_umesh_ptr->GetMeshAttributes(),
110 {input_umesh_ptr->GetMeshOptions().ortho_Nx,
111 input_umesh_ptr->GetMeshOptions().ortho_Ny,
112 input_umesh_ptr->GetMeshOptions().ortho_Nz});
114 grid_ptr->SetGlobalVertexCount(input_umesh_ptr->GetVertices().size());
#define ChiLogicalErrorIf(condition, message)
static chi::MPI_Info & mpi
LogStream Log(LOG_LVL level=LOG_0)
virtual std::vector< int64_t > Partition(const std::vector< std::vector< uint64_t > > &graph, const std::vector< chi_mesh::Vector3 > ¢roids, int number_of_parts)=0
static std::shared_ptr< MeshContinuum > New()
bool CellHasLocalScope(int location_id, const chi_mesh::UnpartitionedMesh::LightWeightCell &lwcell, uint64_t cell_global_id, const std::vector< std::set< uint64_t > > &vertex_subscriptions, const std::vector< int64_t > &cell_partition_ids) const
std::shared_ptr< MeshContinuum > SetupMesh(std::unique_ptr< UnpartitionedMesh > input_umesh_ptr, const std::vector< int64_t > &cell_pids)
chi::GraphPartitioner * partitioner_
static void ComputeAndPrintStats(const chi_mesh::MeshContinuum &grid)
static void SetGridAttributes(chi_mesh::MeshContinuum &grid, MeshAttributes new_attribs, std::array< size_t, 3 > ortho_cells_per_dimension)
static std::unique_ptr< chi_mesh::Cell > SetupCell(const UnpartitionedMesh::LightWeightCell &raw_cell, uint64_t global_id, uint64_t partition_id, const VertexListHelper &vertices)
std::vector< int64_t > PartitionMesh(const UnpartitionedMesh &input_umesh, int num_partitions)
std::vector< LightWeightCell * > & GetRawCells()