IOSS 2.0

Iopg_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 SIERRA_Iopg_DatabaseIO_h
34 #define SIERRA_Iopg_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 <stddef.h> // for size_t
43 #include <stdint.h> // for int64_t
44 #include <string> // for string
45 #include <vector> // for vector
46
47 namespace Ioss {
48 class CommSet;
49 class EdgeBlock;
50 class EdgeSet;
51 class ElementBlock;
52 class ElementSet;
53 class EntityBlock;
54 class FaceBlock;
55 class FaceSet;
56 class Field;
57 class GroupingEntity;
58 class NodeBlock;
59 class NodeSet;
60 class PropertyManager;
61 class Region;
62 class SideBlock;
63 class SideSet;
64 class StructuredBlock;
65 } // namespace Ioss
66
67 /** \brief A namespace for the pamgen database format.
68 */
69 namespace Iopg {
70 class IOFactory : public Ioss::IOFactory
71 {
72 public:
73 static const IOFactory *factory();
74
75 private:
76 IOFactory();
77 Ioss::DatabaseIO *make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage,
78 MPI_Comm communicator, const Ioss::PropertyManager &properties) const;
79 };
80
81 class DatabaseIO : public Ioss::DatabaseIO
82 {
83 public:
84 DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage,
85 MPI_Comm communicator, const Ioss::PropertyManager &properties);
86 DatabaseIO(const DatabaseIO &from) = delete;
87 DatabaseIO &operator=(const DatabaseIO &from) = delete;
88 ~DatabaseIO();
89
90 // Check capabilities of input/output database... Returns an
91 // unsigned int with the supported Ioss::EntityTypes or'ed
92 // together. If "return_value & Ioss::EntityType" is set, then the
93 // database supports that type (e.g. return_value & Ioss::FACESET)
94 unsigned entity_field_support() const override
95 {
96 return Ioss::NODEBLOCK | Ioss::ELEMENTBLOCK | Ioss::NODESET | Ioss::SIDESET | Ioss::REGION;
97 }
98
99 int int_byte_size_db() const override { return 4; }
100
101 std::string title() const { return databaseTitle; }
102 int maximum_symbol_length() const override { return 32; }
103
104 void compute_block_membership(Ioss::SideBlock * efblock,
105 std::vector<std::string> &block_membership) const;
106
107 private:
108 void read_meta_data__() override;
109
110 bool begin__(Ioss::State state) override;
111 bool end__(Ioss::State state) override;
112
113 bool begin_state__(Ioss::Region *region, int state, double time) override;
114 bool end_state__(Ioss::Region *region, int state, double time) override;
115
116 void read_region();
117 void read_communication_metadata();
118
119 void get_nodeblocks();
120 void get_elemblocks();
121 void get_nodesets();
122 void get_sidesets();
123 void get_commsets();
124
125 int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect,
126 size_t data_size) const;
127 int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact,
128 size_t data_size) const;
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 {
140 return 0;
141 }
142 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
143 size_t data_size) const override
144 {
145 return 0;
146 }
147 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
148 size_t data_size) const override;
149 int64_t get_field_internal(const Ioss::SideBlock *fb, 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 {
156 return 0;
157 }
158 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
159 size_t data_size) const override
160 {
161 return 0;
162 }
163 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
164 size_t data_size) const override
165 {
166 return 0;
167 }
168 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172
173 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
174 void *data, size_t data_size) const override
175 {
176 return 0;
177 }
178
179 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
180 size_t data_size) const override;
181 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
182 size_t data_size) const override;
183 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
184 size_t data_size) const override
185 {
186 return 0;
187 }
188 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
189 size_t data_size) const override
190 {
191 return 0;
192 }
193 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
194 size_t data_size) const override;
195 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
196 size_t data_size) const override;
197 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
198 size_t data_size) const override;
199 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
200 size_t data_size) const override
201 {
202 return 0;
203 }
204 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
205 size_t data_size) const override
206 {
207 return 0;
208 }
209 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
210 size_t data_size) const override
211 {
212 return 0;
213 }
214 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
215 size_t data_size) const override;
216 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
217 size_t data_size) const override;
218 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
219 void *data, size_t data_size) const override
220 {
221 return 0;
222 }
223
224 std::string databaseTitle;
225
226 int spatialDimension;
227
228 int nodeBlockCount;
229 int elementBlockCount;
230 int nodesetCount;
231 int sidesetCount;
232
233 // Communication Set Data
234 Ioss::IntVector nodeCmapIds;
235 Ioss::IntVector nodeCmapNodeCnts;
236 Ioss::IntVector elemCmapIds;
237 Ioss::IntVector elemCmapElemCnts;
238 int commsetNodeCount;
239 int commsetElemCount;
240 };
241 } // namespace Iopg
242 #endif // SIERRA_Iopg_DatabaseIO_h
Ioss::REGION
Definition: Ioss_EntityType.h:52
Ioss_CodeTypes.h
Iopg::DatabaseIO::title
std::string title() const
Definition: Iopg_DatabaseIO.h:101
Iopg
A namespace for the pamgen database format.
Definition: Iopg_DatabaseIO.C:58
Ioss::SIDESET
Definition: Ioss_EntityType.h:48
Iopg::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: Iopg_DatabaseIO.h:173
Iopg::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:163
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
Iopg::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:137
Iopg::DatabaseIO::commsetElemCount
int commsetElemCount
Definition: Iopg_DatabaseIO.h:239
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::ELEMENTBLOCK
Definition: Ioss_EntityType.h:43
Iopg::DatabaseIO::maximum_symbol_length
int maximum_symbol_length() const override
Get the length of the longest name in the database file.
Definition: Iopg_DatabaseIO.h:102
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Iopg::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iopg_DatabaseIO.h:230
Ioss_Map.h
Iopg::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: Iopg_DatabaseIO.h:218
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
Iopg::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:188
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:42
Iopg::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iopg_DatabaseIO.h:231
Iopg::DatabaseIO::nodeCmapIds
Ioss::IntVector nodeCmapIds
Definition: Iopg_DatabaseIO.h:234
Iopg::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:204
Ioss_DatabaseIO.h
Ioss::State
State
Access states for a database.
Definition: Ioss_State.h:42
Iopg::DatabaseIO::elemCmapElemCnts
Ioss::IntVector elemCmapElemCnts
Definition: Iopg_DatabaseIO.h:237
Ioss::IOFactory
The main public user interface for creating Ioss::DatabaseIO objects.
Definition: Ioss_IOFactory.h:58
Iopg::DatabaseIO::nodeBlockCount
int nodeBlockCount
Definition: Iopg_DatabaseIO.h:228
Ioss_State.h
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Iopg::DatabaseIO
Definition: Iopg_DatabaseIO.h:81
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
Iopg::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iopg_DatabaseIO.h:226
Iopg::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:209
Iopg::DatabaseIO::nodeCmapNodeCnts
Ioss::IntVector nodeCmapNodeCnts
Definition: Iopg_DatabaseIO.h:235
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iopg::IOFactory
Definition: Iopg_DatabaseIO.h:70
Ioss::NODEBLOCK
Definition: Ioss_EntityType.h:40
Ioss::Map
Definition: Ioss_Map.h:52
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iopg::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:158
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
Iopg::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:142
Iopg::DatabaseIO::get_field_internal
int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:153
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:59
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Ioss_IOFactory.h
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:79
Ioss::NODESET
Definition: Ioss_EntityType.h:44
Iopg::DatabaseIO::elemCmapIds
Ioss::IntVector elemCmapIds
Definition: Iopg_DatabaseIO.h:236
Iopg::DatabaseIO::databaseTitle
std::string databaseTitle
Definition: Iopg_DatabaseIO.h:224
Iopg::DatabaseIO::commsetNodeCount
int commsetNodeCount
Definition: Iopg_DatabaseIO.h:238
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iopg::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iopg_DatabaseIO.h:99
anonymous_namespace{Ioss_Utils.C}::data
std::vector< char > data
Definition: Ioss_Utils.C:78
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iopg::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:183
Iopg::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iopg_DatabaseIO.h:229
Iopg::DatabaseIO::put_field_internal
int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data, size_t data_size) const override
Definition: Iopg_DatabaseIO.h:199
Iopg::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iopg_DatabaseIO.h:94