22 const std::string fname = __FUNCTION__;
25 std::set<uint64_t> ls_node_ids_set;
27 for (uint64_t node_id : cell.vertex_ids_)
28 ls_node_ids_set.insert(node_id);
37 typedef std::set<uint64_t> PSUBS;
38 std::map<uint64_t, PSUBS> ls_node_ids_psubs;
39 for (
const uint64_t node_id : ls_node_ids_set)
45 for (
const uint64_t ghost_id : ghost_cell_ids)
48 for (
const uint64_t vid : ghost_cell.vertex_ids_)
49 ls_node_ids_psubs[vid].insert(ghost_cell.partition_id_);
55 std::vector<uint64_t> local_node_ids;
56 std::map<uint64_t, std::vector<uint64_t>> nonlocal_node_ids_map;
57 for (
const uint64_t node_id : ls_node_ids_set)
60 for (
const uint64_t pid : ls_node_ids_psubs[node_id])
61 smallest_partition_id = std::min(smallest_partition_id, pid);
63 if (smallest_partition_id ==
Chi::mpi.location_id)
64 local_node_ids.push_back(node_id);
66 nonlocal_node_ids_map[smallest_partition_id].push_back(node_id);
70 const uint64_t local_num_nodes = local_node_ids.size();
72 MPI_Allgather(&local_num_nodes,
82 uint64_t global_num_nodes = 0;
97 for (uint64_t i = 0; i < local_num_nodes; ++i)
103 std::map<uint64_t, std::vector<uint64_t>> query_node_ids =
107 std::map<uint64_t, std::vector<int64_t>> mapped_node_ids;
108 for (
const auto& key_value : query_node_ids)
110 const uint64_t& pid = key_value.first;
111 const auto& node_list = key_value.second;
113 for (
const uint64_t node_id : node_list)
115 throw std::logic_error(
"Error mapping query node.");
119 mapped_node_ids[pid].push_back(mapping);
124 std::map<uint64_t, std::vector<int64_t>> nonlocal_node_ids_map_mapped =
132 for (
const auto& pid_node_ids : nonlocal_node_ids_map)
134 const uint64_t& pid = pid_node_ids.first;
135 const auto& node_list = pid_node_ids.second;
136 const auto& mappings = nonlocal_node_ids_map_mapped.at(pid);
138 if (mappings.size() != node_list.size())
139 throw std::logic_error(
"mappings.size() != node_list.size()");
141 const size_t num_nodes = node_list.size();
142 for (
size_t i = 0; i < num_nodes; ++i)
149 catch (
const std::out_of_range& oor)
151 throw std::out_of_range(fname +
": Processing non-local mapping failed.");
153 catch (
const std::logic_error& lerr)
155 throw std::logic_error(fname +
": Processing non-local mapping failed." +
static chi::MPI_Info & mpi
const MPI_Comm & comm
MPI communicator.
const int & process_count
Total number of processes.
const int & location_id
Current process rank.
std::vector< uint64_t > locJ_block_size_
uint64_t globl_base_block_size_
uint64_t local_base_block_size_
uint64_t local_block_address_
std::vector< uint64_t > locJ_block_address_
const chi_mesh::MeshContinuum & ref_grid_
std::map< uint64_t, int64_t > ghost_node_mapping_
std::map< uint64_t, int64_t > node_mapping_
std::vector< uint64_t > GetGhostGlobalIDs() const
LocalCellHandler local_cells
std::map< K, std::vector< T > > MapAllToAll(const std::map< K, std::vector< T > > &pid_data_pairs, const MPI_Datatype data_mpi_type, const MPI_Comm communicator=Chi::mpi.comm)