IOSS 2.0

Iogs_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_Iogs_DatabaseIO_h
34 #define IOSS_Iogs_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 Iogs {
48 class GeneratedMesh;
49 } // namespace Iogs
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 gen_struc database format.
74 */
75 namespace Iogs {
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_gen_struc_mesh() const { return m_generatedMesh; }
108
109 void setGeneratedMesh(Iogs::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__(int state, double time) override;
120
121 void get_step_times__() override;
122 void get_nodeblocks();
123 void get_structured_blocks();
124 void get_nodesets();
125 void get_sidesets();
126 void get_commsets();
127
128 const Ioss::Map &get_node_map() const;
129 const Ioss::Map &get_element_map() const;
130
131 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
132 size_t data_size) const override;
133 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
134 size_t data_size) const override;
135 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
136 size_t data_size) const override;
137 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
138 size_t data_size) const override;
139 int64_t get_field_internal(const Ioss::ElementBlock * /* eb */, const Ioss::Field & /* field */,
140 void * /* data */, size_t /* data_size */) const override
141 {
142 return -1;
143 }
144
145 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
146 void *data, size_t data_size) const override;
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 */,
187 const Ioss::Field & /* field */, void * /* data */,
188 size_t /* data_size */) const override
189 {
190 return -1;
191 }
192
193 void add_transient_fields(Ioss::GroupingEntity *entity);
194
195 GeneratedMesh * m_generatedMesh{nullptr};
196 std::vector<std::string> m_sideset_names;
197
198 double currentTime{0.0};
199 int spatialDimension{3};
200
201 int elementBlockCount{0};
202 int nodesetCount{0};
203 int sidesetCount{0};
204
205 bool m_useVariableDf{true};
206 };
207 } // namespace Iogs
208 #endif // IOSS_Iogs_DatabaseIO_h
Iogs::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iogs_DatabaseIO.h:199
Ioss_CodeTypes.h
Iogs::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::ElementBlock *, const Ioss::Field &, void *, size_t) const override
Definition: Iogs_DatabaseIO.h:139
Iogs::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iogs_DatabaseIO.h:203
Iogs::DatabaseIO::get_commsets
void get_commsets()
Iogs::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: Iogs_DatabaseIO.C:535
Iogs::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iogs_DatabaseIO.C:173
Iogs::DatabaseIO::~DatabaseIO
~DatabaseIO() override
Definition: Iogs_DatabaseIO.C:171
Iogs::DatabaseIO::get_structured_blocks
void get_structured_blocks()
Definition: Iogs_DatabaseIO.C:652
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
Iogs::DatabaseIO::setGeneratedMesh
void setGeneratedMesh(Iogs::GeneratedMesh *generatedMesh)
Definition: Iogs_DatabaseIO.h:109
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 'grouping' entities. The following derived classes are typical:
Definition: Ioss_GroupingEntity.h:93
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Iogs::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iogs_DatabaseIO.h:202
Ioss_Map.h
Iogs::DatabaseIO::begin_state__
bool begin_state__(int state, double time) override
Definition: Iogs_DatabaseIO.C:214
Iogs::DatabaseIO::m_generatedMesh
GeneratedMesh * m_generatedMesh
Definition: Iogs_DatabaseIO.h:195
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
Iogs
A namespace for the gen_struc database format.
Definition: Iogs_DatabaseIO.C:129
Iogs::IOFactory
Definition: Iogs_DatabaseIO.h:77
Iogs::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iogs_DatabaseIO.h:105
Ioss_DatabaseIO.h
Iogs::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::StructuredBlock *, const Ioss::Field &, void *, size_t) const override
Definition: Iogs_DatabaseIO.h:186
Ioss::State
State
Access states for a database.
Definition: Ioss_State.h:42
Iogs::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: Iogs_DatabaseIO.C:265
Ioss::IOFactory
The main public user interface for creating Ioss::DatabaseIO objects.
Definition: Ioss_IOFactory.h:58
Iogs::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iogs_DatabaseIO.C:210
Ioss::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Ioss_State.h
Iogs::IOFactory::IOFactory
IOFactory()
Definition: Iogs_DatabaseIO.C:138
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
Iogs::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iogs_DatabaseIO.h:201
Ioss::DatabaseUsage
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition: Ioss_DBUsage.h:40
Iogs::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iogs_DatabaseIO.C:212
Iogs::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: Iogs_DatabaseIO.C:140
Iogs::DatabaseIO::add_transient_fields
void add_transient_fields(Ioss::GroupingEntity *entity)
Definition: Iogs_DatabaseIO.C:736
Iogs::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iogs::DatabaseIO::get_step_times__
void get_step_times__() override
Definition: Iogs_DatabaseIO.C:644
Iogs::GeneratedMesh
Definition: Iogs_GeneratedMesh.h:49
Iogs::DatabaseIO::get_sidesets
void get_sidesets()
Definition: Iogs_DatabaseIO.C:669
Iogs::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iogs_DatabaseIO.C:634
Ioss::Map
Definition: Ioss_Map.h:52
Iogs::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iogs_DatabaseIO.C:731
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iogs::DatabaseIO::m_sideset_names
std::vector< std::string > m_sideset_names
Definition: Iogs_DatabaseIO.h:196
Iogs::DatabaseIO::get_nodesets
void get_nodesets()
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
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:59
Iogs::DatabaseIO
Definition: Iogs_DatabaseIO.h:89
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iogs::DatabaseIO::get_gen_struc_mesh
const GeneratedMesh * get_gen_struc_mesh() const
Definition: Iogs_DatabaseIO.h:107
Ioss_IOFactory.h
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:88
Iogs::DatabaseIO::get_node_map
const Ioss::Map & get_node_map() const
Definition: Iogs_DatabaseIO.C:608
Iogs::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Definition: Iogs_DatabaseIO.C:621
Iogs::DatabaseIO::get_sideset_names
const std::vector< std::string > & get_sideset_names() const
Definition: Iogs_DatabaseIO.h:111
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iogs::DatabaseIO::currentTime
double currentTime
Definition: Iogs_DatabaseIO.h:198
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iogs::IOFactory::factory
static const IOFactory * factory()
Definition: Iogs_DatabaseIO.C:132
Iogs::DatabaseIO::m_useVariableDf
bool m_useVariableDf
Definition: Iogs_DatabaseIO.h:205