IOSS 2.0

Iohb_DatabaseIO.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 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 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Iohb_DatabaseIO_h
34 #define IOSS_Iohb_DatabaseIO_h
35
36 #include "Ioss_State.h" // for State
37 #include <Ioss_CodeTypes.h>
38 #include <Ioss_DBUsage.h> // for DatabaseUsage
39 #include <Ioss_DatabaseIO.h> // for DatabaseIO
40 #include <Ioss_IOFactory.h> // for IOFactory
41 #include <cstddef> // for size_t
42 #include <cstdint> // for int64_t
43 #include <iostream> // for ostream
44 #include <string> // for string
45 namespace Iohb {
46 class Layout;
47 class CommSet;
48 class EdgeBlock;
49 class EdgeSet;
50 class ElementBlock;
51 class ElementSet;
52 class FaceBlock;
53 class FaceSet;
54 class Field;
55 class NodeBlock;
56 class NodeSet;
57 class PropertyManager;
58 class Region;
59 class SideBlock;
60 class SideSet;
61 class StructuredBlock;
62 } // namespace Iohb
63
64 namespace Ioss {
65 class GroupingEntity;
66 class EntityBlock;
67 } // namespace Ioss
68
69 /** \brief A namespace for the heartbeat database format.
70 */
71 namespace Iohb {
72 class Layout;
73
74 enum Format { DEFAULT = 0, SPYHIS = 1, TEXT, TS_TEXT, CSV, TS_CSV };
75
76 class IOFactory : public Ioss::IOFactory
77 {
78 public:
79 static const IOFactory *factory();
80
81 private:
82 IOFactory();
83 Ioss::DatabaseIO *make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage,
84 MPI_Comm communicator,
85 const Ioss::PropertyManager &props) const override;
86 };
87
88 class DatabaseIO : public Ioss::DatabaseIO
89 {
90 public:
91 DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage,
92 MPI_Comm communicator, const Ioss::PropertyManager &props);
93 DatabaseIO(const DatabaseIO &from) = delete;
94 DatabaseIO &operator=(const DatabaseIO &from) = delete;
95
96 ~DatabaseIO() override;
97
98 const std::string get_format() const override {return "HeartBeat";}
99
100 // Check capabilities of input/output database... Returns an
101 // unsigned int with the supported Ioss::EntityTypes or'ed
102 // together. If "return_value & Ioss::EntityType" is set, then the
103 // database supports that type (e.g. return_value & Ioss::FACESET)
104 unsigned entity_field_support() const override;
105
106 int int_byte_size_db() const override { return int_byte_size_api(); }
107
108 private:
109 int64_t node_global_to_local__(int64_t /* global */, bool /* must_exist */) const override
110 {
111 return 0;
112 }
113 int64_t element_global_to_local__(int64_t /* global */) const override { return 0; }
114
115 void read_meta_data__() override {}
116
117 void flush_database__() const override;
118
119 bool begin__(Ioss::State state) override;
120 bool end__(Ioss::State state) override;
121
122 bool begin_state__(int state, double time) override;
123 bool end_state__(int state, double time) override;
124
125 void initialize() const;
126
127 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
128 size_t data_size) const override;
129 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
130 size_t data_size) const override;
131 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
132 size_t data_size) const override;
133 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
134 size_t data_size) const override;
135 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
136 size_t data_size) const override;
137 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
138 void *data, size_t data_size) const override;
139 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
140 size_t data_size) const override;
141 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
142 size_t data_size) const override;
143 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
144 size_t data_size) const override;
145 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
146 size_t data_size) const override;
147 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
148 size_t data_size) const override;
149 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
150 size_t data_size) const override;
151 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
152 size_t data_size) const override;
153
154 int64_t put_field_internal(const Ioss::Region *region, const Ioss::Field &field, void *data,
155 size_t data_size) const override;
156 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
157 size_t data_size) const override;
158 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
159 size_t data_size) const override;
160 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
161 size_t data_size) const override;
162 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
163 size_t data_size) const override;
164 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
165 size_t data_size) const override;
166 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
167 size_t data_size) const override;
168 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
173 size_t data_size) const override;
174 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
175 size_t data_size) const override;
176 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
177 size_t data_size) const override;
178 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
179 void *data, size_t data_size) const override;
180
181 time_t timeLastFlush_{0};
182 time_t flushInterval_{10};
183
184 std::ostream *logStream{nullptr};
185 Layout * layout_{nullptr};
186 Layout * legend_{nullptr};
187
188 std::string defaultTsFormat{"[%H:%M:%S]"};
189 std::string tsFormat{};
190 std::string separator_{", "};
191 int precision_{5};
192 int fieldWidth_{0};
193 bool showLabels{true};
194 bool showLegend{false};
195 bool appendOutput{false};
196 bool addTimeField{false};
197
198 bool initialized_{false};
199 bool streamNeedsDelete{false};
200 enum Format fileFormat { DEFAULT };
201 };
202 } // namespace Iohb
203 #endif // IOSS_Iohb_DatabaseIO_h
Ioss_DBUsage.h
Iohb::DatabaseIO::legend_
Layout * legend_
Definition: Iohb_DatabaseIO.h:186
Iohb::DatabaseIO::layout_
Layout * layout_
Definition: Iohb_DatabaseIO.h:185
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iohb::DatabaseIO::begin_state__
bool begin_state__(int state, double time) override
Definition: Iohb_DatabaseIO.C:336
Iohb::TEXT
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iohb_DatabaseIO.C:332
Iohb::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::Region *region, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iohb_DatabaseIO.C:478
Iohb::DatabaseIO::appendOutput
bool appendOutput
Definition: Iohb_DatabaseIO.h:195
Iohb::DatabaseIO::flush_database__
void flush_database__() const override
Definition: Iohb_DatabaseIO.C:355
Iohb::DatabaseIO
Definition: Iohb_DatabaseIO.h:88
Iohb::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iohb_DatabaseIO.h:115
Iohb::DatabaseIO::logStream
std::ostream * logStream
Definition: Iohb_DatabaseIO.h:184
Iohb::DatabaseIO::initialize
void initialize() const
Definition: Iohb_DatabaseIO.C:183
Iohb::DatabaseIO::node_global_to_local__
int64_t node_global_to_local__(int64_t, bool) const override
Definition: Iohb_DatabaseIO.h:109
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Ioss::DatabaseUsage
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition: Ioss_DBUsage.h:40
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
Ioss::State
State
Access states for a database.
Definition: Ioss_State.h:42
Ioss::IOFactory
The main public user interface for creating Ioss::DatabaseIO objects.
Definition: Ioss_IOFactory.h:58
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
Iohb::IOFactory::make_IO
Ioss::DatabaseIO * make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage, MPI_Comm communicator, const Ioss::PropertyManager &props) const override
Definition: Iohb_DatabaseIO.C:157
Iohb::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
Ioss::NodeSet
A collection of nodes.
Definition: Ioss_NodeSet.h:53
Iohb::SPYHIS
Definition: Iohb_DatabaseIO.h:74
Ioss::FaceSet
A collection of element faces.
Definition: Ioss_FaceSet.h:54
Ioss::StructuredBlock
A structured zone – i,j,k.
Definition: Ioss_StructuredBlock.h:103
Iohb::DatabaseIO::separator_
std::string separator_
Definition: Iohb_DatabaseIO.h:190
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Ioss::ElementSet
A collection of elements.
Definition: Ioss_ElementSet.h:54
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iohb::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iohb_DatabaseIO.C:396
Iohb::DatabaseIO::element_global_to_local__
int64_t element_global_to_local__(int64_t) const override
Definition: Iohb_DatabaseIO.h:113
Ioss::FaceBlock
A collection of element faces with the same topology.
Definition: Ioss_FaceBlock.h:53
Iohb::IOFactory::factory
static const IOFactory * factory()
Definition: Iohb_DatabaseIO.C:149
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
Ioss::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Iohb::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iohb_DatabaseIO.C:628
Ioss_State.h
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:59
Iohb
A namespace for the heartbeat database format.
Definition: Iohb_DatabaseIO.C:146
Iohb::DatabaseIO::get_format
const std::string get_format() const override
Definition: Iohb_DatabaseIO.h:98
Iohb::DatabaseIO::tsFormat
std::string tsFormat
Definition: Iohb_DatabaseIO.h:189
Iohb::DatabaseIO::end_state__
bool end_state__(int state, double time) override
Definition: Iohb_DatabaseIO.C:362
Iohb::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iohb_DatabaseIO.C:334
Iohb::IOFactory
Definition: Iohb_DatabaseIO.h:76
Iohb::Layout
Definition: Iohb_Layout.h:42
Iohb::DatabaseIO::timeLastFlush_
time_t timeLastFlush_
Definition: Iohb_DatabaseIO.h:181
Ioss_IOFactory.h
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Ioss::DatabaseIO::int_byte_size_api
int int_byte_size_api() const
Returns 4 or 8.
Definition: Ioss_DatabaseIO.C:237
Iohb::DatabaseIO::flushInterval_
time_t flushInterval_
Definition: Iohb_DatabaseIO.h:182
Iohb::DatabaseIO::showLabels
bool showLabels
Definition: Iohb_DatabaseIO.h:193
Iohb::IOFactory::IOFactory
IOFactory()
Definition: Iohb_DatabaseIO.C:155
Iohb::DatabaseIO::fieldWidth_
int fieldWidth_
Definition: Iohb_DatabaseIO.h:192
Iohb::DatabaseIO::initialized_
bool initialized_
Definition: Iohb_DatabaseIO.h:198
Iohb::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iohb_DatabaseIO.h:106
Iohb::CSV
Definition: Iohb_DatabaseIO.h:74
Iohb::TS_TEXT
Definition: Iohb_DatabaseIO.h:74
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:74
Iohb::DatabaseIO::defaultTsFormat
std::string defaultTsFormat
Definition: Iohb_DatabaseIO.h:188
Iohb::DatabaseIO::precision_
int precision_
Definition: Iohb_DatabaseIO.h:191
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iohb::DEFAULT
Definition: Iohb_DatabaseIO.h:74
Iohb::Format
Format
Definition: Iohb_DatabaseIO.h:74
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:96
Iohb::DatabaseIO::showLegend
bool showLegend
Definition: Iohb_DatabaseIO.h:194
Iohb::DatabaseIO::addTimeField
bool addTimeField
Definition: Iohb_DatabaseIO.h:196
Iohb::DatabaseIO::~DatabaseIO
~DatabaseIO() override
Definition: Iohb_DatabaseIO.C:174
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:53
Ioss_CodeTypes.h
Iohb::TS_CSV
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::streamNeedsDelete
bool streamNeedsDelete
Definition: Iohb_DatabaseIO.h:199
Ioss_DatabaseIO.h