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 = 0, 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 // Check capabilities of input/output database... Returns an
99 // unsigned int with the supported Ioss::EntityTypes or'ed
100 // together. If "return_value & Ioss::EntityType" is set, then the
101 // database supports that type (e.g. return_value & Ioss::FACESET)
102 unsigned entity_field_support() const override;
103
104 int int_byte_size_db() const override { return int_byte_size_api(); }
105
106 private:
107 int64_t node_global_to_local__(int64_t /* global */, bool /* must_exist */) const override
108 {
109 return 0;
110 }
111 int64_t element_global_to_local__(int64_t /* global */) const override { return 0; }
112
113 void read_meta_data__() override {}
114
115 void flush_database__() const override;
116
117 bool begin__(Ioss::State state) override;
118 bool end__(Ioss::State state) override;
119
120 bool begin_state__(int state, double time) override;
121 bool end_state__(int state, double time) override;
122
123 void initialize() const;
124
125 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
126 size_t data_size) const override;
127 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
128 size_t data_size) const override;
129 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
130 size_t data_size) const override;
131 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
132 size_t data_size) const override;
133 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
134 size_t data_size) const override;
135 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
136 void *data, size_t data_size) const override;
137 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
138 size_t data_size) const override;
139 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
140 size_t data_size) const override;
141 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
142 size_t data_size) const override;
143 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
144 size_t data_size) const override;
145 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
146 size_t data_size) const override;
147 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
148 size_t data_size) const override;
149 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
150 size_t data_size) const override;
151
152 int64_t put_field_internal(const Ioss::Region *region, const Ioss::Field &field, void *data,
153 size_t data_size) const override;
154 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
155 size_t data_size) const override;
156 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
157 size_t data_size) const override;
158 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
159 size_t data_size) const override;
160 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
161 size_t data_size) const override;
162 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
163 size_t data_size) const override;
164 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
165 size_t data_size) const override;
166 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
167 size_t data_size) const override;
168 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
173 size_t data_size) const override;
174 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
175 size_t data_size) const override;
176 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
177 void *data, size_t data_size) const override;
178
179 time_t timeLastFlush_{0};
180 time_t flushInterval_{10};
181
182 std::ostream *logStream{nullptr};
183 Layout * layout_{nullptr};
184 Layout * legend_{nullptr};
185
186 std::string tsFormat{"[%H:%M:%S]"};
187 std::string separator_{", "};
188 int precision_{5};
189 int fieldWidth_{0};
190 bool showLabels{false};
191 bool showLegend{true};
192 bool appendOutput{false};
193 bool addTimeField{false};
194
195 bool initialized_{false};
196 bool streamNeedsDelete{false};
197 enum Format fileFormat { SPYHIS };
198 };
199 } // namespace Iohb
200 #endif // IOSS_Iohb_DatabaseIO_h
Ioss_CodeTypes.h
Iohb::DatabaseIO::initialize
void initialize() const
Definition: Iohb_DatabaseIO.C:183
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
Ioss_DBUsage.h
Iohb::TS_CSV
Definition: Iohb_DatabaseIO.h:74
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::begin__
bool begin__(Ioss::State state) override
Definition: Iohb_DatabaseIO.C:324
Ioss::NodeSet
A collection of nodes.
Definition: Ioss_NodeSet.h:53
Ioss::FaceBlock
A collection of element faces with the same topology.
Definition: Ioss_FaceBlock.h:53
Iohb::DatabaseIO::element_global_to_local__
int64_t element_global_to_local__(int64_t) const override
Definition: Iohb_DatabaseIO.h:111
Iohb::DatabaseIO::begin_state__
bool begin_state__(int state, double time) override
Definition: Iohb_DatabaseIO.C:328
Ioss::FaceSet
A collection of element faces.
Definition: Ioss_FaceSet.h:54
Iohb::SPYHIS
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::separator_
std::string separator_
Definition: Iohb_DatabaseIO.h:187
Iohb::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
Iohb::DatabaseIO::tsFormat
std::string tsFormat
Definition: Iohb_DatabaseIO.h:186
Iohb::DatabaseIO::showLabels
bool showLabels
Definition: Iohb_DatabaseIO.h:190
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Iohb::TEXT
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::appendOutput
bool appendOutput
Definition: Iohb_DatabaseIO.h:192
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
Iohb::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iohb_DatabaseIO.C:620
Ioss_DatabaseIO.h
Iohb::DatabaseIO::flush_database__
void flush_database__() const override
Definition: Iohb_DatabaseIO.C:347
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::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Ioss_State.h
Iohb::DatabaseIO::node_global_to_local__
int64_t node_global_to_local__(int64_t, bool) const override
Definition: Iohb_DatabaseIO.h:107
Iohb::DatabaseIO::timeLastFlush_
time_t timeLastFlush_
Definition: Iohb_DatabaseIO.h:179
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Ioss::StructuredBlock
A structured zone – i,j,k.
Definition: Ioss_StructuredBlock.h:103
Ioss::DatabaseIO::int_byte_size_api
int int_byte_size_api() const
Returns 4 or 8.
Definition: Ioss_DatabaseIO.C:238
Ioss::ElementSet
A collection of elements.
Definition: Ioss_ElementSet.h:54
Iohb::DatabaseIO::~DatabaseIO
~DatabaseIO() override
Definition: Iohb_DatabaseIO.C:174
Ioss::DatabaseUsage
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition: Ioss_DBUsage.h:40
Iohb::DatabaseIO::fieldWidth_
int fieldWidth_
Definition: Iohb_DatabaseIO.h:189
Iohb::DatabaseIO::logStream
std::ostream * logStream
Definition: Iohb_DatabaseIO.h:182
Iohb::DatabaseIO::showLegend
bool showLegend
Definition: Iohb_DatabaseIO.h:191
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iohb::DatabaseIO::layout_
Layout * layout_
Definition: Iohb_DatabaseIO.h:183
Iohb::DatabaseIO::initialized_
bool initialized_
Definition: Iohb_DatabaseIO.h:195
Iohb::DatabaseIO::end_state__
bool end_state__(int state, double time) override
Definition: Iohb_DatabaseIO.C:354
Iohb::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iohb_DatabaseIO.h:104
Iohb::TS_TEXT
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::addTimeField
bool addTimeField
Definition: Iohb_DatabaseIO.h:193
Iohb::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iohb_DatabaseIO.C:326
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iohb::DatabaseIO::flushInterval_
time_t flushInterval_
Definition: Iohb_DatabaseIO.h:180
Iohb::CSV
Definition: Iohb_DatabaseIO.h:74
Iohb::DEFAULT
Definition: Iohb_DatabaseIO.h:74
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:73
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
Iohb::IOFactory::factory
static const IOFactory * factory()
Definition: Iohb_DatabaseIO.C:149
Iohb::IOFactory
Definition: Iohb_DatabaseIO.h:76
Iohb::DatabaseIO
Definition: Iohb_DatabaseIO.h:88
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:59
Iohb
A namespace for the heartbeat database format.
Definition: Iohb_DatabaseIO.C:146
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iohb::DatabaseIO::precision_
int precision_
Definition: Iohb_DatabaseIO.h:188
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:470
Ioss_IOFactory.h
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:88
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:388
Iohb::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iohb_DatabaseIO.h:113
Iohb::DatabaseIO::streamNeedsDelete
bool streamNeedsDelete
Definition: Iohb_DatabaseIO.h:196
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iohb::Format
Format
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::legend_
Layout * legend_
Definition: Iohb_DatabaseIO.h:184
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iohb::IOFactory::IOFactory
IOFactory()
Definition: Iohb_DatabaseIO.C:155
Iohb::Layout
Definition: Iohb_Layout.h:42