IOSS 2.0

Iogn_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_Iogn_DatabaseIO_h
34 #define IOSS_Iogn_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 <Ioss_Map.h> // for Map
42 #include <cstddef> // for size_t
43 #include <cstdint> // for int64_t
44 #include <string> // for string
45 #include <vector> // for vector
46
47 namespace Iogn {
48 class GeneratedMesh;
49 } // namespace Iogn
50 namespace Ioss {
51 class CommSet;
52 class EdgeBlock;
53 class EdgeSet;
54 class ElementBlock;
55 class ElementSet;
56 class FaceBlock;
57 class FaceSet;
58 class Field;
59 class GroupingEntity;
60 class NodeBlock;
61 class NodeSet;
62 class PropertyManager;
63 class Region;
64 class SideBlock;
65 class SideSet;
66 class StructuredBlock;
67 } // namespace Ioss
68
69 namespace Ioss {
70 class EntityBlock;
71 } // namespace Ioss
72
73 /** \brief A namespace for the generated database format.
74 */
75 namespace Iogn {
76
77 class IOFactory : public Ioss::IOFactory
78 {
79 public:
80 static const IOFactory *factory();
81
82 private:
83 IOFactory();
84 Ioss::DatabaseIO *make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage,
85 MPI_Comm communicator,
86 const Ioss::PropertyManager &props) const override;
87 };
88
89 class DatabaseIO : public Ioss::DatabaseIO
90 {
91 public:
92 DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage,
93 MPI_Comm communicator, const Ioss::PropertyManager &props);
94 DatabaseIO(const DatabaseIO &from) = delete;
95 DatabaseIO &operator=(const DatabaseIO &from) = delete;
96
97 ~DatabaseIO() override;
98
99 // Check capabilities of input/output database... Returns an
100 // unsigned int with the supported Ioss::EntityTypes or'ed
101 // together. If "return_value & Ioss::EntityType" is set, then the
102 // database supports that type (e.g. return_value & Ioss::FACESET)
103 unsigned entity_field_support() const override;
104
105 int int_byte_size_db() const override { return int_byte_size_api(); }
106
107 const GeneratedMesh *get_generated_mesh() const { return m_generatedMesh; }
108
109 void setGeneratedMesh(Iogn::GeneratedMesh *generatedMesh) { m_generatedMesh = generatedMesh; }
110
111 const std::vector<std::string> &get_sideset_names() const { return m_sideset_names; }
112
113 private:
114 void read_meta_data__() override;
115
116 bool begin__(Ioss::State state) override;
117 bool end__(Ioss::State state) override;
118
119 bool begin_state__(Ioss::Region *region, int state, double time) override;
120 bool end_state__(Ioss::Region *region, int state, double time) override;
121
122 void get_step_times__() override;
123 void get_nodeblocks();
124 void get_elemblocks();
125 void get_nodesets();
126 void get_sidesets();
127 void get_commsets();
128
129 const Ioss::Map &get_node_map() const;
130 const Ioss::Map &get_element_map() const;
131
132 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
133 size_t data_size) const override;
134 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
135 size_t data_size) const override;
136 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
137 size_t data_size) const override;
138 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
139 size_t data_size) const override;
140 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
141 size_t data_size) const override;
142 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
143 void *data, size_t data_size) const override
144 {
145 return -1;
146 }
147 int64_t get_field_internal(const Ioss::SideBlock *ef_blk, const Ioss::Field &field, void *data,
148 size_t data_size) const override;
149 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
150 size_t data_size) const override;
151 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
152 size_t data_size) const override;
153 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
154 size_t data_size) const override;
155 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
156 size_t data_size) const override;
157 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
158 size_t data_size) const override;
159 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
160 size_t data_size) const override;
161
162 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
163 size_t data_size) const override;
164 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
165 size_t data_size) const override;
166 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
167 size_t data_size) const override;
168 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
173 size_t data_size) const override;
174 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
175 size_t data_size) const override;
176 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
177 size_t data_size) const override;
178 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
179 size_t data_size) const override;
180 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
181 size_t data_size) const override;
182 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
183 size_t data_size) const override;
184 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
185 size_t data_size) const override;
186 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
187 void *data, size_t data_size) const override
188 {
189 return -1;
190 }
191
192 void add_transient_fields(Ioss::GroupingEntity *entity);
193
194 GeneratedMesh * m_generatedMesh{nullptr};
195 std::vector<std::string> m_sideset_names;
196
197 double currentTime{0.0};
198 int spatialDimension{3};
199
200 int elementBlockCount{0};
201 int nodesetCount{0};
202 int sidesetCount{0};
203
204 bool m_useVariableDf{true};
205 };
206 } // namespace Iogn
207 #endif // IOSS_Iogn_DatabaseIO_h
Ioss_CodeTypes.h
Iogn::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iogn_DatabaseIO.h:105
Iogn::DatabaseIO::get_sidesets
void get_sidesets()
Definition: Iogn_DatabaseIO.C:776
Iogn::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iogn_DatabaseIO.h:202
Iogn::DatabaseIO::get_generated_mesh
const GeneratedMesh * get_generated_mesh() const
Definition: Iogn_DatabaseIO.h:107
Iogn::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iogn_DatabaseIO.C:595
Iogn::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iogn_DatabaseIO.C:694
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
Iogn::DatabaseIO::~DatabaseIO
~DatabaseIO() override
Definition: Iogn_DatabaseIO.C:169
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
Ioss::FaceSet
A collection of element faces.
Definition: Ioss_FaceSet.h:54
Ioss::GroupingEntity
Base class for all &#39;grouping&#39; entities. The following derived classes are typical: ...
Definition: Ioss_GroupingEntity.h:93
Iogn::IOFactory::factory
static const IOFactory * factory()
Definition: Iogn_DatabaseIO.C:135
Iogn::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iogn_DatabaseIO.C:213
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Iogn::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: Iogn_DatabaseIO.C:273
Ioss_Map.h
Iogn::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iogn_DatabaseIO.h:200
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
Iogn::DatabaseIO::get_node_map
const Ioss::Map & get_node_map() const
Definition: Iogn_DatabaseIO.C:668
Iogn::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iogn_DatabaseIO.C:852
Iogn::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iogn_DatabaseIO.C:215
Iogn::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iogn_DatabaseIO.h:198
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::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Ioss_State.h
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Iogn::DatabaseIO::m_generatedMesh
GeneratedMesh * m_generatedMesh
Definition: Iogn_DatabaseIO.h:194
Iogn::DatabaseIO::currentTime
double currentTime
Definition: Iogn_DatabaseIO.h:197
Iogn::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
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:225
Iogn::GeneratedMesh
Definition: Iogn_GeneratedMesh.h:49
Ioss::ElementSet
A collection of elements.
Definition: Ioss_ElementSet.h:54
Iogn::DatabaseIO::add_transient_fields
void add_transient_fields(Ioss::GroupingEntity *entity)
Definition: Iogn_DatabaseIO.C:857
Ioss::DatabaseUsage
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition: Ioss_DBUsage.h:40
Iogn::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Definition: Iogn_DatabaseIO.C:681
Iogn::DatabaseIO::setGeneratedMesh
void setGeneratedMesh(Iogn::GeneratedMesh *generatedMesh)
Definition: Iogn_DatabaseIO.h:109
Iogn::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iogn_DatabaseIO.C:171
Iogn
A namespace for the generated database format.
Definition: Iogn_DashSurfaceMesh.C:38
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iogn::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iogn_DatabaseIO.h:201
Iogn::DatabaseIO::get_nodesets
void get_nodesets()
Definition: Iogn_DatabaseIO.C:749
Iogn::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: Iogn_DatabaseIO.h:142
Ioss::Map
Definition: Ioss_Map.h:52
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iogn::IOFactory
Definition: Iogn_DatabaseIO.h:77
Iogn::DatabaseIO::get_step_times__
void get_step_times__() override
Definition: Iogn_DatabaseIO.C:704
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
Iogn::DatabaseIO::m_useVariableDf
bool m_useVariableDf
Definition: Iogn_DatabaseIO.h:204
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:59
Iogn::IOFactory::IOFactory
IOFactory()
Definition: Iogn_DatabaseIO.C:141
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iogn::DatabaseIO::begin_state__
bool begin_state__(Ioss::Region *region, int state, double time) override
Definition: Iogn_DatabaseIO.C:217
Ioss_IOFactory.h
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:80
Iogn::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: Iogn_DatabaseIO.C:143
Iogn::DatabaseIO::get_commsets
void get_commsets()
Definition: Iogn_DatabaseIO.C:838
Iogn::DatabaseIO
Definition: Iogn_DatabaseIO.h:89
Iogn::DatabaseIO::m_sideset_names
std::vector< std::string > m_sideset_names
Definition: Iogn_DatabaseIO.h:195
Iogn::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: Iogn_DatabaseIO.h:186
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iogn::DatabaseIO::get_sideset_names
const std::vector< std::string > & get_sideset_names() const
Definition: Iogn_DatabaseIO.h:111
Iogn::DatabaseIO::end_state__
bool end_state__(Ioss::Region *region, int state, double time) override
Definition: Iogn_DatabaseIO.C:223
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iogn::DatabaseIO::get_elemblocks
void get_elemblocks()
Definition: Iogn_DatabaseIO.C:712