| 1 |
/* |
| 2 |
* Copyright(C) 1999-2023, 2025 National Technology & Engineering Solutions |
| 3 |
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 4 |
* NTESS, the U.S. Government retains certain rights in this software. |
| 5 |
* |
| 6 |
* See packages/seacas/LICENSE for details |
| 7 |
*/ |
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include <array> |
| 11 |
|
| 12 |
#include "globals.h" |
| 13 |
#include "pe_str_util_const.h" // for strip_string, token_compare, etc |
| 14 |
#include "rf_allo.h" |
| 15 |
#include "rf_io_const.h" |
| 16 |
|
| 17 |
#define UTIL_NAME "nem_spread" |
| 18 |
#define VER_STR "7.05 (2025/02/04)" |
| 19 |
|
| 20 |
extern void check_exodus_error(int, const char *); |
| 21 |
extern double second(); |
| 22 |
|
| 23 |
template <typename T, typename INT> class NemSpread |
| 24 |
{ |
| 25 |
public: |
| 26 |
void load_mesh(); |
| 27 |
int check_inp(); |
| 28 |
void read_coord(int exoid, int max_name_length); |
| 29 |
void read_elem_blk_ids(int mesh_exoid, int max_name_length); |
| 30 |
void read_elem_blk(int exoid); |
| 31 |
void extract_elem_blk(); |
| 32 |
void extract_global_element_ids(const std::vector<INT> &global_ids, size_t Num_Elem, int iproc); |
| 33 |
void extract_global_node_ids(const std::vector<INT> &global_ids, size_t Num_Node, int iproc); |
| 34 |
size_t extract_elem_connect(INT elem_blk[], int icurrent_elem_blk, size_t istart_elem, |
| 35 |
size_t iend_elem, int *local_ielem_blk, int iproc); |
| 36 |
void extract_elem_attr(T *elem_attr, int icurrent_elem_blk, size_t istart_elem, size_t iend_elem, |
| 37 |
int natt_p_elem, int iproc); |
| 38 |
void find_elem_block(std::vector<INT> &proc_elem_blk, int iproc, int proc_for); |
| 39 |
void read_node_set_ids(int mesh_exoid, std::vector<INT> &num_nodes_in_node_set, |
| 40 |
std::vector<INT> &num_df_in_nsets, int max_name_length); |
| 41 |
void read_side_set_ids(int mesh_exoid, std::vector<INT> &num_elem_in_ssets, |
| 42 |
std::vector<INT> &num_df_in_ssets, int max_name_length); |
| 43 |
void read_node_sets(int exoid, std::vector<INT> &num_nodes_in_node_set, |
| 44 |
std::vector<INT> &num_df_in_nsets); |
| 45 |
void read_side_sets(int exoid, std::vector<INT> &num_elem_in_ssets, |
| 46 |
std::vector<INT> &num_df_in_ssets); |
| 47 |
|
| 48 |
void read_nodal_vars(int mesh_exoid); |
| 49 |
|
| 50 |
void load_lb_info(); |
| 51 |
|
| 52 |
int write_var_param(int mesh_exoid, int max_name_length, int num_glob, char **gv_names, |
| 53 |
int num_node, char **nv_names, int num_elem, char **ev_names, int *local_ebtt, |
| 54 |
int num_nset, char **ns_names, int *local_nstt, int num_sset, char **ss_names, |
| 55 |
int *local_sstt); |
| 56 |
|
| 57 |
void write_parExo_data(int mesh_exoid, int max_name_length, int iproc, |
| 58 |
std::vector<INT> &Num_Nodes_In_NS, std::vector<INT> &Num_Elems_In_SS, |
| 59 |
std::vector<INT> &Num_Elems_In_EB); |
| 60 |
|
| 61 |
void write_var_timestep(int exoid, int proc, int time_step, INT *eb_ids_global, |
| 62 |
INT *ss_ids_global, INT *ns_ids_global); |
| 63 |
|
| 64 |
void process_lb_data(INT *Integer_Vector, int indx); |
| 65 |
void read_proc_init(int lb_exoid, std::array<int, 6> &proc_info, std::vector<int> &proc_ids); |
| 66 |
void read_lb_init(int lb_exoid, std::vector<INT> &Int_Space, std::vector<INT> &Int_Node_Num, |
| 67 |
std::vector<INT> &Bor_Node_Num, std::vector<INT> &Ext_Node_Num, |
| 68 |
std::vector<INT> &Int_Elem_Num, std::vector<INT> &Bor_Elem_Num, |
| 69 |
std::vector<INT> &Node_Comm_Num, std::vector<INT> &Elem_Comm_Num, char *Title); |
| 70 |
|
| 71 |
void read_cmap_params(int lb_exoid, std::vector<ELEM_COMM_MAP<INT>> &E_Comm_Map, |
| 72 |
std::vector<NODE_COMM_MAP<INT>> &N_Comm_Map, INT *cmap_max_size); |
| 73 |
|
| 74 |
void create_elem_types(); |
| 75 |
void read_mesh_param(); |
| 76 |
void read_restart_params(); |
| 77 |
void read_restart_data(); |
| 78 |
|
| 79 |
int read_var_param(int exoid, int max_name_length); |
| 80 |
|
| 81 |
int read_vars(int exoid, int index, INT *eb_ids, INT *eb_cnts, INT ***eb_map_ptr, |
| 82 |
INT **eb_cnts_local, INT *ss_ids, INT *ss_cnts, INT *ns_ids, INT *ns_cnts); |
| 83 |
int read_elem_vars(int exoid, int index, INT *eb_ids, INT *eb_cnts, INT ***eb_map_ptr, |
| 84 |
INT **eb_cnts_local); |
| 85 |
int read_elem_vars_1(int exoid, int index, INT *eb_ids, INT *eb_cnts, INT ***eb_map_ptr, |
| 86 |
INT **eb_cnts_local, int iblk, int eb_offset, INT *local_offset); |
| 87 |
int read_sset_vars(int exoid, int index, INT *ss_ids, INT *ss_cnts); |
| 88 |
int read_sset_vars_1(int exoid, int index, INT *ss_ids, INT *ss_cnts, int iset); |
| 89 |
int read_nset_vars(int exoid, int index, INT *ns_ids, INT *ns_cnts); |
| 90 |
int read_nset_vars_1(int exoid, int index, INT *ns_ids, INT *ns_cnts, int iset); |
| 91 |
int read_nodal_vars(int exoid, int index); |
| 92 |
int compare_mesh_param(int exoid); |
| 93 |
|
| 94 |
int int64db{0}; |
| 95 |
int int64api{0}; |
| 96 |
bool force64db{false}; /* Store all ints as 64-bit on output databases. */ |
| 97 |
|
| 98 |
int selected_change_set{0}; |
| 99 |
int io_ws{0}; |
| 100 |
Restart_Description<T> Restart_Info; |
| 101 |
Globals<T, INT> globals; |
| 102 |
|
| 103 |
/*----------------------------------------------------------------------------- |
| 104 |
* |
| 105 |
* variable definitions used for reading and setting up the mesh |
| 106 |
* information on the processors. These variables are only used in |
| 107 |
* the program in the file, el_exoII_io.c. Use of these variables |
| 108 |
* outside this file constitutes an error. |
| 109 |
* |
| 110 |
*----------------------------------------------------------------------------*/ |
| 111 |
|
| 112 |
std::vector<INT> Node_Set_Ids; /* Vector of node set ids * |
| 113 |
* (ptr to vector of length, * |
| 114 |
* Num_Node_Set) */ |
| 115 |
std::vector<INT> Side_Set_Ids; /* Side set ids * |
| 116 |
* (ptr to vector of length, * |
| 117 |
* Num_Side_Set) */ |
| 118 |
std::vector<INT> Num_Elem_In_Blk; /* Number of elements in each element * |
| 119 |
* block (ptr to vector of length, * |
| 120 |
* Num_Elem_Blk) */ |
| 121 |
std::vector<INT> Num_Nodes_Per_Elem; /* Number of nodes per element in each* |
| 122 |
* elem block (ptr to vector of * |
| 123 |
* length, Num_Elem_Blk) */ |
| 124 |
std::vector<INT> Num_Attr_Per_Elem; /* Number of attributes per element in* |
| 125 |
* each block (ptr to vector of * |
| 126 |
* length, Num_Elem_Blk) */ |
| 127 |
std::vector<INT> Elem_Blk_Ids; /* Element block id's of each element * |
| 128 |
* block (ptr to vector of length, * |
| 129 |
* Num_Elem_Blk) */ |
| 130 |
char **Elem_Blk_Types{nullptr}; /* Element block types for each * |
| 131 |
* element block (ptr to vector of * |
| 132 |
* length, Num_Elem_Blk, of vectors of* |
| 133 |
* char of length MAX_STR_LENGTH+1) */ |
| 134 |
char **Elem_Blk_Names{nullptr}; /* Element block names for each * |
| 135 |
* element block (ptr to vector of * |
| 136 |
* length, Num_Elem_Blk, of vectors of* |
| 137 |
* char of length MAX_STR_LENGTH+1) */ |
| 138 |
char **Node_Set_Names{nullptr}; /* Nodeset names for each * |
| 139 |
* nodeset (ptr to vector of * |
| 140 |
* length, Num_Node_Set, of vectors of* |
| 141 |
* char of length MAX_STR_LENGTH+1) */ |
| 142 |
char **Side_Set_Names{nullptr}; /* Sideset names for each * |
| 143 |
* sideset (ptr to vector of * |
| 144 |
* length, Num_Side_Set, of vectors of* |
| 145 |
* char of length MAX_STR_LENGTH+1) */ |
| 146 |
char ***Elem_Blk_Attr_Names{nullptr}; /* Element block attribute names for each |
| 147 |
* attribute in each element block |
| 148 |
* ragged array (size varies for each |
| 149 |
* element block */ |
| 150 |
|
| 151 |
int *GM_Elem_Types{nullptr}; /* This is a list of the element * |
| 152 |
* in the entire global mesh. It is * |
| 153 |
* stored on Processor 0 to * |
| 154 |
* facilitate the reading of the side * |
| 155 |
* set distribution factors. */ |
| 156 |
|
| 157 |
char *Coord_Name[3]{}; /* The name(s) of the coordinate axes. */ |
| 158 |
|
| 159 |
std::array<int, 6> Proc_Info{}; |
| 160 |
std::vector<int> Proc_Ids{}; |
| 161 |
|
| 162 |
NemSpread() { Coord_Name[0] = Coord_Name[1] = Coord_Name[2] = nullptr; } |
| 163 |
|
| 164 |
~NemSpread() { safe_free((void **)&GM_Elem_Types); } |
| 165 |
}; |