33 #ifndef IOSS_Ioss_IOUtils_h 34 #define IOSS_Ioss_IOUtils_h 54 class PropertyManager;
55 struct MeshCopyOptions;
58 #if __cplusplus > 199711L 59 #define TOPTR(x) x.data() 61 #define TOPTR(x) (x.empty() ? nullptr : &x[0]) 64 #define IOSS_ERROR(errmsg) throw std::runtime_error(errmsg.str()) 65 #define IOSS_WARNING std::cerr 69 template <
typename T>
size_t unique(std::vector<T> &out,
bool skip_first)
81 for (; i < out.size(); ++i) {
84 pos += (newv != oldv);
106 if (ptr ==
nullptr) {
107 std::cerr <<
"INTERNAL ERROR: Invalid dynamic cast returned nullptr\n";
112 template <
typename T>
static void uniquify(std::vector<T> &vec,
bool skip_first =
false)
114 auto it = vec.begin();
118 std::sort(it, vec.end());
119 vec.resize(
unique(vec, skip_first));
126 for (
size_t i = 0; i < index.size() - 1; i++) {
142 static size_t prev = 1;
144 size_t nproc = index.size();
145 if (prev < nproc && index[prev - 1] <= node && index[prev] > node) {
149 for (
size_t p = 1; p < nproc; p++) {
150 if (index[p] > node) {
155 std::cerr <<
"FATAL ERROR: find_index_location. Searching for " << node <<
" in:\n";
156 for (
auto idx : index) {
157 std::cerr << idx <<
", ";
163 return std::distance(index.begin(), std::upper_bound(index.begin(), index.end(), node)) - 1;
167 template <
typename T>
static void clear(std::vector<T> &vec)
171 assert(vec.capacity() == 0);
183 while (pow2 < count) {
193 typename std::vector<T *>::const_iterator I;
195 int64_t eb_offset = -1;
196 for (I = blocks.begin(); I != blocks.end(); ++I) {
197 int64_t this_off = (*I)->get_offset();
198 if (this_off < eb_offset) {
205 eb_offset = this_off;
211 static int log_power_2(uint64_t value);
213 static char **get_name_array(
size_t count,
int size);
214 static void delete_name_array(
char **names,
int count);
219 static void time_and_date(
char *time_string,
char *date_string,
size_t length);
221 static std::string decode_filename(
const std::string &filename,
int processor,
223 static size_t get_number(
const std::string &suffix);
224 static int64_t
extract_id(
const std::string &name_id);
225 static std::string encode_entity_name(
const std::string &
entity_type, int64_t
id);
228 static void fixup_name(
char *
name);
229 static void fixup_name(std::string &name);
237 const std::string &prop_name,
bool &prop_value);
248 static std::string fixup_type(
const std::string &base,
int nodes_per_element,
int spatial);
250 static std::string
uppercase(std::string name);
251 static std::string lowercase(std::string name);
253 static void check_non_null(
void *ptr,
const char *type,
const std::string &name,
254 const std::string &func);
256 static int case_strcmp(
const std::string &s1,
const std::string &s2);
262 static std::string platform_information();
265 static size_t get_memory_info();
266 static size_t get_hwm_memory_info();
272 static std::string local_filename(
const std::string &relative_filename,
const std::string &type,
273 const std::string &working_directory);
275 static void get_fields(int64_t entity_count,
char **names,
size_t num_names,
277 char suffix_separator,
int *local_truth,
278 std::vector<Ioss::Field> &fields);
281 const std::string &inout);
283 static void calculate_sideblock_membership(
IntVector &face_is_member,
const SideBlock *ef_blk,
284 size_t int_byte_size,
const void *element,
285 const void *sides, int64_t number_sides,
300 static unsigned int hash(
const std::string &name);
302 static double timer();
307 static void input_file(
const std::string &file_name, std::vector<std::string> *lines,
310 template <
class T>
static std::string
to_string(
const T &t) {
return std::to_string(t); }
326 static std::string variable_name_kluge(
const std::string &name,
size_t component_count,
327 size_t copies,
size_t max_var_len);
333 static void generate_history_mesh(
Ioss::Region *region);
static int power_2(int count)
Definition: Ioss_Utils.h:174
int64_t extract_id(const std::string &name_id)
Definition: Ioex_Utils.C:300
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
static void check_dynamic_cast(const void *ptr)
Definition: Ioss_Utils.h:104
Definition: Ioss_Utils.h:95
Base class for all 'grouping' entities. The following derived classes are typical: ...
Definition: Ioss_GroupingEntity.h:93
RoleType
Definition: Ioss_Field.h:75
Definition: Ioss_MeshCopyOptions.h:35
int field_warning(const Ioss::GroupingEntity *ge, const Ioss::Field &field, const std::string &inout)
Definition: Iovs_DatabaseIO.C:973
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:42
size_t unique(std::vector< T > &out, bool skip_first)
Definition: Ioss_Utils.h:69
static std::string to_string(const T &t)
Definition: Ioss_Utils.h:310
static T find_index_location(T node, const std::vector< T > &index)
Definition: Ioss_Utils.h:134
const size_t max_line_length
Definition: Iofx_DatabaseIO.C:96
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:71
static bool check_block_order(const std::vector< T *> &blocks)
Definition: Ioss_Utils.h:189
std::string uppercase(const std::string &my_name)
Definition: Ioss_Region.C:2285
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
static void uniquify(std::vector< T > &vec, bool skip_first=false)
Definition: Ioss_Utils.h:112
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
entity_type
Definition: Iovs_DatabaseIO.C:81
static void generate_index(std::vector< T > &index)
Definition: Ioss_Utils.h:123
static void clear(std::vector< T > &vec)
Definition: Ioss_Utils.h:167