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 const std::string get_format() const override {return "Generated";}
100
101 // Check capabilities of input/output database... Returns an
102 // unsigned int with the supported Ioss::EntityTypes or'ed
103 // together. If "return_value & Ioss::EntityType" is set, then the
104 // database supports that type (e.g. return_value & Ioss::FACESET)
105 unsigned entity_field_support() const override;
106
107 int int_byte_size_db() const override { return int_byte_size_api(); }
108
109 const GeneratedMesh *get_generated_mesh() const { return m_generatedMesh; }
110
111 void setGeneratedMesh(Iogn::GeneratedMesh *generatedMesh) { m_generatedMesh = generatedMesh; }
112
113 const std::vector<std::string> &get_sideset_names() const { return m_sideset_names; }
114
115 private:
116 void read_meta_data__() override;
117
118 bool begin__(Ioss::State state) override;
119 bool end__(Ioss::State state) override;
120
121 bool begin_state__(int state, double time) override;
122
123 void get_step_times__() override;
124 void get_nodeblocks();
125 void get_elemblocks();
126 void get_nodesets();
127 void get_sidesets();
128 void get_commsets();
129
130 const Ioss::Map &get_node_map() const;
131 const Ioss::Map &get_element_map() const;
132
133 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
134 size_t data_size) const override;
135 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
136 size_t data_size) const override;
137 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
138 size_t data_size) const override;
139 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
140 size_t data_size) const override;
141 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
142 size_t data_size) const override;
143 int64_t get_field_internal(const Ioss::StructuredBlock * /* sb */,
144 const Ioss::Field & /* field */, void * /* data */,
145 size_t /* data_size */) const override
146 {
147 return -1;
148 }
149 int64_t get_field_internal(const Ioss::SideBlock *ef_blk, const Ioss::Field &field, void *data,
150 size_t data_size) const override;
151 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
152 size_t data_size) const override;
153 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
154 size_t data_size) const override;
155 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
156 size_t data_size) const override;
157 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
158 size_t data_size) const override;
159 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
160 size_t data_size) const override;
161 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
162 size_t data_size) const override;
163
164 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
165 size_t data_size) const override;
166 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
167 size_t data_size) const override;
168 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
173 size_t data_size) const override;
174 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
175 size_t data_size) const override;
176 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
177 size_t data_size) const override;
178 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
179 size_t data_size) const override;
180 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
181 size_t data_size) const override;
182 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
183 size_t data_size) const override;
184 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
185 size_t data_size) const override;
186 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
187 size_t data_size) const override;
188 int64_t put_field_internal(const Ioss::StructuredBlock * /* sb */,
189 const Ioss::Field & /* field */, void * /* data */,
190 size_t /* data_size */) const override
191 {
192 return -1;
193 }
194
195 void add_transient_fields(Ioss::GroupingEntity *entity);
196
197 GeneratedMesh * m_generatedMesh{nullptr};
198 std::vector<std::string> m_sideset_names;
199
200 double currentTime{0.0};
201 int spatialDimension{3};
202
203 int elementBlockCount{0};
204 int nodesetCount{0};
205 int sidesetCount{0};
206
207 bool m_useVariableDf{true};
208 };
209 } // namespace Iogn
210 #endif // IOSS_Iogn_DatabaseIO_h
Iogn::DatabaseIO::get_sideset_names
const std::vector< std::string > & get_sideset_names() const
Definition: Iogn_DatabaseIO.h:113
Ioss_DBUsage.h
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iogn::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iogn_DatabaseIO.C:212
Iogn::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::StructuredBlock *, const Ioss::Field &, void *, size_t) const override
Definition: Iogn_DatabaseIO.h:143
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:126
Ioss_Map.h
Iogn::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iogn_DatabaseIO.h:204
Iogn::DatabaseIO::get_sidesets
void get_sidesets()
Definition: Iogn_DatabaseIO.C:776
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:267
Iogn::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iogn_DatabaseIO.h:201
Iogn::DatabaseIO::~DatabaseIO
~DatabaseIO() override
Definition: Iogn_DatabaseIO.C:152
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
Iogn::DatabaseIO
Definition: Iogn_DatabaseIO.h:89
Iogn::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iogn_DatabaseIO.C:154
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
Iogn::DatabaseIO::get_format
const std::string get_format() const override
Definition: Iogn_DatabaseIO.h:99
Iogn::DatabaseIO::get_step_times__
void get_step_times__() override
Definition: Iogn_DatabaseIO.C:705
Iogn::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iogn_DatabaseIO.C:695
Ioss::NodeSet
A collection of nodes.
Definition: Ioss_NodeSet.h:53
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
Iogn::IOFactory::factory
static const IOFactory * factory()
Definition: Iogn_DatabaseIO.C:118
Iogn::DatabaseIO::setGeneratedMesh
void setGeneratedMesh(Iogn::GeneratedMesh *generatedMesh)
Definition: Iogn_DatabaseIO.h:111
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
Iogn::DatabaseIO::get_elemblocks
void get_elemblocks()
Definition: Iogn_DatabaseIO.C:713
Iogn::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iogn_DatabaseIO.C:852
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iogn::DatabaseIO::get_node_map
const Ioss::Map & get_node_map() const
Definition: Iogn_DatabaseIO.C:669
Iogn::DatabaseIO::m_sideset_names
std::vector< std::string > m_sideset_names
Definition: Iogn_DatabaseIO.h:198
Ioss::FaceBlock
A collection of element faces with the same topology.
Definition: Ioss_FaceBlock.h:53
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
Ioss::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Iogn::DatabaseIO::add_transient_fields
void add_transient_fields(Ioss::GroupingEntity *entity)
Definition: Iogn_DatabaseIO.C:857
Iogn::DatabaseIO::currentTime
double currentTime
Definition: Iogn_DatabaseIO.h:200
Ioss_State.h
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:59
Iogn::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iogn_DatabaseIO.h:107
Iogn::DatabaseIO::m_useVariableDf
bool m_useVariableDf
Definition: Iogn_DatabaseIO.h:207
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:596
Iogn::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Definition: Iogn_DatabaseIO.C:682
Iogn::GeneratedMesh
Definition: Iogn_GeneratedMesh.h:49
Iogn::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iogn_DatabaseIO.C:214
Iogn::IOFactory
Definition: Iogn_DatabaseIO.h:77
Iogn
A namespace for the generated database format.
Definition: Iogn_DashSurfaceMesh.C:38
Iogn::IOFactory::IOFactory
IOFactory()
Definition: Iogn_DatabaseIO.C:124
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
Iogn::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iogn_DatabaseIO.h:203
Ioss::Map
Definition: Ioss_Map.h:52
Iogn::DatabaseIO::get_commsets
void get_commsets()
Definition: Iogn_DatabaseIO.C:838
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:74
Iogn::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::StructuredBlock *, const Ioss::Field &, void *, size_t) const override
Definition: Iogn_DatabaseIO.h:188
Iogn::DatabaseIO::get_nodesets
void get_nodesets()
Definition: Iogn_DatabaseIO.C:749
Iogn::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iogn_DatabaseIO.h:205
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iogn::DatabaseIO::begin_state__
bool begin_state__(int state, double time) override
Definition: Iogn_DatabaseIO.C:216
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:96
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:53
Ioss::GroupingEntity
Base class for all 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:93
Ioss_CodeTypes.h
Iogn::DatabaseIO::m_generatedMesh
GeneratedMesh * m_generatedMesh
Definition: Iogn_DatabaseIO.h:197
Ioss_DatabaseIO.h
Iogn::DatabaseIO::get_generated_mesh
const GeneratedMesh * get_generated_mesh() const
Definition: Iogn_DatabaseIO.h:109
Iogn::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete