| 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.h" |
| 12 |
#include "pamgen_mesh_specification.h" |
| 13 |
#include <strings.h> |
| 14 |
|
| 15 |
|
| 16 |
/*****************************************************************************/ |
| 17 |
int im_ne_get_init_global(int /* neid */, /* NemesisI file ID */ |
| 18 |
int *num_nodes_g, /* Number of global FEM nodes */ |
| 19 |
int *num_elems_g, /* Number of global FEM elements */ |
| 20 |
int *num_elem_blks_g, /* Number of global elem blocks */ |
| 21 |
int *num_node_sets_g, /* Number of global node sets */ |
| 22 |
int *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(int /* neid */, /* NemesisI file ID */ |
| 39 |
int *num_proc, /* Number of processors */ |
| 40 |
int *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(int /* neid */, /* NemesisI file ID */ |
| 55 |
int *el_blk_ids, /* Vector of global element IDs */ |
| 56 |
int *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 |
int 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(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 74 |
int *num_int_nodes, /* Number of internal FEM nodes */ |
| 75 |
int *num_bor_nodes, /* Number of border FEM nodes */ |
| 76 |
int *num_ext_nodes, /* Number of external FEM nodes */ |
| 77 |
int *num_int_elems, /* Number of internal FEM elems */ |
| 78 |
int *num_bor_elems, /* Number of border FEM elems */ |
| 79 |
int *num_node_cmaps, /* Number of nodal comm maps */ |
| 80 |
int *num_elem_cmaps, /* Number of elemental comm maps */ |
| 81 |
int /* 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 102 |
int *elem_mapi, /* Internal element IDs */ |
| 103 |
int *elem_mapb, /* Border element IDs */ |
| 104 |
int /* 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 |
int int_elems = ms->getMSI(ms_lt::Mesh_Specification::NUM_INTERNAL_ELEMS); |
| 112 |
int 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(int i = 0; i < int_elems; i ++)elem_mapi[i] = int_el_arr[i]; |
| 118 |
for(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 125 |
int *node_mapi, /* Internal FEM node IDs */ |
| 126 |
int *node_mapb, /* Border FEM node IDs */ |
| 127 |
int *node_mape, /* External FEM node IDs */ |
| 128 |
int /* 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 |
int int_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_INTERNAL_NODES); |
| 136 |
int bor_nodes = ms->getMSI(ms_lt::Mesh_Specification::NUM_BORDER_NODES); |
| 137 |
int 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(int i = 0; i < int_nodes; i ++)node_mapi[i] = int_nd_arr[i]; |
| 144 |
for(int i = 0; i < bor_nodes; i ++)node_mapb[i] = bor_nd_arr[i]; |
| 145 |
for(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 152 |
int *node_cmap_ids, /* Nodal comm. map IDs */ |
| 153 |
int *node_cmap_node_cnts, /* Number of nodes in each map */ |
| 154 |
int *elem_cmap_ids, /* Elemental comm. map IDs */ |
| 155 |
int *elem_cmap_elem_cnts, /* Number of elems in each map */ |
| 156 |
int /* 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 |
int num_node_cmaps = ms->getMSI(ms_lt::Mesh_Specification::NUM_NODE_COMM_MAPS); |
| 164 |
int 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(int 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(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 186 |
int map_id, /* Map ID */ |
| 187 |
int *node_ids, /* FEM node IDs */ |
| 188 |
int *proc_ids, /* Processor IDs */ |
| 189 |
int /* 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 |
int map_index = -1; |
| 197 |
// get the map index |
| 198 |
int 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(int 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 |
int 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(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 220 |
int map_id, /* Elemental comm map ID */ |
| 221 |
int *elem_ids, /* Element IDs */ |
| 222 |
int *side_ids, /* Element side IDs */ |
| 223 |
int *proc_ids, /* Processor IDs */ |
| 224 |
int /* 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 |
int map_index = -1; |
| 232 |
// get the map index |
| 233 |
int 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(int 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 |
int 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(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 257 |
int *ns_ids_glob, /* Global IDs of node sets */ |
| 258 |
int *ns_n_cnt_glob, /* Count of nodes in node sets */ |
| 259 |
int *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 |
int 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(int 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(int /* neid */, /* NetCDF/Exodus file ID */ |
| 281 |
int *ss_ids_glob, /* Global side-set IDs */ |
| 282 |
int *ss_s_cnt_glob, /* Global side count */ |
| 283 |
int *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(int 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 |
} |