26#include "ioss_export.h"
34 class PropertyManager;
38[[noreturn]]
inline void IOSS_ERROR(
const std::ostringstream &errmsg)
40 throw std::runtime_error((errmsg).str());
44#define IOSS_ASSERT_USED(x) (void)x
46#define IOSS_ASSERT_USED(x)
74 return N == 0 ? nullptr : arr.data();
77template <
typename T,
size_t N>
IOSS_NODISCARD constexpr const T *
Data(
const std::array<T, N> &arr)
79 return N == 0 ? nullptr : arr.data();
101 static void set_all_streams(std::ostream &out_stream);
119 static void set_output_stream(std::ostream &output_stream);
123 static void set_debug_stream(std::ostream &debug_stream);
127 static void set_warning_stream(std::ostream &warning_stream);
136 static void copyright(std::ostream &out,
const std::string &year_range);
140 if (ptr ==
nullptr) {
141 std::ostringstream errmsg;
142 errmsg <<
"INTERNAL ERROR: Invalid dynamic cast returned nullptr\n";
154#ifdef __IOSS_WINDOWS__
155 return path[0] ==
'\\' && path[1] ==
':';
157 return path[0] ==
'/';
164 IOSS_NODISCARD static std::string get_type_from_file(
const std::string &filename);
166 template <
typename T>
static void uniquify(std::vector<T> &vec,
bool skip_first =
false)
168 auto it = vec.begin();
173 vec.resize(unique(vec, skip_first));
180 for (
size_t i = 0; i < index.size() - 1; i++) {
188 template <
typename T>
197 static size_t prev = 1;
199 size_t nproc = index.size();
200 if (prev < nproc && index[prev - 1] <= node && index[prev] > node) {
204 for (
size_t p = 1; p < nproc; p++) {
205 if (index[p] > node) {
210 std::ostringstream errmsg;
211 errmsg <<
"FATAL ERROR: find_index_location. Searching for " << node <<
" in:\n";
212 for (
auto idx : index) {
213 errmsg << idx <<
", ";
218 return std::distance(index.begin(), std::upper_bound(index.begin(), index.end(), node)) - 1;
222 static void copy_string(
char *dest,
char const *source,
size_t elements);
224 static void copy_string(
char *dest,
const std::string &source,
size_t elements)
226 copy_string(dest, source.c_str(), elements);
229 template <
size_t size>
static void copy_string(
char (&output)[size],
const std::string &source)
231 copy_string(output, source.c_str(), size);
234 template <
size_t size>
static void copy_string(
char (&output)[size],
const char *source)
237 copy_string(output, source, size);
240 template <
typename T>
static void clear(std::vector<T> &vec)
244 assert(vec.capacity() == 0);
263 int width =
static_cast<int>(std::floor(std::log10(number))) + 1;
265 width += ((width - 1) / 3);
279 while (pow2 < count) {
285 template <
typename T>
290 typename std::vector<T *>::const_iterator I;
292 int64_t eb_offset = -1;
293 for (I = blocks.begin(); I != blocks.end(); ++I) {
294 int64_t this_off = (*I)->get_offset();
295 if (this_off < eb_offset) {
302 eb_offset = this_off;
322 static void time_and_date(
char *time_string,
char *date_string,
size_t length);
324 IOSS_NODISCARD static std::string decode_filename(
const std::string &filename,
int processor,
328 IOSS_NODISCARD static std::string encode_entity_name(
const std::string &entity_type,
335 IOSS_NODISCARD static std::string get_trailing_digits(
const std::string &name);
345 IOSS_NODISCARD static std::string format_id_list(
const std::vector<size_t> &ids,
346 const std::string &rng_sep =
" to ",
347 const std::string &seq_sep =
", ");
356 static void fixup_name(
char *name);
365 static void fixup_name(std::string &name);
380 const std::string &prop_name,
bool &prop_value);
402 IOSS_NODISCARD static std::string fixup_type(
const std::string &base,
int nodes_per_element,
426 static void check_non_null(
void *ptr,
const char *type,
const std::string &name,
427 const std::string &func);
435 IOSS_NODISCARD static bool str_equal(
const std::string &s1,
const std::string &s2);
443 IOSS_NODISCARD static bool substr_equal(
const std::string &prefix,
const std::string &str);
449 static bool check_int_to_real_overflow(
const Ioss::Field &field, int64_t *data,
472 IOSS_NODISCARD static std::string local_filename(
const std::string &relative_filename,
473 const std::string &type,
474 const std::string &working_directory);
476 static void get_fields(int64_t entity_count,
Ioss::NameList &names,
478 std::vector<Ioss::Field> &fields);
481 const std::string &inout);
483 static void calculate_sideblock_membership(
IntVector &face_is_member,
const SideBlock *sb,
484 size_t int_byte_size,
const void *element,
485 const void *sides, int64_t number_sides,
522 static void input_file(
const std::string &file_name,
Ioss::NameList *lines,
523 size_t max_line_length = 0);
527 return std::to_string(t);
548 IOSS_NODISCARD static std::string variable_name_kluge(
const std::string &name,
549 size_t component_count,
size_t copies,
565 static void generate_history_mesh(
Ioss::Region *region);
568 const std::string &header,
const std::string &suffix =
"\n\t",
569 bool detail =
false);
572 const std::string &header,
const std::string &suffix =
"\n\t",
573 bool print_empty =
false);
577 dest.insert(dest.end(), src.begin(), src.end());
578 std::sort(dest.begin(), dest.end(), std::less<>());
579 auto endIter = std::unique(dest.begin(), dest.end());
580 dest.resize(endIter - dest.begin());
585 template <
typename T>
static size_t unique(std::vector<T> &out,
bool skip_first)
598 for (; i < out.size(); ++i) {
601 pos += (newv != oldv);
612 inline std::ostream &
WarnOut(
bool output_prewarning =
true)
614 if (output_prewarning) {
#define IOSS_MAYBE_UNUSED
Definition Ioss_CodeTypes.h:54
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
IOSS_NODISCARD constexpr T * Data(std::vector< T > &vec)
Definition Ioss_Utils.h:56
void IOSS_ERROR(const std::ostringstream &errmsg)
Definition Ioss_Utils.h:38
An input or output Database.
Definition Ioss_DatabaseIO.h:63
Represents an element topology.
Definition Ioss_ElementTopology.h:68
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
RoleType
Definition Ioss_Field.h:69
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
Origin
Definition Ioss_Property.h:30
A grouping entity that contains other grouping entities.
Definition Ioss_Region.h:93
A collection of element sides having the same topology.
Definition Ioss_SideBlock.h:37
Definition Ioss_Utils.h:86
static IOSS_NODISCARD std::string to_string(const T &t)
Definition Ioss_Utils.h:525
static void insert_sort_and_unique(const Ioss::NameList &src, Ioss::NameList &dest)
Definition Ioss_Utils.h:575
static std::ostream * m_debugStream
debug output when requested. Default std::cerr
Definition Ioss_Utils.h:89
static std::ostream * m_outputStream
general informational output (very rare). Default std::cerr
Definition Ioss_Utils.h:88
static IOSS_NODISCARD int number_width(const size_t number, bool use_commas=false)
Definition Ioss_Utils.h:258
static void clear(std::vector< T > &vec)
Definition Ioss_Utils.h:240
static void copy_string(char(&output)[size], const char *source)
Definition Ioss_Utils.h:234
static void check_dynamic_cast(const void *ptr)
Definition Ioss_Utils.h:138
static bool is_path_absolute(const std::string &path)
Definition Ioss_Utils.h:151
static void uniquify(std::vector< T > &vec, bool skip_first=false)
Definition Ioss_Utils.h:166
static std::string m_preWarningText
Definition Ioss_Utils.h:91
static void generate_index(std::vector< T > &index)
Definition Ioss_Utils.h:177
static IOSS_NODISCARD int power_2(int count)
Definition Ioss_Utils.h:270
static std::ostream * m_warningStream
IOSS warning output. Default std::cerr.
Definition Ioss_Utils.h:90
static IOSS_NODISCARD bool check_block_order(IOSS_MAYBE_UNUSED const std::vector< T * > &blocks)
Definition Ioss_Utils.h:286
static size_t unique(std::vector< T > &out, bool skip_first)
Definition Ioss_Utils.h:585
static void copy_string(char(&output)[size], const std::string &source)
Definition Ioss_Utils.h:229
static IOSS_NODISCARD T find_index_location(T node, const std::vector< T > &index)
Definition Ioss_Utils.h:189
static void copy_string(char *dest, const std::string &source, size_t elements)
Definition Ioss_Utils.h:224
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:133
static IOSS_NODISCARD std::string & get_warning_text()
Definition Ioss_Utils.h:115
static IOSS_NODISCARD std::ostream & get_warning_stream()
get the warning stream.
Definition Ioss_Utils.C:157
static IOSS_NODISCARD std::ostream & get_output_stream()
get the output stream.
Definition Ioss_Utils.C:155
static IOSS_NODISCARD std::ostream & get_debug_stream()
get the debug stream.
Definition Ioss_Utils.C:159
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
std::ostream & WarnOut(bool output_prewarning=true)
Definition Ioss_Utils.h:612
std::ostream & OUTPUT()
Definition Ioss_Utils.h:608
void sort(Iter begin, Iter end, Comp compare)
Definition Ioss_Sort.h:17
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
ElementShape
Definition Ioss_ElementTopology.h:24
std::ostream & DebugOut()
Definition Ioss_Utils.h:610
std::vector< int > IntVector
Definition Ioss_CodeTypes.h:21
EntityType
The particular type of GroupingEntity.
Definition Ioss_EntityType.h:12