IOSS 2.0

Public Member Functions | Static Public Member Functions | List of all members
Ioss::Utils Class Reference

`#include <Ioss_Utils.h>`

## Public Member Functions
| Utils ()=default
| ~Utils ()=default

## Static Public Member Functions
static void | check_dynamic_cast (const void *ptr)
template<typename T >
static void | uniquify (std::vector< T > &vec, bool skip_first=false)
template<typename T >
static void | generate_index (std::vector< T > &index)
template<typename T >
static T | find_index_location (T node, const std::vector< T > &index)
static void | copy_string (char *dest, char const *source, size_t elements)
static void | copy_string (char *dest, const std::string &source, size_t elements)
template<size_t size>
static void | copy_string (char(&output)[size], const std::string &source)
template<size_t size>
static void | copy_string (char(&output)[size], const char *source)
template<typename T >
static void | clear (std::vector< T > &vec)
static int | number_width (const size_t number, bool use_commas=false)
static int | power_2 (int count)
template<typename T >
static bool | check_block_order (const std::vector< T * > &blocks)
static int | term_width ()
static int | log_power_2 (uint64_t value)
static char ** | get_name_array (size_t count, int size)
static void | delete_name_array (char **names, int count)
static void | time_and_date (char *time_string, char *date_string, size_t length)
| Get formatted time and date strings. More...
static std::string | decode_filename (const std::string &filename, int processor, int num_processors)
static size_t | get_number (const std::string &suffix)
static int64_t | extract_id (const std::string &name_id)
static std::string | encode_entity_name (const std::string &entity_type, int64_t id)
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. More...
static void | fixup_name (char *name)
| Convert a string to lower case, and convert spaces to `_`. More...
static void | fixup_name (std::string &name)
| Convert a string to lower case, and convert spaces to `_`. More...
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` More...
static bool | block_is_omitted (Ioss::GroupingEntity *block)
| Determine whether an entity has the property `omitted`. More...
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 `spatial` into a form that the IO system can (hopefully) recognize. More...
static std::string | uppercase (std::string name)
| Convert a string to upper case. More...
static std::string | lowercase (std::string name)
| Convert a string to lower case. More...
static void | check_non_null (void *ptr, const char *type, const std::string &name, const std::string &func)
static bool | str_equal (const std::string &s1, const std::string &s2)
| Case-insensitive string comparison. More...
static bool | substr_equal (const std::string &prefix, const std::string &str)
| Case-insensitive substring comparison. More...
static std::string | platform_information ()
| Get a string containing `uname` output. More...
static size_t | get_memory_info ()
| Return amount of memory being used on this processor. More...
static size_t | get_hwm_memory_info ()
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. More...
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)
static int | field_warning (const Ioss::GroupingEntity *ge, const Ioss::Field &field, const std::string &inout)
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)
static int64_t | get_side_offset (const Ioss::SideBlock *sb)
| Get the appropriate index offset for the sides of elements in a SideBlock. More...
static unsigned int | hash (const std::string &name)
static double | timer ()
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. More...
template<class T >
static std::string | to_string (const T &t)
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 `_` More...
static void | generate_history_mesh (Ioss::Region *region)
| Create a nominal mesh for use in history databases. More...
static void | copy_database (Ioss::Region &region, Ioss::Region &output_region, Ioss::MeshCopyOptions &options)

## Constructor & Destructor Documentation

## ◆ Utils()

Ioss::Utils::Utils | ( |  | ) |
| default

## ◆ ~Utils()

Ioss::Utils::~Utils | ( |  | ) |
| default

## Member Function Documentation

## ◆ block_is_omitted()

bool Ioss::Utils::block_is_omitted | ( | Ioss::GroupingEntity * | block | ) |
| static

Determine whether an entity has the property `omitted`.

Parameters

  [in] | block | The entity.

Returns
  True if the entity has the property `omitted`.

## ◆ calculate_sideblock_membership()

void Ioss::Utils::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
| ) |  |
| static

## ◆ check_block_order()

template<typename T >

static bool Ioss::Utils::check_block_order | ( | const std::vector< T * > & | blocks | ) |
| inlinestatic

## ◆ check_dynamic_cast()

static void Ioss::Utils::check_dynamic_cast | ( | const void * | ptr | ) |
| inlinestatic

## ◆ check_non_null()

void Ioss::Utils::check_non_null | ( | void * | ptr,
|  | const char * | type,
|  | const std::string & | name,
|  | const std::string & | func
| ) |  |
| static

## ◆ check_set_bool_property()

bool Ioss::Utils::check_set_bool_property | ( | const Ioss::PropertyManager & | properties,
|  | const std::string & | prop_name,
|  | bool & | prop_value
| ) |  |
| static

Check whether property `prop_name` exists and if so, set `prop_value`

based on the property value. Either "TRUE", "YES", "ON", or nonzero for true; or "FALSE", "NO", "OFF", or 0 for false.

Parameters

  [in] | properties | the Ioss::PropertyManager containing the properties to be checked.
  [in] | prop_name | the name of the property to check whether it exists and if so, set its value.
  [out] | prop_value | if `prop_name` exists and has a valid value, set prop_value accordingly. Does not modify if `prop_name` does not exist.

Returns
  true/false depending on whether property found and value set.

## ◆ clear()

template<typename T >

static void Ioss::Utils::clear | ( | std::vector< T > & | vec | ) |
| inlinestatic

## ◆ copy_database()

void Ioss::Utils::copy_database | ( | Ioss::Region & | region,
|  | Ioss::Region & | output_region,
|  | Ioss::MeshCopyOptions & | options
| ) |  |
| static

Copy the mesh in `region` to `output_region`. Behavior can be controlled via options in `options`

## ◆ copy_string() [1/4]

void Ioss::Utils::copy_string | ( | char * | dest,
|  | char const * | source,
|  | size_t | elements
| ) |  |
| static

## ◆ copy_string() [2/4]

static void Ioss::Utils::copy_string | ( | char * | dest,
|  | const std::string & | source,
|  | size_t | elements
| ) |  |
| inlinestatic

## ◆ copy_string() [3/4]

template<size_t size>

static void Ioss::Utils::copy_string | ( | char(&) | output[size],
|  | const char * | source
| ) |  |
| inlinestatic

## ◆ copy_string() [4/4]

template<size_t size>

static void Ioss::Utils::copy_string | ( | char(&) | output[size],
|  | const std::string & | source
| ) |  |
| inlinestatic

## ◆ decode_filename()

std::string Ioss::Utils::decode_filename | ( | const std::string & | filename,
|  | int | processor,
|  | int | num_processors
| ) |  |
| static

## ◆ delete_name_array()

void Ioss::Utils::delete_name_array | ( | char ** | names,
|  | int | count
| ) |  |
| static

## ◆ encode_entity_name()

std::string Ioss::Utils::encode_entity_name | ( | const std::string & | entity_type,
|  | int64_t | id
| ) |  |
| static

## ◆ extract_id()

int64_t Ioss::Utils::extract_id | ( | const std::string & | name_id | ) |
| static

## ◆ field_warning()

int Ioss::Utils::field_warning | ( | const Ioss::GroupingEntity * | ge,
|  | const Ioss::Field & | field,
|  | const std::string & | inout
| ) |  |
| static

## ◆ find_index_location()

template<typename T >

static T Ioss::Utils::find_index_location | ( | T | node,
|  | const std::vector< T > & | index
| ) |  |
| inlinestatic

## ◆ fixup_name() [1/2]

void Ioss::Utils::fixup_name | ( | char * | name | ) |
| static

Convert a string to lower case, and convert spaces to `_`.

The conversion is performed in place.

Parameters

  [in,out] | name | On input, the string to convert. On output, the converted string.

## ◆ fixup_name() [2/2]

void Ioss::Utils::fixup_name | ( | std::string & | name | ) |
| static

Convert a string to lower case, and convert spaces to `_`.

The conversion is performed in place.

Parameters

  [in,out] | name | On input, the string to convert. On output, the converted string.

## ◆ fixup_type()

std::string Ioss::Utils::fixup_type | ( | const std::string & | base,
|  | int | nodes_per_element,
|  | int | spatial
| ) |  |
| static

Process the base element type `base` which has `nodes_per_element` nodes and a spatial dimension of `spatial` into a form that the IO system can (hopefully) recognize.

Lowercases the name; converts spaces to `_`, adds nodes_per_element at end of name (if not already there), and does some other transformations to remove some exodusII ambiguity.

Parameters

  [in] | base | The element base name.
  [in] | nodes_per_element | The number of nodes per element.
  [in] | spatial | The spatial dimension of the element.

Returns
  The Ioss-formatted element name.

## ◆ format_id_list()

std::string Ioss::Utils::format_id_list | ( | const std::vector< size_t > & | ids,
|  | const std::string & | rng_sep = `" to "`,
|  | const std::string & | seq_sep = `", "`
| ) |  |
| static

create a string that describes the list of input `ids` collapsing ranges if possible.

Traverse the sorted input vector `ids` and return a string that has all sequential ranges collapsed and separated by `rng_sep` and all individual ids or ranges separated by `seq_sep`. Will throw an exception if `ids` is not sorted. An empty list returns an empty string. The sequence of ids `1, 2, 3, 5, 6, 7` with `rng_sep=".."` will return the default string `1..3, 5..8`

## ◆ generate_history_mesh()

void Ioss::Utils::generate_history_mesh | ( | Ioss::Region * | region | ) |
| static

Create a nominal mesh for use in history databases.

The model for a history file is a single sphere element (1 node, 1 element). This is needed for some applications that read this file that require a "mesh" even though a history file is just a collection of global variables with no real mesh. This routine will add the mesh portion to a history file.

Parameters

  [in,out] | region | The region on which the nominal mesh is to be defined.

## ◆ generate_index()

template<typename T >

static void Ioss::Utils::generate_index | ( | std::vector< T > & | index | ) |
| inlinestatic

## ◆ get_fields()

void Ioss::Utils::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
| ) |  |
| static

## ◆ get_hwm_memory_info()

size_t Ioss::Utils::get_hwm_memory_info | ( |  | ) |
| static

## ◆ get_memory_info()

size_t Ioss::Utils::get_memory_info | ( |  | ) |
| static

Return amount of memory being used on this processor.

## ◆ get_name_array()

char ** Ioss::Utils::get_name_array | ( | size_t | count,
|  | int | size
| ) |  |
| static

## ◆ get_number()

size_t Ioss::Utils::get_number | ( | const std::string & | suffix | ) |
| static

## ◆ get_side_offset()

int64_t Ioss::Utils::get_side_offset | ( | const Ioss::SideBlock * | sb | ) |
| static

Get the appropriate index offset for the sides of elements in a SideBlock.

And yet another idiosyncrasy of sidesets... The side of an element (especially shells) can be either a face or an edge in the same sideset. The ordinal of an edge is (local_edge_number+numfaces) on the database, but needs to be (local_edge_number) for Sierra...

If the sideblock has a "parent_element_topology" and a "topology", then we can determine whether to offset the side ordinals...

Parameters

  [in] | sb | Compute the offset for element sides in this SideBlock

Returns
  The offset.

## ◆ hash()

unsigned int Ioss::Utils::hash | ( | const std::string & | name | ) |
| static

## ◆ input_file()

void Ioss::Utils::input_file | ( | const std::string & | file_name,
|  | std::vector< std::string > * | lines,
|  | size_t | max_line_length = `0`
| ) |  |
| static

Convert an input file to a vector of strings containing one string for each line of the file.

Should only be called by a single processor or each processor will be accessing the file at the same time...

Parameters

  [in] | file_name | The name of the file.
  [out] | lines | The vector of strings containing the lines of the file
  [in] | max_line_length | The maximum number of characters in any line of the file.

## ◆ local_filename()

std::string Ioss::Utils::local_filename | ( | const std::string & | relative_filename,
|  | const std::string & | type,
|  | const std::string & | working_directory
| ) |  |
| static

Get a filename relative to the specified working directory (if any) of the current execution.

Working_directory must end with `/` or be empty.

Parameters

  [in] | relative_filename | The file path to be appended to the working directory path.
  [in] | type | The file type. "generated" file types are treated differently.
  [in] | working_directory | the path to which the relative_filename path is appended.

Returns
  The full path (working_directory + relative_filename)

## ◆ log_power_2()

int Ioss::Utils::log_power_2 | ( | uint64_t | value | ) |
| static

## ◆ lowercase()

std::string Ioss::Utils::lowercase | ( | std::string | name | ) |
| static

Convert a string to lower case.

Parameters

  [in] | name | The string to convert.

Returns
  The converted string.

## ◆ number_width()

static int Ioss::Utils::number_width | ( | const size_t | number,
|  | bool | use_commas = `false`
| ) |  |
| inlinestatic

Returns the number of digits required to print the number. If `use_commas` is specified, then the width will be adjusted to account for the comma used every 3 digits. (1,234,567,890 would return 13) Typically used with the `fmt::print()` functions as:

fmt::print("{:{}n}", number, number_width(number,true))
fmt::print("{:{}d}", number, number_width(number,false))

## ◆ platform_information()

std::string Ioss::Utils::platform_information | ( |  | ) |
| static

Get a string containing `uname` output.

This output contains information about the current computing platform. This is used as information data in the created results file to help in tracking when/where/... the file was created.

Returns
  The platform information string.

## ◆ power_2()

static int Ioss::Utils::power_2 | ( | int | count | ) |
| inlinestatic

## ◆ str_equal()

bool Ioss::Utils::str_equal | ( | const std::string & | s1,
|  | const std::string & | s2
| ) |  |
| static

Case-insensitive string comparison.

Parameters

  [in] | s1 | First string
  [in] | s2 | Second string

Returns
  `true` if strings are equal

## ◆ substr_equal()

bool Ioss::Utils::substr_equal | ( | const std::string & | prefix,
|  | const std::string & | str
| ) |  |
| static

Case-insensitive substring comparison.

Parameters

  [in] | prefix |
  [in] | str |

Returns
  `true` if `str` begins with `prefix` or `prefix` is empty

## ◆ term_width()

int Ioss::Utils::term_width | ( |  | ) |
| static

## ◆ time_and_date()

void Ioss::Utils::time_and_date | ( | char * | time_string,
|  | char * | date_string,
|  | size_t | length
| ) |  |
| static

Get formatted time and date strings.

Fill time_string and date_string with current time and date formatted as "HH:MM:SS" for time and "yy/mm/dd" or "yyyy/mm/dd" for date.

Parameters

  [out] | time_string | The formatted time string.
  [out] | date_string | The formatted date string.
  [in] | length | Use 8 for short-year date format, or 10 for long-year date format.

## ◆ timer()

double Ioss::Utils::timer | ( |  | ) |
| static

## ◆ to_string()

template<class T >

static std::string Ioss::Utils::to_string | ( | const T & | t | ) |
| inlinestatic

## ◆ uniquify()

template<typename T >

static void Ioss::Utils::uniquify | ( | std::vector< T > & | vec,
|  | bool | skip_first = `false`
| ) |  |
| inlinestatic

## ◆ uppercase()

std::string Ioss::Utils::uppercase | ( | std::string | name | ) |
| static

Convert a string to upper case.

Parameters

  [in] | name | The string to convert.

Returns
  The converted string.

## ◆ variable_name_kluge()

std::string Ioss::Utils::variable_name_kluge | ( | const std::string & | name,
|  | size_t | component_count,
|  | size_t | copies,
|  | size_t | max_var_len
| ) |  |
| static

Tries to shorten long variable names to an acceptable length, and converts to lowercase and spaces to `_`

Many databases have a maximum length for variable names which can cause a problem with variable name length. This routine tries to shorten long variable names to an acceptable length (`max_var_len` characters max). If the name is already less than this length, it is returned unchanged...

Since there is a (good) chance that two shortened names will match, a 2-letter `hash` code is appended to the end of the variable name.

So, we shorten the name to a maximum of `max_var_len`-3 characters and append a 2 character hash+separator.

It also converts name to lowercase and converts spaces to `_`

The documentation for this class was generated from the following files:

- src/Ioss_Utils.h
- src/Ioss_Utils.C

Ioss::Utils::number_width
static int number_width(const size_t number, bool use_commas=false)
Definition: Ioss_Utils.h:201