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 IOSS_Iopg_DatabaseIO_h
34 #define IOSS_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 void read_region();
114 void read_communication_metadata();
115
116 void get_nodeblocks();
117 void get_elemblocks();
118 void get_nodesets();
119 void get_sidesets();
120 void get_commsets();
121
122 int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect,
123 size_t data_size) const;
124 int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact,
125 size_t data_size) const;
126
127 const Ioss::Map &get_node_map() const;
128 const Ioss::Map &get_element_map() const;
129
130 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
131 size_t data_size) const override;
132 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
133 size_t data_size) const override;
134 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
135 size_t data_size) const override
136 {
137 return 0;
138 }
139 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
140 size_t data_size) const override
141 {
142 return 0;
143 }
144 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
145 size_t data_size) const override;
146 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
147 size_t data_size) const override;
148 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
149 size_t data_size) const override;
150 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
151 size_t data_size) const override
152 {
153 return 0;
154 }
155 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
156 size_t data_size) const override
157 {
158 return 0;
159 }
160 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
161 size_t data_size) const override
162 {
163 return 0;
164 }
165 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
166 size_t data_size) const override;
167 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
168 size_t data_size) const override;
169
170 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
171 void *data, size_t data_size) const override
172 {
173 return 0;
174 }
175
176 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
177 size_t data_size) const override;
178 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
179 size_t data_size) const override;
180 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
181 size_t data_size) const override
182 {
183 return 0;
184 }
185 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
186 size_t data_size) const override
187 {
188 return 0;
189 }
190 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
191 size_t data_size) const override;
192 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
193 size_t data_size) const override;
194 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
195 size_t data_size) const override;
196 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
197 size_t data_size) const override
198 {
199 return 0;
200 }
201 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
202 size_t data_size) const override
203 {
204 return 0;
205 }
206 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
207 size_t data_size) const override
208 {
209 return 0;
210 }
211 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
212 size_t data_size) const override;
213 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
214 size_t data_size) const override;
215 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
216 void *data, size_t data_size) const override
217 {
218 return 0;
219 }
220
221 std::string databaseTitle;
222
223 int spatialDimension{3};
224
225 int nodeBlockCount{0};
226 int elementBlockCount{0};
227 int nodesetCount{0};
228 int sidesetCount{0};
229
230 // Communication Set Data
231 Ioss::IntVector nodeCmapIds;
232 Ioss::IntVector nodeCmapNodeCnts;
233 Ioss::IntVector elemCmapIds;
234 Ioss::IntVector elemCmapElemCnts;
235 int commsetNodeCount{0};
236 int commsetElemCount{0};
237 };
238 } // namespace Iopg
239 #endif // IOSS_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:170
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:160
Iopg::DatabaseIO::compute_block_membership
void compute_block_membership(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
Definition: Iopg_DatabaseIO.C:1561
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:66
Iopg::DatabaseIO::get_node_map
const Ioss::Map & get_node_map() const
Definition: Iopg_DatabaseIO.C:1513
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
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:134
Iopg::DatabaseIO::get_nodesets
void get_nodesets()
Definition: Iopg_DatabaseIO.C:573
Iopg::DatabaseIO::commsetElemCount
int commsetElemCount
Definition: Iopg_DatabaseIO.h:236
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::end__
bool end__(Ioss::State state) override
Definition: Iopg_DatabaseIO.C:967
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
Iopg::IOFactory::IOFactory
IOFactory()
Definition: Iopg_DatabaseIO.C:115
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Iopg::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iopg_DatabaseIO.h:227
Ioss_Map.h
Iopg::DatabaseIO::get_side_connectivity
int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect, size_t data_size) const
Definition: Iopg_DatabaseIO.C:1601
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:215
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:185
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:43
Iopg::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
Iopg::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iopg_DatabaseIO.h:228
Iopg::DatabaseIO::nodeCmapIds
Ioss::IntVector nodeCmapIds
Definition: Iopg_DatabaseIO.h:231
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:201
Iopg::DatabaseIO::get_elemblocks
void get_elemblocks()
Definition: Iopg_DatabaseIO.C:447
Ioss_DatabaseIO.h
Iopg::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iopg_DatabaseIO.C:965
Ioss::State
State
Access states for a database.
Definition: Ioss_State.h:42
Iopg::DatabaseIO::get_sidesets
void get_sidesets()
Definition: Iopg_DatabaseIO.C:679
Iopg::DatabaseIO::elemCmapElemCnts
Ioss::IntVector elemCmapElemCnts
Definition: Iopg_DatabaseIO.h:234
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:225
Ioss::DatabaseIO::DatabaseIO
DatabaseIO()=delete
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:103
Ioss::DatabaseIO::properties
Ioss::PropertyManager properties
Definition: Ioss_DatabaseIO.h:574
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:223
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:206
Iopg::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Definition: Iopg_DatabaseIO.C:1537
Iopg::DatabaseIO::nodeCmapNodeCnts
Ioss::IntVector nodeCmapNodeCnts
Definition: Iopg_DatabaseIO.h:232
Iopg::DatabaseIO::read_region
void read_region()
Definition: Iopg_DatabaseIO.C:274
Iopg::DatabaseIO::read_communication_metadata
void read_communication_metadata()
Definition: Iopg_DatabaseIO.C:328
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iopg::IOFactory::factory
static const IOFactory * factory()
Definition: Iopg_DatabaseIO.C:109
Iopg::IOFactory
Definition: Iopg_DatabaseIO.h:70
Iopg::IOFactory::make_IO
Ioss::DatabaseIO * make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage, MPI_Comm communicator, const Ioss::PropertyManager &properties) const
Definition: Iopg_DatabaseIO.C:117
Iopg::DatabaseIO::get_side_distributions
int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact, size_t data_size) const
Definition: Iopg_DatabaseIO.C:1687
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:155
Iopg::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: Iopg_DatabaseIO.C:1087
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
Iopg::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iopg_DatabaseIO.C:434
Iopg::DatabaseIO::get_commsets
void get_commsets()
Definition: Iopg_DatabaseIO.C:617
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:139
Iopg::DatabaseIO::~DatabaseIO
~DatabaseIO()
Definition: Iopg_DatabaseIO.C:140
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:150
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:59
Iopg::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iopg_DatabaseIO.C:184
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iopg::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: Iopg_DatabaseIO.C:1461
Ioss_IOFactory.h
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:88
Ioss::NODESET
Definition: Ioss_EntityType.h:44
Iopg::DatabaseIO::elemCmapIds
Ioss::IntVector elemCmapIds
Definition: Iopg_DatabaseIO.h:233
Iopg::DatabaseIO::databaseTitle
std::string databaseTitle
Definition: Iopg_DatabaseIO.h:221
Iopg::DatabaseIO::commsetNodeCount
int commsetNodeCount
Definition: Iopg_DatabaseIO.h:235
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
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:180
Iopg::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iopg_DatabaseIO.h:226
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:196
Iopg::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iopg_DatabaseIO.h:94