IOSS 2.0
Loading...
Searching...
No Matches
Iohb_DatabaseIO.h
Go to the documentation of this file.
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
23namespace 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 */
47namespace 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
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
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
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
#define IOSS_NOOP_PFI(type)
Definition Ioss_CodeTypes.h:119
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
#define IOSS_NOOP_GFI(type)
Definition Ioss_CodeTypes.h:114
Definition Iohb_DatabaseIO.h:66
IOSS_NODISCARD int64_t node_global_to_local_nl(int64_t, bool) const override
Definition Iohb_DatabaseIO.h:84
IOSS_NODISCARD int int_byte_size_db() const override
Definition Iohb_DatabaseIO.h:81
IOSS_NODISCARD int64_t element_global_to_local_nl(int64_t) const override
Definition Iohb_DatabaseIO.h:89
IOSS_NODISCARD std::string get_format() const override
Definition Iohb_DatabaseIO.h:73
void read_meta_data_nl() override
Definition Iohb_DatabaseIO.h:94
Definition Iohb_DatabaseIO.h:53
A homogeneous collection of other GroupingEntities.
Definition Ioss_Assembly.h:31
A homogeneous collection of other GroupingEntities.
Definition Ioss_Blob.h:31
Definition Ioss_CommSet.h:27
An input or output Database.
Definition Ioss_DatabaseIO.h:63
A collection of element edges with the same topology.
Definition Ioss_EdgeBlock.h:29
A collection of element edges.
Definition Ioss_EdgeSet.h:30
A collection of elements having the same topology.
Definition Ioss_ElementBlock.h:29
A collection of elements.
Definition Ioss_ElementSet.h:30
A collection of element faces with the same topology.
Definition Ioss_FaceBlock.h:29
A collection of element faces.
Definition Ioss_FaceSet.h:30
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
The main public user interface for creating Ioss::DatabaseIO objects.
Definition Ioss_IOFactory.h:35
A collection of all nodes in the region.
Definition Ioss_NodeBlock.h:33
A collection of nodes.
Definition Ioss_NodeSet.h:29
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
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
A collection of element sides.
Definition Ioss_SideSet.h:29
A structured zone – i,j,k.
Definition Ioss_StructuredBlock.h:91
A namespace for the heartbeat database format.
Definition Iohb_DatabaseIO.C:102
Format
Definition Iohb_DatabaseIO.h:50
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
State
Access states for a database.
Definition Ioss_State.h:15
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition Ioss_DBUsage.h:13