Go to the documentation of this file.
33 #ifndef IOSS_Ioss_Utils_h
34 #define IOSS_Ioss_Utils_h
55 class PropertyManager;
56 struct MeshCopyOptions;
59 #if __cplusplus > 199711L
60 #define TOPTR(x) x.data()
62 #define TOPTR(x) (x.empty() ? nullptr : &x[0])
65 #define IOSS_ERROR(errmsg) throw std::runtime_error(errmsg.str())
66 #define IOSS_WARNING std::cerr
70 template <
typename T>
size_t unique(std::vector<T> &out,
bool skip_first)
82 for (; i < out.size(); ++i) {
85 pos += (newv != oldv);
104 if (ptr ==
nullptr) {
105 std::cerr <<
"INTERNAL ERROR: Invalid dynamic cast returned nullptr\n";
110 template <
typename T>
static void uniquify(std::vector<T> &vec,
bool skip_first =
false)
112 auto it = vec.begin();
116 std::sort(it, vec.end());
117 vec.resize(
unique(vec, skip_first));
124 for (
size_t i = 0; i < index.size() - 1; i++) {
140 static size_t prev = 1;
142 size_t nproc = index.size();
143 if (prev < nproc && index[prev - 1] <= node && index[prev] > node) {
147 for (
size_t p = 1; p < nproc; p++) {
148 if (index[p] > node) {
153 std::cerr <<
"FATAL ERROR: find_index_location. Searching for " << node <<
" in:\n";
154 for (
auto idx : index) {
155 std::cerr << idx <<
", ";
161 return std::distance(index.begin(), std::upper_bound(index.begin(), index.end(), node)) - 1;
165 static void copy_string(
char *dest,
char const *source,
size_t elements);
167 static void copy_string(
char *dest,
const std::string &source,
size_t elements)
172 template <
size_t size>
static void copy_string(
char (&output)[size],
const std::string &source)
177 template <
size_t size>
static void copy_string(
char (&output)[size],
const char *source)
183 template <
typename T>
static void clear(std::vector<T> &vec)
187 assert(vec.capacity() == 0);
201 inline static int number_width(
const size_t number,
bool use_commas =
false)
206 int width = int(std::floor(std::log10(number))) + 1;
208 width += ((width - 1) / 3);
222 while (pow2 < count) {
232 typename std::vector<T *>::const_iterator I;
234 int64_t eb_offset = -1;
235 for (I = blocks.begin(); I != blocks.end(); ++I) {
236 int64_t this_off = (*I)->get_offset();
237 if (this_off < eb_offset) {
244 eb_offset = this_off;
267 static void time_and_date(
char *time_string,
char *date_string,
size_t length);
269 static std::string
decode_filename(
const std::string &filename,
int processor,
271 static size_t get_number(
const std::string &suffix);
272 static int64_t
extract_id(
const std::string &name_id);
284 const std::string & rng_sep =
" to ",
285 const std::string & seq_sep =
", ");
318 const std::string &prop_name,
bool &prop_value);
340 static std::string
fixup_type(
const std::string &base,
int nodes_per_element,
int spatial);
357 const std::string &func);
365 static bool str_equal(
const std::string &s1,
const std::string &s2);
373 static bool substr_equal(
const std::string &prefix,
const std::string &str);
399 static std::string
local_filename(
const std::string &relative_filename,
const std::string &type,
400 const std::string &working_directory);
402 static void get_fields(int64_t entity_count,
char **names,
size_t num_names,
404 char suffix_separator,
int *local_truth,
405 std::vector<Ioss::Field> &fields);
408 const std::string &inout);
411 size_t int_byte_size,
const void *element,
412 const void *sides, int64_t number_sides,
432 static unsigned int hash(
const std::string &
name);
434 static double timer();
446 static void input_file(
const std::string &file_name, std::vector<std::string> *lines,
449 template <
class T>
static std::string
to_string(
const T &t) {
return std::to_string(t); }
470 size_t copies,
size_t max_var_len);
static void copy_string(char(&output)[size], const std::string &source)
Definition: Ioss_Utils.h:172
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
static int field_warning(const Ioss::GroupingEntity *ge, const Ioss::Field &field, const std::string &inout)
Definition: Ioss_Utils.C:471
static unsigned int hash(const std::string &name)
Definition: Ioss_Utils.C:1108
static bool str_equal(const std::string &s1, const std::string &s2)
Case-insensitive string comparison.
Definition: Ioss_Utils.C:1167
static void uniquify(std::vector< T > &vec, bool skip_first=false)
Definition: Ioss_Utils.h:110
static std::string fixup_type(const std::string &base, int nodes_per_element, int spatial)
Process the base element type base which has nodes_per_element nodes and a spatial dimension of spati...
Definition: Ioss_Utils.C:390
static void copy_string(char *dest, char const *source, size_t elements)
Definition: Ioss_Utils.C:1368
static T find_index_location(T node, const std::vector< T > &index)
Definition: Ioss_Utils.h:132
const size_t max_line_length
Definition: Iofx_DatabaseIO.C:96
static size_t get_number(const std::string &suffix)
Definition: Ioss_Utils.C:304
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:51
static int term_width()
Definition: Ioss_Utils.C:1397
static std::string platform_information()
Get a string containing uname output.
Definition: Ioss_Utils.C:875
static size_t get_hwm_memory_info()
Definition: Ioss_Utils.C:955
Definition: Ioss_MeshCopyOptions.h:35
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
static std::string to_string(const T &t)
Definition: Ioss_Utils.h:449
static void clear(std::vector< T > &vec)
Definition: Ioss_Utils.h:183
static int64_t extract_id(const std::string &name_id)
Definition: Ioss_Utils.C:314
entity_type
Definition: Iovs_DatabaseIO.C:81
static int number_width(const size_t number, bool use_commas=false)
Definition: Ioss_Utils.h:201
static std::string encode_entity_name(const std::string &entity_type, int64_t id)
Definition: Ioss_Utils.C:363
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
size_t unique(std::vector< T > &out, bool skip_first)
Definition: Ioss_Utils.h:70
static void get_fields(int64_t entity_count, char **names, size_t num_names, Ioss::Field::RoleType fld_role, bool enable_field_recognition, char suffix_separator, int *local_truth, std::vector< Ioss::Field > &fields)
Definition: Ioss_Utils.C:757
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
static char ** get_name_array(size_t count, int size)
Definition: Ioss_Utils.C:372
static size_t get_memory_info()
Return amount of memory being used on this processor.
Definition: Ioss_Utils.C:891
static void calculate_sideblock_membership(IntVector &face_is_member, const SideBlock *ef_blk, size_t int_byte_size, const void *element, const void *sides, int64_t number_sides, const Region *region)
Definition: Ioss_Utils.C:1001
static std::string local_filename(const std::string &relative_filename, const std::string &type, const std::string &working_directory)
Get a filename relative to the specified working directory (if any) of the current execution.
Definition: Ioss_Utils.C:459
static std::string uppercase(std::string name)
Convert a string to upper case.
Definition: Ioss_Utils.C:1179
static bool check_set_bool_property(const Ioss::PropertyManager &properties, const std::string &prop_name, bool &prop_value)
Check whether property prop_name exists and if so, set prop_value
Definition: Ioss_Utils.C:1191
static void copy_string(char *dest, const std::string &source, size_t elements)
Definition: Ioss_Utils.h:167
static void fixup_name(char *name)
Convert a string to lower case, and convert spaces to _.
Definition: Ioss_Utils.C:1221
static double timer()
Definition: Ioss_Utils.C:1127
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:59
static int power_2(int count)
Definition: Ioss_Utils.h:213
static bool block_is_omitted(Ioss::GroupingEntity *block)
Determine whether an entity has the property omitted.
Definition: Ioss_Utils.C:992
static void check_dynamic_cast(const void *ptr)
Definition: Ioss_Utils.h:102
static void copy_database(Ioss::Region ®ion, Ioss::Region &output_region, Ioss::MeshCopyOptions &options)
Definition: Ioss_Utils.C:1414
static std::string variable_name_kluge(const std::string &name, size_t component_count, size_t copies, size_t max_var_len)
Tries to shorten long variable names to an acceptable length, and converts to lowercase and spaces to...
Definition: Ioss_Utils.C:1271
static std::string decode_filename(const std::string &filename, int processor, int num_processors)
Definition: Ioss_Utils.C:287
static void generate_index(std::vector< T > &index)
Definition: Ioss_Utils.h:121
static void copy_string(char(&output)[size], const char *source)
Definition: Ioss_Utils.h:177
static int log_power_2(uint64_t value)
Definition: Ioss_Utils.C:1384
static void check_non_null(void *ptr, const char *type, const std::string &name, const std::string &func)
Definition: Ioss_Utils.C:275
static void delete_name_array(char **names, int count)
Definition: Ioss_Utils.C:382
static void input_file(const std::string &file_name, std::vector< std::string > *lines, size_t max_line_length=0)
Convert an input file to a vector of strings containing one string for each line of the file.
Definition: Ioss_Utils.C:1133
static std::string format_id_list(const std::vector< size_t > &ids, const std::string &rng_sep=" to ", const std::string &seq_sep=", ")
create a string that describes the list of input ids collapsing ranges if possible.
Definition: Ioss_Utils.C:327
RoleType
Definition: Ioss_Field.h:75
std::string name(const Ioss::GroupingEntity *entity)
Definition: io_info.C:89
static void generate_history_mesh(Ioss::Region *region)
Create a nominal mesh for use in history databases.
Definition: Ioss_Utils.C:1336
static bool substr_equal(const std::string &prefix, const std::string &str)
Case-insensitive substring comparison.
Definition: Ioss_Utils.C:1174
static int64_t get_side_offset(const Ioss::SideBlock *sb)
Get the appropriate index offset for the sides of elements in a SideBlock.
Definition: Ioss_Utils.C:1090
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:93
Definition: Ioss_Utils.h:96
static void time_and_date(char *time_string, char *date_string, size_t length)
Get formatted time and date strings.
Definition: Ioss_Utils.C:259
static bool check_block_order(const std::vector< T * > &blocks)
Definition: Ioss_Utils.h:228
static std::string lowercase(std::string name)
Convert a string to lower case.
Definition: Ioss_Utils.C:1185