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);
107 if (ptr ==
nullptr) {
108 std::cerr <<
"INTERNAL ERROR: Invalid dynamic cast returned nullptr\n";
113 template <
typename T>
static void uniquify(std::vector<T> &vec,
bool skip_first =
false)
115 auto it = vec.begin();
119 std::sort(it, vec.end());
120 vec.resize(
unique(vec, skip_first));
127 for (
size_t i = 0; i < index.size() - 1; i++) {
143 static size_t prev = 1;
145 size_t nproc = index.size();
146 if (prev < nproc && index[prev - 1] <= node && index[prev] > node) {
150 for (
size_t p = 1; p < nproc; p++) {
151 if (index[p] > node) {
156 std::cerr <<
"FATAL ERROR: find_index_location. Searching for " << node <<
" in:\n";
157 for (
auto idx : index) {
158 std::cerr << idx <<
", ";
164 return std::distance(index.begin(), std::upper_bound(index.begin(), index.end(), node)) - 1;
168 static void copy_string(
char *dest,
char const *source,
size_t elements);
170 static void copy_string(
char *dest,
const std::string &source,
size_t elements)
175 template <
size_t size>
static void copy_string(
char (&output)[size],
const std::string &source)
180 template <
size_t size>
static void copy_string(
char (&output)[size],
const char *source)
186 template <
typename T>
static void clear(std::vector<T> &vec)
190 assert(vec.capacity() == 0);
202 inline static int number_width(
const size_t number,
bool use_commas =
false)
207 int width = std::floor(std::log10(number)) + 1;
209 width += (width / 3);
223 while (pow2 < count) {
233 typename std::vector<T *>::const_iterator I;
235 int64_t eb_offset = -1;
236 for (I = blocks.begin(); I != blocks.end(); ++I) {
237 int64_t this_off = (*I)->get_offset();
238 if (this_off < eb_offset) {
245 eb_offset = this_off;
259 static void time_and_date(
char *time_string,
char *date_string,
size_t length);
261 static std::string
decode_filename(
const std::string &filename,
int processor,
263 static size_t get_number(
const std::string &suffix);
264 static int64_t
extract_id(
const std::string &name_id);
277 const std::string &prop_name,
bool &prop_value);
288 static std::string
fixup_type(
const std::string &base,
int nodes_per_element,
int spatial);
294 const std::string &func);
296 static int case_strcmp(
const std::string &s1,
const std::string &s2);
310 static std::string
local_filename(
const std::string &relative_filename,
const std::string &type,
311 const std::string &working_directory);
313 static void get_fields(int64_t entity_count,
char **names,
size_t num_names,
315 char suffix_separator,
int *local_truth,
316 std::vector<Ioss::Field> &fields);
319 const std::string &inout);
322 size_t int_byte_size,
const void *element,
323 const void *sides, int64_t number_sides,
338 static unsigned int hash(
const std::string &
name);
340 static double timer();
345 static void input_file(
const std::string &file_name, std::vector<std::string> *lines,
348 template <
class T>
static std::string
to_string(
const T &t) {
return std::to_string(t); }
365 size_t copies,
size_t max_var_len);
static int number_width(const size_t number, bool use_commas=false)
Definition: Ioss_Utils.h:202
static std::string uppercase(std::string name)
Convert a string to upper case.
Definition: Ioss_Utils.C:1198
static int power_2(int count)
Definition: Ioss_Utils.h:214
static size_t get_memory_info()
Return amount of memory being used on this processor.
Definition: Ioss_Utils.C:873
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
static void check_dynamic_cast(const void *ptr)
Definition: Ioss_Utils.h:105
Definition: Ioss_Utils.h:96
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
static std::string encode_entity_name(const std::string &entity_type, int64_t id)
Definition: Ioss_Utils.C:309
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:1139
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:1226
static void copy_string(char(&output)[size], const char *source)
Definition: Ioss_Utils.h:180
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:43
static bool block_is_omitted(Ioss::GroupingEntity *block)
Determine whether an entity has the property "omitted.".
Definition: Ioss_Utils.C:967
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:1350
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:1080
static int case_strcmp(const std::string &s1, const std::string &s2)
Case-insensitive string comparison.
Definition: Ioss_Utils.C:1179
static std::string lowercase(std::string name)
Convert a string to lower case.
Definition: Ioss_Utils.C:1209
static unsigned int hash(const std::string &name)
Definition: Ioss_Utils.C:1098
static void copy_string(char *dest, const std::string &source, size_t elements)
Definition: Ioss_Utils.h:170
size_t unique(std::vector< T > &out, bool skip_first)
Definition: Ioss_Utils.h:70
static std::string to_string(const T &t)
Definition: Ioss_Utils.h:348
static void fixup_name(char *name)
Convert a string to lower case, and convert spaces to '_'.
Definition: Ioss_Utils.C:1263
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:730
static T find_index_location(T node, const std::vector< T > &index)
Definition: Ioss_Utils.h:135
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 '...
Definition: Ioss_Utils.C:349
static bool check_block_order(const std::vector< T * > &blocks)
Definition: Ioss_Utils.h:229
static std::string platform_information()
Get a string containing 'uname' output.
Definition: Ioss_Utils.C:856
static size_t get_number(const std::string &suffix)
Definition: Ioss_Utils.C:286
static void check_non_null(void *ptr, const char *type, const std::string &name, const std::string &func)
Definition: Ioss_Utils.C:257
static void delete_name_array(char **names, int count)
Definition: Ioss_Utils.C:328
static void copy_string(char *dest, char const *source, size_t elements)
Definition: Ioss_Utils.C:1493
const size_t max_line_length
Definition: Iofx_DatabaseIO.C:97
static void copy_database(Ioss::Region ®ion, Ioss::Region &output_region, Ioss::MeshCopyOptions &options)
Definition: Ioss_Utils.C:1522
static void time_and_date(char *time_string, char *date_string, size_t length)
Get formatted time and date strings.
Definition: Ioss_Utils.C:241
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
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:976
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:428
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:87
static double timer()
Definition: Ioss_Utils.C:1117
static int64_t extract_id(const std::string &name_id)
Definition: Ioss_Utils.C:296
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:440
static void uniquify(std::vector< T > &vec, bool skip_first=false)
Definition: Ioss_Utils.h:113
static void generate_history_mesh(Ioss::Region *region)
Create a nominal mesh for use in history databases.
Definition: Ioss_Utils.C:1461
static char ** get_name_array(size_t count, int size)
Definition: Ioss_Utils.C:318
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
entity_type
Definition: Iovs_DatabaseIO.C:81
static size_t get_hwm_memory_info()
Definition: Ioss_Utils.C:928
static void copy_string(char(&output)[size], const std::string &source)
Definition: Ioss_Utils.h:175
static std::string decode_filename(const std::string &filename, int processor, int num_processors)
Definition: Ioss_Utils.C:269
static void generate_index(std::vector< T > &index)
Definition: Ioss_Utils.h:124
static int log_power_2(uint64_t value)
Definition: Ioss_Utils.C:1509
static void clear(std::vector< T > &vec)
Definition: Ioss_Utils.h:186