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 };
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__(Ioss::Region *region, int state, double time) override;
121 bool end_state__(Ioss::Region *region, int state, double time) override;
122
123 void initialize(const Ioss::Region *region) 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 {
138 return -1;
139 }
140 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
141 size_t data_size) const override;
142 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
143 size_t data_size) const override;
144 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
145 size_t data_size) const override;
146 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
147 size_t data_size) const override;
148 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
149 size_t data_size) const override;
150 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
151 size_t data_size) const override;
152 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
153 size_t data_size) const override;
154
155 int64_t put_field_internal(const Ioss::Region *region, const Ioss::Field &field, void *data,
156 size_t data_size) const override;
157 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
158 size_t data_size) const override;
159 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
160 size_t data_size) const override;
161 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
162 size_t data_size) const override;
163 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
164 size_t data_size) const override;
165 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
166 size_t data_size) const override;
167 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
168 size_t data_size) const override;
169 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
170 size_t data_size) const override;
171 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
172 size_t data_size) const override;
173 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
174 size_t data_size) const override;
175 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
176 size_t data_size) const override;
177 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
178 size_t data_size) const override;
179 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
180 void *data, size_t data_size) const override
181 {
182 return -1;
183 }
184
185 time_t timeLastFlush_;
186 time_t flushInterval_;
187
188 std::ostream *logStream;
189 Layout * layout_;
190 Layout * legend_;
191
192 std::string tsFormat;
193 std::string separator_;
194 int precision_;
195 int fieldWidth_;
196 bool showLabels;
197 bool showLegend;
198 bool appendOutput;
199 bool addTimeField;
200
201 bool initialized_;
202 bool streamNeedsDelete;
203 enum Format fileFormat;
204 };
205 } // namespace Iohb
206 #endif // IOSS_Iohb_DatabaseIO_h
Ioss_CodeTypes.h
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:80
Ioss_DBUsage.h
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::get_field_internal
int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iohb_DatabaseIO.h:135
Iohb::DatabaseIO::element_global_to_local__
int64_t element_global_to_local__(int64_t) const override
Definition: Iohb_DatabaseIO.h:111
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:193
Iohb::DatabaseIO::tsFormat
std::string tsFormat
Definition: Iohb_DatabaseIO.h:192
Iohb::DatabaseIO::showLabels
bool showLabels
Definition: Iohb_DatabaseIO.h:196
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Iohb::DatabaseIO::appendOutput
bool appendOutput
Definition: Iohb_DatabaseIO.h:198
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
Ioss_DatabaseIO.h
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_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:185
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:98
Ioss::ElementSet
A collection of elements.
Definition: Ioss_ElementSet.h:54
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:195
Iohb::DatabaseIO::logStream
std::ostream * logStream
Definition: Iohb_DatabaseIO.h:188
Iohb::DatabaseIO::showLegend
bool showLegend
Definition: Iohb_DatabaseIO.h:197
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iohb::DatabaseIO::layout_
Layout * layout_
Definition: Iohb_DatabaseIO.h:189
Iohb::DatabaseIO::initialized_
bool initialized_
Definition: Iohb_DatabaseIO.h:201
Iohb::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iohb_DatabaseIO.h:104
Iohb::DatabaseIO::addTimeField
bool addTimeField
Definition: Iohb_DatabaseIO.h:199
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iohb::DatabaseIO::flushInterval_
time_t flushInterval_
Definition: Iohb_DatabaseIO.h:186
Iohb::DEFAULT
Definition: Iohb_DatabaseIO.h:74
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
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:194
Ioss_IOFactory.h
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:79
Iohb::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iohb_DatabaseIO.h:113
Iohb::DatabaseIO::streamNeedsDelete
bool streamNeedsDelete
Definition: Iohb_DatabaseIO.h:202
Iohb::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iohb_DatabaseIO.h:179
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
anonymous_namespace{Ioss_Utils.C}::data
std::vector< char > data
Definition: Ioss_Utils.C:78
Iohb::Format
Format
Definition: Iohb_DatabaseIO.h:74
Iohb::DatabaseIO::legend_
Layout * legend_
Definition: Iohb_DatabaseIO.h:190
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iohb::Layout
Definition: Iohb_Layout.h:42