28using Ghosts = std::vector<std::vector<int>>;
39 constexpr int nodes_per_shell = 4;
41 for (
int j = 0; j < nodes_per_shell; ++j)
43 const int node_id = shells[shell_index * nodes_per_shell + j];
44 if (node_id > 0 && node_id <= max_node_id)
48 const int mask_index = (node_id - 1) *
nspmd + process_id;
49 if (mask[mask_index] == 1)
67 if (!shells || !mask || nb_shells < 0 ||
nspmd <= 0 || numnod <= 0)
73 const int max_node_id = numnod;
76 for (
int shell_idx = 0; shell_idx < nb_shells; ++shell_idx)
78 for (
int process_idx = 0; process_idx <
nspmd; ++process_idx)
82 (*ghost_data)[process_idx].push_back(shell_idx + 1);
90 for (
int process_idx = 0; process_idx <
nspmd; ++process_idx)
92 auto &shell_list = (*ghost_data)[process_idx];
93 std::sort(shell_list.begin(), shell_list.end());
94 auto new_end = std::unique(shell_list.begin(), shell_list.end());
95 shell_list.erase(new_end, shell_list.end());
111 auto *ghost_data =
static_cast<Ghosts *
>(c);
112 const int process_idx = pc - 1;
115 if (process_idx < 0 || process_idx >=
static_cast<int>(ghost_data->size()))
121 auto &shell_list = (*ghost_data)[process_idx];
122 *
n =
static_cast<int>(shell_list.size());
124 return *
n == 0 ? nullptr : shell_list.data();
134 auto *ghost_data =
static_cast<Ghosts *
>(c);
135 const int process_idx = pc - 1;
138 if (process_idx < 0 || process_idx >=
static_cast<int>(ghost_data->size()))
143 return static_cast<int>((*ghost_data)[process_idx].size());
153 auto *ghost_data =
static_cast<Ghosts *
>(c);
154 const int process_idx = pc - 1;
157 if (process_idx < 0 || process_idx >=
static_cast<int>(ghost_data->size()))
163 const auto &shell_list = (*ghost_data)[process_idx];
164 std::copy(shell_list.begin(), shell_list.end(), shells);
174 auto *ghost_data =
static_cast<Ghosts *
>(c);
int * cpp_get_shells_list(void *c, int pc, int *n)
int cpp_get_shells_list_size(void *c, int pc)
void cpp_copy_shells_list(void *c, int pc, int *shells, int n)
void cpp_destroy_ghosts(void *c)
Ghosts * cpp_build_ghosts(int *shells, int nb_shells, int *mask, int nspmd, int numnod)
bool is_shell_ghost_on_proc(int shell_index, int process_id, int *shells, int *mask, int nspmd, int max_node_id)
std::vector< std::vector< int > > Ghosts