| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Pamgen Package |
| 4 |
// |
| 5 |
// Copyright 2004 NTESS and the Pamgen contributors. |
| 6 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#include <cstring> |
| 11 |
#include "pamgen_im_ne_nemesisI_l.h" |
| 12 |
#include "pamgen_mesh_specification.h" |
| 13 |
#include <strings.h> |
| 14 |
|
| 15 |
|
| 16 |
/*****************************************************************************/ |
| 17 |
int im_ne_get_init_global_l(int /* neid */, /* NemesisI file ID */ |
| 18 |
long long *num_nodes_g, /* Number of global FEM nodes */ |
| 19 |
long long *num_elems_g, /* Number of global FEM elements */ |
| 20 |
long long *num_elem_blks_g, /* Number of global elem blocks */ |
| 21 |
long long *num_node_sets_g, /* Number of global node sets */ |
| 22 |
long long *num_side_sets_g /* Number of global side sets */ |
| 23 |
) |
| 24 |
/*****************************************************************************/ |
| 25 |
{ |
| 26 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 27 |
if(!ms)return -1; |
| 28 |
*num_nodes_g = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODES_GLOBAL); |
| 29 |
*num_elems_g = ms->getMSI(ms_lt::Mesh_Specification::NUM_ELEMS_GLOBAL); |
| 30 |
*num_elem_blks_g = ms->getMSI(ms_lt::Mesh_Specification::NUM_ELM_BLKS_GLOBAL); |
| 31 |
*num_node_sets_g = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_SETS_GLOBAL); |
| 32 |
*num_side_sets_g = ms->getMSI(ms_lt::Mesh_Specification::NUM_SIDE_SETS_GLOBAL); |
| 33 |
|
| 34 |
return 0; |
| 35 |
} |
| 36 |
|
| 37 |
/*****************************************************************************/ |
| 38 |
int im_ne_get_init_info_l(int /* neid */, /* NemesisI file ID */ |
| 39 |
long long *num_proc, /* Number of processors */ |
| 40 |
long long *num_proc_in_f, /* Number of procs in this file */ |
| 41 |
char *ftype) |
| 42 |
/*****************************************************************************/ |
| 43 |
{ |
| 44 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 45 |
if(!ms)return -1; |
| 46 |
*num_proc = ms->getMSI(ms_lt::Mesh_Specification::NUM_TOTAL_PROC); |
| 47 |
*num_proc_in_f = ms->getMSI(ms_lt::Mesh_Specification::NUM_PROC_IN_FILE); |
| 48 |
const std::string ft = ms->File_Type(); |
| 49 |
strcpy(ftype,ft.c_str()); |
| 50 |
return 0; |
| 51 |
} |
| 52 |
|
| 53 |
/*****************************************************************************/ |
| 54 |
int im_ne_get_eb_info_global_l(int /* neid */, /* NemesisI file ID */ |
| 55 |
long long *el_blk_ids, /* Vector of global element IDs */ |
| 56 |
long long *el_blk_cnts /* Vector of global element counts */ |
| 57 |
) |
| 58 |
/*****************************************************************************/ |
| 59 |
{ |
| 60 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 61 |
if(!ms)return -1; |
| 62 |
long long num_eb = ms->getMSI(ms_lt::Mesh_Specification::NUM_ELM_BLKS_GLOBAL); |
| 63 |
long long * ebids = ms->getMSP(ms_lt::Mesh_Specification::ELEM_BLK_IDS_GLOBAL); |
| 64 |
long long * ebcts = ms->getMSP(ms_lt::Mesh_Specification::ELEM_BLK_CNTS_GLOBAL); |
| 65 |
for(long long i = 0; i < num_eb; i ++){ |
| 66 |
el_blk_ids[i] = ebids[i]; |
| 67 |
el_blk_cnts[i] = ebcts[i]; |
| 68 |
} |
| 69 |
return 0; |
| 70 |
} |
| 71 |
|
| 72 |
/*****************************************************************************/ |
| 73 |
int im_ne_get_loadbal_param_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 74 |
long long *num_int_nodes, /* Number of internal FEM nodes */ |
| 75 |
long long *num_bor_nodes, /* Number of border FEM nodes */ |
| 76 |
long long *num_ext_nodes, /* Number of external FEM nodes */ |
| 77 |
long long *num_int_elems, /* Number of internal FEM elems */ |
| 78 |
long long *num_bor_elems, /* Number of border FEM elems */ |
| 79 |
long long *num_node_cmaps, /* Number of nodal comm maps */ |
| 80 |
long long *num_elem_cmaps, /* Number of elemental comm maps */ |
| 81 |
long long /* processor */ /* Processor ID */ |
| 82 |
) |
| 83 |
/*****************************************************************************/ |
| 84 |
{ |
| 85 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 86 |
if(!ms)return -1; |
| 87 |
|
| 88 |
*num_int_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_INTERNAL_NODES); |
| 89 |
*num_bor_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_BORDER_NODES); |
| 90 |
*num_ext_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_EXTERNAL_NODES); |
| 91 |
*num_int_elems = ms->getMSI(ms_lt::Mesh_Specification::NUM_INTERNAL_ELEMS); |
| 92 |
*num_bor_elems = ms->getMSI(ms_lt::Mesh_Specification::NUM_BORDER_ELEMS); |
| 93 |
*num_node_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_COMM_MAPS); |
| 94 |
*num_elem_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_ELEM_COMM_MAPS); |
| 95 |
|
| 96 |
|
| 97 |
return 0; |
| 98 |
} |
| 99 |
|
| 100 |
/*****************************************************************************/ |
| 101 |
int im_ne_get_elem_map_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 102 |
long long *elem_mapi, /* Internal element IDs */ |
| 103 |
long long *elem_mapb, /* Border element IDs */ |
| 104 |
long long /* processor */ /* Processor ID */ |
| 105 |
) |
| 106 |
/*****************************************************************************/ |
| 107 |
{ |
| 108 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 109 |
if(!ms)return -1; |
| 110 |
|
| 111 |
long long int_elems = ms->getMSI(ms_lt::Mesh_Specification::NUM_INTERNAL_ELEMS); |
| 112 |
long long bor_elems = ms->getMSI(ms_lt::Mesh_Specification::NUM_BORDER_ELEMS); |
| 113 |
|
| 114 |
long long * int_el_arr = ms->getMSP(ms_lt::Mesh_Specification::INTERNAL_ELEMENTS); |
| 115 |
long long * bor_el_arr = ms->getMSP(ms_lt::Mesh_Specification::BORDER_ELEMENTS); |
| 116 |
|
| 117 |
for(long long i = 0; i < int_elems; i ++)elem_mapi[i] = int_el_arr[i]; |
| 118 |
for(long long i = 0; i < bor_elems; i ++)elem_mapb[i] = bor_el_arr[i]; |
| 119 |
|
| 120 |
return 0; |
| 121 |
} |
| 122 |
|
| 123 |
/*****************************************************************************/ |
| 124 |
int im_ne_get_node_map_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 125 |
long long *node_mapi, /* Internal FEM node IDs */ |
| 126 |
long long *node_mapb, /* Border FEM node IDs */ |
| 127 |
long long *node_mape, /* External FEM node IDs */ |
| 128 |
long long /* processor */ /* Processor IDs */ |
| 129 |
) |
| 130 |
/*****************************************************************************/ |
| 131 |
{ |
| 132 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 133 |
if(!ms)return -1; |
| 134 |
|
| 135 |
long long int_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_INTERNAL_NODES); |
| 136 |
long long bor_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_BORDER_NODES); |
| 137 |
long long ext_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_EXTERNAL_NODES); |
| 138 |
|
| 139 |
long long * int_nd_arr = ms->getMSP(ms_lt::Mesh_Specification::INTERNAL_NODES); |
| 140 |
long long * bor_nd_arr = ms->getMSP(ms_lt::Mesh_Specification::BORDER_NODES); |
| 141 |
long long * ext_nd_arr = ms->getMSP(ms_lt::Mesh_Specification::EXTERNAL_NODES); |
| 142 |
|
| 143 |
for(long long i = 0; i < int_nodes; i ++)node_mapi[i] = int_nd_arr[i]; |
| 144 |
for(long long i = 0; i < bor_nodes; i ++)node_mapb[i] = bor_nd_arr[i]; |
| 145 |
for(long long i = 0; i < ext_nodes; i ++)node_mape[i] = ext_nd_arr[i]; |
| 146 |
|
| 147 |
return 0; |
| 148 |
} |
| 149 |
|
| 150 |
/*****************************************************************************/ |
| 151 |
int im_ne_get_cmap_params_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 152 |
long long *node_cmap_ids, /* Nodal comm. map IDs */ |
| 153 |
long long *node_cmap_node_cnts, /* Number of nodes in each map */ |
| 154 |
long long *elem_cmap_ids, /* Elemental comm. map IDs */ |
| 155 |
long long *elem_cmap_elem_cnts, /* Number of elems in each map */ |
| 156 |
long long /* processor */ /* This processor ID */ |
| 157 |
) |
| 158 |
/*****************************************************************************/ |
| 159 |
{ |
| 160 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 161 |
if(!ms)return -1; |
| 162 |
|
| 163 |
long long num_node_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_COMM_MAPS); |
| 164 |
long long num_elem_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_ELEM_COMM_MAPS); |
| 165 |
|
| 166 |
long long * nd_cmap_id_arr = ms->getMSP(ms_lt::Mesh_Specification::NODE_CMAP_IDS); |
| 167 |
const long long * nd_cmap_ct_arr = ms->getMSP(ms_lt::Mesh_Specification::NODE_CMAP_NODE_CNTS); |
| 168 |
long long * el_cmap_id_arr = ms->getMSP(ms_lt::Mesh_Specification::ELEM_CMAP_IDS); |
| 169 |
const long long * el_cmap_ct_arr = ms->getMSP(ms_lt::Mesh_Specification::ELEM_CMAP_ELEM_CNTS); |
| 170 |
|
| 171 |
for(long long i = 0; i < num_node_cmaps; i ++){ |
| 172 |
node_cmap_ids[i] = nd_cmap_id_arr[i]; |
| 173 |
node_cmap_node_cnts[i] = nd_cmap_ct_arr[i]; |
| 174 |
} |
| 175 |
|
| 176 |
for(long long i = 0; i < num_elem_cmaps; i ++){ |
| 177 |
elem_cmap_ids[i] = el_cmap_id_arr[i]; |
| 178 |
elem_cmap_elem_cnts[i] = el_cmap_ct_arr[i]; |
| 179 |
} |
| 180 |
|
| 181 |
return 0; |
| 182 |
} |
| 183 |
|
| 184 |
/*****************************************************************************/ |
| 185 |
int im_ne_get_node_cmap_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 186 |
long long map_id, /* Map ID */ |
| 187 |
long long *node_ids, /* FEM node IDs */ |
| 188 |
long long *proc_ids, /* Processor IDs */ |
| 189 |
long long /* processor */ /* This processor ID */ |
| 190 |
) |
| 191 |
/*****************************************************************************/ |
| 192 |
{ |
| 193 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 194 |
if(!ms)return -1; |
| 195 |
|
| 196 |
long long map_index = -1; |
| 197 |
// get the map index |
| 198 |
long long num_node_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_COMM_MAPS); |
| 199 |
long long * nd_cmap_id_arr = ms->getMSP(ms_lt::Mesh_Specification::NODE_CMAP_IDS); |
| 200 |
for(long long i = 0; i < num_node_cmaps; i ++)if(map_id == nd_cmap_id_arr[i])map_index = i; |
| 201 |
if(map_index == -1)return -1; |
| 202 |
|
| 203 |
|
| 204 |
const long long * nd_cmap_ct_arr = ms->getMSP(ms_lt::Mesh_Specification::NODE_CMAP_NODE_CNTS); |
| 205 |
long long num_comm_nodes = nd_cmap_ct_arr[map_index]; |
| 206 |
|
| 207 |
long long * const * nd_id_arr = ms->getMSPP(ms_lt::Mesh_Specification::COMM_NODE_IDS);//Comm_Node_Ids(); |
| 208 |
long long * const * nd_proc_arr = ms->getMSPP(ms_lt::Mesh_Specification::COMM_NODE_PROC_IDS);//Comm_Node_Proc_Ids(); |
| 209 |
|
| 210 |
for(long long i = 0; i < num_comm_nodes; i ++){ |
| 211 |
node_ids[i] = nd_id_arr[map_index][i]; |
| 212 |
proc_ids[i] = nd_proc_arr[map_index][i]; |
| 213 |
} |
| 214 |
|
| 215 |
return 0; |
| 216 |
} |
| 217 |
|
| 218 |
/*****************************************************************************/ |
| 219 |
int im_ne_get_elem_cmap_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 220 |
long long map_id, /* Elemental comm map ID */ |
| 221 |
long long *elem_ids, /* Element IDs */ |
| 222 |
long long *side_ids, /* Element side IDs */ |
| 223 |
long long *proc_ids, /* Processor IDs */ |
| 224 |
long long /* processor */ /* This processor ID */ |
| 225 |
) |
| 226 |
/*****************************************************************************/ |
| 227 |
{ |
| 228 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 229 |
if(!ms)return -1; |
| 230 |
|
| 231 |
long long map_index = -1; |
| 232 |
// get the map index |
| 233 |
long long num_elem_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_ELEM_COMM_MAPS); |
| 234 |
long long * elem_cmap_id_arr = ms->getMSP(ms_lt::Mesh_Specification::ELEM_CMAP_IDS); |
| 235 |
for(long long i = 0; i < num_elem_cmaps; i ++)if(map_id == elem_cmap_id_arr[i])map_index = i; |
| 236 |
if(map_index == -1)return -1; |
| 237 |
|
| 238 |
|
| 239 |
const long long * el_cmap_ct_arr = ms->getMSP(ms_lt::Mesh_Specification::ELEM_CMAP_ELEM_CNTS); |
| 240 |
long long num_comm_elements = el_cmap_ct_arr[map_index]; |
| 241 |
|
| 242 |
long long * const * el_id_arr = ms->getMSPP(ms_lt::Mesh_Specification::COMM_ELEM_IDS); |
| 243 |
long long * const * el_side_arr = ms->getMSPP(ms_lt::Mesh_Specification::COMM_SIDE_IDS); |
| 244 |
long long * const * el_proc_arr = ms->getMSPP(ms_lt::Mesh_Specification::COMM_ELEM_PROC_IDS); |
| 245 |
|
| 246 |
for(long long i = 0; i < num_comm_elements; i ++){ |
| 247 |
elem_ids[i] = el_id_arr[map_index][i]; |
| 248 |
side_ids[i] = el_side_arr[map_index][i]; |
| 249 |
proc_ids[i] = el_proc_arr[map_index][i]; |
| 250 |
} |
| 251 |
|
| 252 |
return 0; |
| 253 |
} |
| 254 |
|
| 255 |
/*****************************************************************************/ |
| 256 |
int im_ne_get_ns_param_global_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 257 |
long long *ns_ids_glob, /* Global IDs of node sets */ |
| 258 |
long long *ns_n_cnt_glob, /* Count of nodes in node sets */ |
| 259 |
long long *ns_df_cnt_glob /* Count of dist. factors in ns */ |
| 260 |
) |
| 261 |
/*****************************************************************************/ |
| 262 |
{ |
| 263 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 264 |
if(!ms)return -1; |
| 265 |
|
| 266 |
long long nns = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_SETS_GLOBAL); |
| 267 |
|
| 268 |
const long long * nsids = ms->getMSP(ms_lt::Mesh_Specification::NS_IDS_GLOBAL); |
| 269 |
const long long * ncts = ms->getMSP(ms_lt::Mesh_Specification::NS_CNTS_GLOBAL); |
| 270 |
const long long * dfs = ms->getMSP(ms_lt::Mesh_Specification::NS_DF_CNTS_GLOBAL); |
| 271 |
for(long long i = 0; i < nns; i ++){ |
| 272 |
ns_ids_glob[i] = nsids[i]; |
| 273 |
ns_n_cnt_glob[i] = ncts[i]; |
| 274 |
ns_df_cnt_glob[i] = dfs[i]; |
| 275 |
} |
| 276 |
return 0; |
| 277 |
} |
| 278 |
|
| 279 |
/*****************************************************************************/ |
| 280 |
int im_ne_get_ss_param_global_l(int /* neid */, /* NetCDF/Exodus file ID */ |
| 281 |
long long *ss_ids_glob, /* Global side-set IDs */ |
| 282 |
long long *ss_s_cnt_glob, /* Global side count */ |
| 283 |
long long *ss_df_cnt_glob /* Global dist. factor count */ |
| 284 |
) |
| 285 |
/*****************************************************************************/ |
| 286 |
{ |
| 287 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 288 |
if(!ms)return -1; |
| 289 |
|
| 290 |
int nss = ms->getMSI(ms_lt::Mesh_Specification::NUM_SIDE_SETS_GLOBAL); |
| 291 |
|
| 292 |
const long long * nsids = ms->getMSP(ms_lt::Mesh_Specification::SS_IDS_GLOBAL); |
| 293 |
const long long * ncts = ms->getMSP(ms_lt::Mesh_Specification::SS_CNTS_GLOBAL); |
| 294 |
const long long * dfs = ms->getMSP(ms_lt::Mesh_Specification::SS_DF_CNTS_GLOBAL); |
| 295 |
for(long long i = 0; i < nss; i ++){ |
| 296 |
ss_ids_glob[i] = nsids[i]; |
| 297 |
ss_s_cnt_glob[i] = ncts[i]; |
| 298 |
ss_df_cnt_glob[i] = dfs[i]; |
| 299 |
} |
| 300 |
return 0; |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
/*****************************************************************************/ |
| 306 |
int im_ne_get_global_ijk_l(int /* neid */, |
| 307 |
long long *global_ijk) |
| 308 |
/*****************************************************************************/ |
| 309 |
{ |
| 310 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 311 |
if(!ms)return -1; |
| 312 |
|
| 313 |
ms->Get_Global_IJK(global_ijk); |
| 314 |
|
| 315 |
//IJK |
| 316 |
return 0; |
| 317 |
} |
| 318 |
|
| 319 |
/*****************************************************************************/ |
| 320 |
int im_ne_get_num_ijk_l(int /* neid */, |
| 321 |
long long *num_ijk) |
| 322 |
/*****************************************************************************/ |
| 323 |
{ |
| 324 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 325 |
if(!ms)return -1; |
| 326 |
|
| 327 |
ms->Get_Total_Num_IJK(num_ijk); |
| 328 |
|
| 329 |
//IJK |
| 330 |
return 0; |
| 331 |
} |
| 332 |
|
| 333 |
/*****************************************************************************/ |
| 334 |
int im_ne_get_local_num_ijk_l(int /* neid */, |
| 335 |
long long *local_num_ijk) |
| 336 |
/*****************************************************************************/ |
| 337 |
{ |
| 338 |
ms_lt::Mesh_Specification * ms = ms_lt::Mesh_Specification::first_ms_static_storage; |
| 339 |
if(!ms)return -1; |
| 340 |
|
| 341 |
ms->Get_Local_Num_IJK(local_num_ijk); |
| 342 |
|
| 343 |
//IJK |
| 344 |
return 0; |
| 345 |
} |
| 346 |
|