33 #ifndef IOSS_Ioss_Utils_h 34 #define IOSS_Ioss_Utils_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;
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);
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);
254 const std::string &func);
256 static int case_strcmp(
const std::string &s1,
const std::string &s2);
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);
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); }
327 size_t copies,
size_t max_var_len);
static std::string uppercase(std::string name)
Convert a string to upper case.
Definition: Ioss_Utils.C:1236
static int power_2(int count)
Definition: Ioss_Utils.h:174
static size_t get_memory_info()
Return amount of memory being used on this processor.
Definition: Ioss_Utils.C:910
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
static std::string encode_entity_name(const std::string &entity_type, int64_t id)
Definition: Ioss_Utils.C:326
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:1177
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:1264
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:1004
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:1386
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:1118
static int case_strcmp(const std::string &s1, const std::string &s2)
Case-insensitive string comparison.
Definition: Ioss_Utils.C:1217
static std::string lowercase(std::string name)
Convert a string to lower case.
Definition: Ioss_Utils.C:1247
static void abort()
Definition: Ioss_Utils.C:441
static unsigned int hash(const std::string &name)
Definition: Ioss_Utils.C:1136
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 void fixup_name(char *name)
Convert a string to lower case, and convert spaces to '_'.
Definition: Ioss_Utils.C:1299
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:759
static T find_index_location(T node, const std::vector< T > &index)
Definition: Ioss_Utils.h:134
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:370
static std::string platform_information()
Get a string containing 'uname' output.
Definition: Ioss_Utils.C:885
static size_t get_number(const std::string &suffix)
Definition: Ioss_Utils.C:303
static void check_non_null(void *ptr, const char *type, const std::string &name, const std::string &func)
Definition: Ioss_Utils.C:259
static void delete_name_array(char **names, int count)
Definition: Ioss_Utils.C:349
const size_t max_line_length
Definition: Iofx_DatabaseIO.C:96
static void copy_database(Ioss::Region ®ion, Ioss::Region &output_region, Ioss::MeshCopyOptions &options)
Definition: Ioss_Utils.C:1548
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:1013
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:457
std::string name(Ioss::GroupingEntity *entity)
Definition: io_info.C:88
static double timer()
Definition: Ioss_Utils.C:1155
static bool check_block_order(const std::vector< T *> &blocks)
Definition: Ioss_Utils.h:189
static int64_t extract_id(const std::string &name_id)
Definition: Ioss_Utils.C:313
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:469
static void uniquify(std::vector< T > &vec, bool skip_first=false)
Definition: Ioss_Utils.h:112
static void generate_history_mesh(Ioss::Region *region)
Create a nominal mesh for use in history databases.
Definition: Ioss_Utils.C:1497
static char ** get_name_array(size_t count, int size)
Definition: Ioss_Utils.C:339
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:965
static std::string decode_filename(const std::string &filename, int processor, int num_processors)
Definition: Ioss_Utils.C:270
static void generate_index(std::vector< T > &index)
Definition: Ioss_Utils.h:123
static int log_power_2(uint64_t value)
Definition: Ioss_Utils.C:1535
static void clear(std::vector< T > &vec)
Definition: Ioss_Utils.h:167