Go to the documentation of this file.
7 #ifndef IOSS_Ioss_Utils_h
8 #define IOSS_Ioss_Utils_h
28 class PropertyManager;
29 struct MeshCopyOptions;
32 #define IOSS_ERROR(errmsg) throw std::runtime_error((errmsg).str())
36 template <
typename T>
size_t unique(std::vector<T> &out,
bool skip_first)
48 for (; i < out.size(); ++i) {
51 pos += (newv != oldv);
112 if (ptr ==
nullptr) {
113 std::ostringstream errmsg;
114 errmsg <<
"INTERNAL ERROR: Invalid dynamic cast returned nullptr\n";
119 template <
typename T>
static void uniquify(std::vector<T> &vec,
bool skip_first =
false)
121 auto it = vec.begin();
125 std::sort(it, vec.end());
126 vec.resize(
unique(vec, skip_first));
133 for (
size_t i = 0; i < index.size() - 1; i++) {
149 static size_t prev = 1;
151 size_t nproc = index.size();
152 if (prev < nproc && index[prev - 1] <= node && index[prev] > node) {
156 for (
size_t p = 1; p < nproc; p++) {
157 if (index[p] > node) {
162 std::ostringstream errmsg;
163 errmsg <<
"FATAL ERROR: find_index_location. Searching for " << node <<
" in:\n";
164 for (
auto idx : index) {
165 errmsg << idx <<
", ";
170 return std::distance(index.begin(), std::upper_bound(index.begin(), index.end(), node)) - 1;
174 static void copy_string(
char *dest,
char const *source,
size_t elements);
176 static void copy_string(
char *dest,
const std::string &source,
size_t elements)
181 template <
size_t size>
static void copy_string(
char (&output)[size],
const std::string &source)
186 template <
size_t size>
static void copy_string(
char (&output)[size],
const char *source)
192 template <
typename T>
static void clear(std::vector<T> &vec)
196 assert(vec.capacity() == 0);
210 inline static int number_width(
const size_t number,
bool use_commas =
false)
215 int width = int(std::floor(std::log10(number))) + 1;
217 width += ((width - 1) / 3);
231 while (pow2 < count) {
241 typename std::vector<T *>::const_iterator I;
243 int64_t eb_offset = -1;
244 for (I = blocks.begin(); I != blocks.end(); ++I) {
245 int64_t this_off = (*I)->get_offset();
246 if (this_off < eb_offset) {
253 eb_offset = this_off;
276 static void time_and_date(
char *time_string,
char *date_string,
size_t length);
278 static std::string
decode_filename(
const std::string &filename,
int processor,
280 static size_t get_number(
const std::string &suffix);
281 static int64_t
extract_id(
const std::string &name_id);
293 const std::string & rng_sep =
" to ",
294 const std::string & seq_sep =
", ");
327 const std::string &prop_name,
bool &prop_value);
349 static std::string
fixup_type(
const std::string &base,
int nodes_per_element,
int spatial);
366 const std::string &func);
374 static bool str_equal(
const std::string &s1,
const std::string &s2);
382 static bool substr_equal(
const std::string &prefix,
const std::string &str);
408 static std::string
local_filename(
const std::string &relative_filename,
const std::string &type,
409 const std::string &working_directory);
411 static void get_fields(int64_t entity_count,
char **names,
size_t num_names,
413 char suffix_separator,
int *local_truth,
414 std::vector<Ioss::Field> &fields);
417 const std::string &inout);
420 size_t int_byte_size,
const void *element,
421 const void *sides, int64_t number_sides,
441 static unsigned int hash(
const std::string &
name);
443 static double timer();
455 static void input_file(
const std::string &file_name, std::vector<std::string> *lines,
458 template <
class T>
static std::string
to_string(
const T &t) {
return std::to_string(t); }
479 size_t copies,
size_t max_var_len);
498 const std::string &header,
const std::string &suffix =
"\n\t");
501 const std::string &header,
const std::string &suffix =
"\n\t",
502 bool print_empty =
false);
static void copy_string(char(&output)[size], const std::string &source)
Definition: Ioss_Utils.h:181
static void info_property(const Ioss::GroupingEntity *ige, Ioss::Property::Origin origin, const std::string &header, const std::string &suffix="\n\t", bool print_empty=false)
Definition: Ioss_Utils.C:1446
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:22
static std::ostream * m_debugStream
debug output when requested. Default std::cerr
Definition: Ioss_Utils.h:73
static int field_warning(const Ioss::GroupingEntity *ge, const Ioss::Field &field, const std::string &inout)
Definition: Ioss_Utils.C:459
static unsigned int hash(const std::string &name)
Definition: Ioss_Utils.C:1096
static bool str_equal(const std::string &s1, const std::string &s2)
Case-insensitive string comparison.
Definition: Ioss_Utils.C:1155
static void uniquify(std::vector< T > &vec, bool skip_first=false)
Definition: Ioss_Utils.h:119
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:375
static void copy_string(char *dest, char const *source, size_t elements)
Definition: Ioss_Utils.C:1356
static T find_index_location(T node, const std::vector< T > &index)
Definition: Ioss_Utils.h:141
static size_t get_number(const std::string &suffix)
Definition: Ioss_Utils.C:289
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:25
static int term_width()
Definition: Ioss_Utils.C:1385
static std::string platform_information()
Get a string containing uname output.
Definition: Ioss_Utils.C:863
static size_t get_hwm_memory_info()
Definition: Ioss_Utils.C:943
Definition: Ioss_MeshCopyOptions.h:10
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
static std::string to_string(const T &t)
Definition: Ioss_Utils.h:458
static void clear(std::vector< T > &vec)
Definition: Ioss_Utils.h:192
static int64_t extract_id(const std::string &name_id)
Definition: Ioss_Utils.C:299
entity_type
Definition: Iovs_DatabaseIO.C:55
static int number_width(const size_t number, bool use_commas=false)
Definition: Ioss_Utils.h:210
static std::string encode_entity_name(const std::string &entity_type, int64_t id)
Definition: Ioss_Utils.C:348
std::ostream & DEBUG()
Definition: Ioss_Utils.h:507
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:78
static std::string m_preWarningText
Definition: Ioss_Utils.h:75
size_t unique(std::vector< T > &out, bool skip_first)
Definition: Ioss_Utils.h:36
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:745
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:24
static char ** get_name_array(size_t count, int size)
Definition: Ioss_Utils.C:357
static size_t get_memory_info()
Return amount of memory being used on this processor.
Definition: Ioss_Utils.C:879
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:989
static void info_fields(const Ioss::GroupingEntity *ige, Ioss::Field::RoleType role, const std::string &header, const std::string &suffix="\n\t")
Definition: Ioss_Utils.C:1402
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:447
static std::string uppercase(std::string name)
Convert a string to upper case.
Definition: Ioss_Utils.C:1167
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:1179
static void copy_string(char *dest, const std::string &source, size_t elements)
Definition: Ioss_Utils.h:176
static void set_debug_stream(std::ostream &debug_stream)
set the debug stream to the specified debug_stream
Definition: Ioss_Utils.h:94
std::ostream & OUTPUT()
Definition: Ioss_Utils.h:505
static void set_warning_stream(std::ostream &warning_stream)
set the warning stream to the specified warning_stream
Definition: Ioss_Utils.h:98
static void fixup_name(char *name)
Convert a string to lower case, and convert spaces to _.
Definition: Ioss_Utils.C:1209
#define IOSS_ERROR(errmsg)
Definition: Ioss_Utils.h:32
static double timer()
Definition: Ioss_Utils.C:1115
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:34
static void set_all_streams(std::ostream &out_stream)
set the stream for all streams (output, debug, and warning) to the specified out_stream
Definition: Ioss_Utils.h:81
static int power_2(int count)
Definition: Ioss_Utils.h:222
static bool block_is_omitted(Ioss::GroupingEntity *block)
Determine whether an entity has the property omitted.
Definition: Ioss_Utils.C:980
static std::ostream * m_outputStream
general informational output (very rare). Default std::cerr
Definition: Ioss_Utils.h:72
static void set_output_stream(std::ostream &output_stream)
set the output stream to the specified output_stream
Definition: Ioss_Utils.h:90
static void check_dynamic_cast(const void *ptr)
Definition: Ioss_Utils.h:110
static void copy_database(Ioss::Region ®ion, Ioss::Region &output_region, Ioss::MeshCopyOptions &options)
Definition: Ioss_Utils.C:1491
static std::ostream * m_warningStream
IOSS warning output. Default std::cerr.
Definition: Ioss_Utils.h:74
const size_t max_line_length
Definition: Ioex_BaseDatabaseIO.C:82
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:1259
static std::string decode_filename(const std::string &filename, int processor, int num_processors)
Definition: Ioss_Utils.C:272
static void generate_index(std::vector< T > &index)
Definition: Ioss_Utils.h:130
static void copy_string(char(&output)[size], const char *source)
Definition: Ioss_Utils.h:186
static int log_power_2(uint64_t value)
Definition: Ioss_Utils.C:1372
static void check_non_null(void *ptr, const char *type, const std::string &name, const std::string &func)
Definition: Ioss_Utils.C:260
static void delete_name_array(char **names, int count)
Definition: Ioss_Utils.C:367
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:1121
Origin
Definition: Ioss_Property.h:27
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:312
RoleType
Definition: Ioss_Field.h:49
std::string name(const Ioss::GroupingEntity *entity)
Definition: io_info.C:65
std::ostream & WARNING()
Definition: Ioss_Utils.h:509
static void generate_history_mesh(Ioss::Region *region)
Create a nominal mesh for use in history databases.
Definition: Ioss_Utils.C:1324
static bool substr_equal(const std::string &prefix, const std::string &str)
Case-insensitive substring comparison.
Definition: Ioss_Utils.C:1162
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:1078
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:68
Definition: Ioss_Utils.h:62
static void set_pre_warning_text(const std::string &text)
set the pre-warning text Sets the text output prior to a warning to the specified text....
Definition: Ioss_Utils.h:107
static void time_and_date(char *time_string, char *date_string, size_t length)
Get formatted time and date strings.
Definition: Ioss_Utils.C:245
static bool check_block_order(const std::vector< T * > &blocks)
Definition: Ioss_Utils.h:237
static std::string lowercase(std::string name)
Convert a string to lower case.
Definition: Ioss_Utils.C:1173