| 1 |
// Copyright(C) 1999-2024 National Technology & Engineering Solutions |
| 2 |
// of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with |
| 3 |
// NTESS, the U.S. Government retains certain rights in this software. |
| 4 |
// |
| 5 |
// See packages/seacas/LICENSE for details |
| 6 |
|
| 7 |
#pragma once |
| 8 |
|
| 9 |
#include "Iohb_Layout.h" |
| 10 |
#include "Ioss_CodeTypes.h" |
| 11 |
#include "Ioss_DBUsage.h" |
| 12 |
#include "Ioss_DatabaseIO.h" |
| 13 |
#include "Ioss_IOFactory.h" |
| 14 |
#include "Ioss_State.h" |
| 15 |
#include <cstddef> |
| 16 |
#include <cstdint> |
| 17 |
#include <iostream> |
| 18 |
#include <string> |
| 19 |
#include <time.h> |
| 20 |
|
| 21 |
#include "iohb_export.h" |
| 22 |
|
| 23 |
namespace Ioss { |
| 24 |
class GroupingEntity; |
| 25 |
class EntityBlock; |
| 26 |
class CommSet; |
| 27 |
class EdgeBlock; |
| 28 |
class EdgeSet; |
| 29 |
class ElementBlock; |
| 30 |
class ElementSet; |
| 31 |
class FaceBlock; |
| 32 |
class FaceSet; |
| 33 |
class Field; |
| 34 |
class NodeBlock; |
| 35 |
class NodeSet; |
| 36 |
class PropertyManager; |
| 37 |
class Region; |
| 38 |
class SideBlock; |
| 39 |
class SideSet; |
| 40 |
class StructuredBlock; |
| 41 |
class Assembly; |
| 42 |
class Blob; |
| 43 |
} // namespace Ioss |
| 44 |
|
| 45 |
/** \brief A namespace for the heartbeat database format. |
| 46 |
*/ |
| 47 |
namespace Iohb { |
| 48 |
class Layout; |
| 49 |
|
| 50 |
enum class Format { DEFAULT = 0, SPYHIS = 1, TEXT, TS_TEXT, CSV, TS_CSV }; |
| 51 |
|
| 52 |
class IOHB_EXPORT IOFactory : public Ioss::IOFactory |
| 53 |
{ |
| 54 |
public: |
| 55 |
static const IOFactory *factory(); |
| 56 |
|
| 57 |
private: |
| 58 |
IOFactory(); |
| 59 |
IOSS_NODISCARD Ioss::DatabaseIO *make_IO(const std::string &filename, |
| 60 |
Ioss::DatabaseUsage db_usage, |
| 61 |
Ioss_MPI_Comm communicator, |
| 62 |
const Ioss::PropertyManager &props) const override; |
| 63 |
}; |
| 64 |
|
| 65 |
class IOHB_EXPORT DatabaseIO : public Ioss::DatabaseIO |
| 66 |
{ |
| 67 |
public: |
| 68 |
DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage, |
| 69 |
Ioss_MPI_Comm communicator, const Ioss::PropertyManager &props); |
| 70 |
|
| 71 |
~DatabaseIO() override; |
| 72 |
|
| 73 |
IOSS_NODISCARD std::string get_format() const override { return "HeartBeat"; } |
| 74 |
|
| 75 |
// Check capabilities of input/output database... Returns an |
| 76 |
// unsigned int with the supported Ioss::EntityTypes or'ed |
| 77 |
// together. If "return_value & Ioss::EntityType" is set, then the |
| 78 |
// database supports that type (e.g. return_value & Ioss::FACESET) |
| 79 |
IOSS_NODISCARD unsigned entity_field_support() const override; |
| 80 |
|
| 81 |
IOSS_NODISCARD int int_byte_size_db() const override { return int_byte_size_api(); } |
| 82 |
|
| 83 |
private: |
| 84 |
IOSS_NODISCARD int64_t node_global_to_local_nl(int64_t /* global */, |
| 85 |
bool /* must_exist */) const override |
| 86 |
{ |
| 87 |
return 0; |
| 88 |
} |
| 89 |
IOSS_NODISCARD int64_t element_global_to_local_nl(int64_t /* global */) const override |
| 90 |
{ |
| 91 |
return 0; |
| 92 |
} |
| 93 |
|
| 94 |
void read_meta_data_nl() override {} |
| 95 |
|
| 96 |
void flush_database_nl() const override; |
| 97 |
|
| 98 |
bool begin_nl(Ioss::State state) override; |
| 99 |
bool end_nl(Ioss::State state) override; |
| 100 |
|
| 101 |
bool begin_state_nl(int state, double time) override; |
| 102 |
bool end_state_nl(int state, double time) override; |
| 103 |
|
| 104 |
void initialize() const; |
| 105 |
|
| 106 |
IOSS_NOOP_GFI(Ioss::Region) |
| 107 |
IOSS_NOOP_GFI(Ioss::NodeBlock) |
| 108 |
IOSS_NOOP_GFI(Ioss::EdgeBlock) |
| 109 |
IOSS_NOOP_GFI(Ioss::FaceBlock) |
| 110 |
IOSS_NOOP_GFI(Ioss::ElementBlock) |
| 111 |
IOSS_NOOP_GFI(Ioss::StructuredBlock) |
| 112 |
IOSS_NOOP_GFI(Ioss::SideBlock) |
| 113 |
IOSS_NOOP_GFI(Ioss::NodeSet) |
| 114 |
IOSS_NOOP_GFI(Ioss::EdgeSet) |
| 115 |
IOSS_NOOP_GFI(Ioss::FaceSet) |
| 116 |
IOSS_NOOP_GFI(Ioss::ElementSet) |
| 117 |
IOSS_NOOP_GFI(Ioss::SideSet) |
| 118 |
IOSS_NOOP_GFI(Ioss::CommSet) |
| 119 |
IOSS_NOOP_GFI(Ioss::Assembly) |
| 120 |
IOSS_NOOP_GFI(Ioss::Blob) |
| 121 |
|
| 122 |
int64_t put_field_internal(const Ioss::Region *region, const Ioss::Field &field, void *data, |
| 123 |
size_t data_size) const override; |
| 124 |
|
| 125 |
IOSS_NOOP_PFI(Ioss::NodeBlock) |
| 126 |
IOSS_NOOP_PFI(Ioss::EdgeBlock) |
| 127 |
IOSS_NOOP_PFI(Ioss::FaceBlock) |
| 128 |
IOSS_NOOP_PFI(Ioss::ElementBlock) |
| 129 |
IOSS_NOOP_PFI(Ioss::StructuredBlock) |
| 130 |
IOSS_NOOP_PFI(Ioss::SideBlock) |
| 131 |
IOSS_NOOP_PFI(Ioss::NodeSet) |
| 132 |
IOSS_NOOP_PFI(Ioss::EdgeSet) |
| 133 |
IOSS_NOOP_PFI(Ioss::FaceSet) |
| 134 |
IOSS_NOOP_PFI(Ioss::ElementSet) |
| 135 |
IOSS_NOOP_PFI(Ioss::SideSet) |
| 136 |
IOSS_NOOP_PFI(Ioss::CommSet) |
| 137 |
IOSS_NOOP_PFI(Ioss::Assembly) |
| 138 |
IOSS_NOOP_PFI(Ioss::Blob) |
| 139 |
|
| 140 |
time_t timeLastFlush_{0}; |
| 141 |
time_t flushInterval_{10}; |
| 142 |
|
| 143 |
std::ostream *logStream{nullptr}; |
| 144 |
std::unique_ptr<Layout> layout_{}; |
| 145 |
std::unique_ptr<Layout> legend_{}; |
| 146 |
|
| 147 |
std::string defaultTsFormat{"[%H:%M:%S]"}; |
| 148 |
std::string tsFormat{}; |
| 149 |
std::string separator_{", "}; |
| 150 |
int precision_{5}; |
| 151 |
int fieldWidth_{0}; |
| 152 |
bool showLabels{true}; |
| 153 |
bool showLegend{false}; |
| 154 |
bool appendOutput{false}; |
| 155 |
bool addTimeField{false}; |
| 156 |
|
| 157 |
bool initialized_{false}; |
| 158 |
bool streamNeedsDelete{false}; |
| 159 |
Format fileFormat{Format::DEFAULT}; |
| 160 |
}; |
| 161 |
} // namespace Iohb |