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 const std::string get_format() const override { return "PamGen"; }
91
92 // Check capabilities of input/output database... Returns an
93 // unsigned int with the supported Ioss::EntityTypes or'ed
94 // together. If "return_value & Ioss::EntityType" is set, then the
95 // database supports that type (e.g. return_value & Ioss::FACESET)
96 unsigned entity_field_support() const override
97 {
98 return Ioss::NODEBLOCK | Ioss::ELEMENTBLOCK | Ioss::NODESET | Ioss::SIDESET | Ioss::REGION;
99 }
100
101 int int_byte_size_db() const override { return 4; }
102
103 std::string title() const { return databaseTitle; }
104 int maximum_symbol_length() const override { return 32; }
105
106 void compute_block_membership__(Ioss::SideBlock * efblock,
107 std::vector<std::string> &block_membership) const override;
108
109 private:
110 void read_meta_data__() override;
111
112 bool begin__(Ioss::State state) override;
113 bool end__(Ioss::State state) override;
114
115 void read_region();
116 void read_communication_metadata();
117
118 void get_nodeblocks();
119 void get_elemblocks();
120 void get_nodesets();
121 void get_sidesets();
122 void get_commsets();
123
124 int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect,
125 size_t data_size) const;
126 int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact,
127 size_t data_size) const;
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 {
139 return 0;
140 }
141 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
142 size_t data_size) const override
143 {
144 return 0;
145 }
146 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
147 size_t data_size) const override;
148 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
149 size_t data_size) const override;
150 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
151 size_t data_size) const override;
152 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
153 size_t data_size) const override
154 {
155 return 0;
156 }
157 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
158 size_t data_size) const override
159 {
160 return 0;
161 }
162 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
163 size_t data_size) const override
164 {
165 return 0;
166 }
167 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
168 size_t data_size) const override;
169 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
170 size_t data_size) const override;
171
172 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
173 void *data, size_t data_size) const override
174 {
175 return 0;
176 }
177
178 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
179 size_t data_size) const override;
180 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
181 size_t data_size) const override;
182 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
183 size_t data_size) const override
184 {
185 return 0;
186 }
187 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
188 size_t data_size) const override
189 {
190 return 0;
191 }
192 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
193 size_t data_size) const override;
194 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
195 size_t data_size) const override;
196 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
197 size_t data_size) const override;
198 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
199 size_t data_size) const override
200 {
201 return 0;
202 }
203 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
204 size_t data_size) const override
205 {
206 return 0;
207 }
208 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
209 size_t data_size) const override
210 {
211 return 0;
212 }
213 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
214 size_t data_size) const override;
215 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
216 size_t data_size) const override;
217 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
218 void *data, size_t data_size) const override
219 {
220 return 0;
221 }
222
223 std::string databaseTitle;
224
225 int spatialDimension{3};
226
227 int nodeBlockCount{0};
228 int elementBlockCount{0};
229 int nodesetCount{0};
230 int sidesetCount{0};
231
232 // Communication Set Data
233 Ioss::IntVector nodeCmapIds;
234 Ioss::IntVector nodeCmapNodeCnts;
235 Ioss::IntVector elemCmapIds;
236 Ioss::IntVector elemCmapElemCnts;
237 int commsetNodeCount{0};
238 int commsetElemCount{0};
239 };
240 } // namespace Iopg
241 #endif // IOSS_Iopg_DatabaseIO_h
Ioss_DBUsage.h
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iopg::DatabaseIO::int_byte_size_db
int int_byte_size_db() const override
Definition: Iopg_DatabaseIO.h:101
Iopg::DatabaseIO::get_commsets
void get_commsets()
Definition: Iopg_DatabaseIO.C:618
Ioss_Map.h
Iopg::DatabaseIO::get_elemblocks
void get_elemblocks()
Definition: Iopg_DatabaseIO.C:447
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:51
Iopg::DatabaseIO::elemCmapIds
Ioss::IntVector elemCmapIds
Definition: Iopg_DatabaseIO.h:235
Iopg::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iopg_DatabaseIO.h:229
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:182
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:172
Iopg::DatabaseIO::get_sidesets
void get_sidesets()
Definition: Iopg_DatabaseIO.C:680
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:162
Ioss::NODESET
Definition: Ioss_EntityType.h:44
Iopg::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Definition: Iopg_DatabaseIO.C:1540
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iopg::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iopg_DatabaseIO.h:96
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
Iopg::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iopg_DatabaseIO.h:225
Iopg::DatabaseIO::~DatabaseIO
~DatabaseIO()
Definition: Iopg_DatabaseIO.C:140
Iopg::DatabaseIO::nodeCmapNodeCnts
Ioss::IntVector nodeCmapNodeCnts
Definition: Iopg_DatabaseIO.h:234
Ioss::State
State
Access states for a database.
Definition: Ioss_State.h:42
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:208
Ioss::IOFactory
The main public user interface for creating Ioss::DatabaseIO objects.
Definition: Ioss_IOFactory.h:58
Iopg::DatabaseIO::get_nodesets
void get_nodesets()
Definition: Iopg_DatabaseIO.C:573
Ioss::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
Iopg::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iopg_DatabaseIO.C:968
Ioss::NodeSet
A collection of nodes.
Definition: Ioss_NodeSet.h:53
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:1690
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
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
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iopg::IOFactory::factory
static const IOFactory * factory()
Definition: Iopg_DatabaseIO.C:109
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:203
Ioss::FaceBlock
A collection of element faces with the same topology.
Definition: Ioss_FaceBlock.h:53
Iopg::DatabaseIO::read_communication_metadata
void read_communication_metadata()
Definition: Iopg_DatabaseIO.C:328
Ioss::DatabaseIO::properties
Ioss::PropertyManager properties
Definition: Ioss_DatabaseIO.h:578
Iopg::IOFactory
Definition: Iopg_DatabaseIO.h:70
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:152
Iopg::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iopg_DatabaseIO.C:434
Ioss::REGION
Definition: Ioss_EntityType.h:52
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
Ioss::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Iopg::DatabaseIO::databaseTitle
std::string databaseTitle
Definition: Iopg_DatabaseIO.h:223
Iopg::DatabaseIO::nodeCmapIds
Ioss::IntVector nodeCmapIds
Definition: Iopg_DatabaseIO.h:233
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:141
Iopg::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
Ioss_State.h
Ioss::ELEMENTBLOCK
Definition: Ioss_EntityType.h:43
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:59
Iopg
A namespace for the pamgen database format.
Definition: Iopg_DatabaseIO.C:58
Iopg::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iopg_DatabaseIO.C:184
Iopg::DatabaseIO::nodeBlockCount
int nodeBlockCount
Definition: Iopg_DatabaseIO.h:227
Ioss::NODEBLOCK
Definition: Ioss_EntityType.h:40
Iopg::DatabaseIO::commsetNodeCount
int commsetNodeCount
Definition: Iopg_DatabaseIO.h:237
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:1604
Iopg::DatabaseIO::elemCmapElemCnts
Ioss::IntVector elemCmapElemCnts
Definition: Iopg_DatabaseIO.h:236
Ioss_IOFactory.h
Iopg::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iopg_DatabaseIO.h:230
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Iopg::DatabaseIO::get_format
const std::string get_format() const override
Definition: Iopg_DatabaseIO.h:90
Iopg::DatabaseIO::get_node_map
const Ioss::Map & get_node_map() const
Definition: Iopg_DatabaseIO.C:1516
Ioss::Map
Definition: Ioss_Map.h:52
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:217
Iopg::DatabaseIO::read_region
void read_region()
Definition: Iopg_DatabaseIO.C:274
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:157
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
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:74
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:187
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:198
Iopg::DatabaseIO
Definition: Iopg_DatabaseIO.h:81
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:1088
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:1464
Iopg::DatabaseIO::compute_block_membership__
void compute_block_membership__(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const override
Definition: Iopg_DatabaseIO.C:1564
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:96
Iopg::DatabaseIO::title
std::string title() const
Definition: Iopg_DatabaseIO.h:103
Iopg::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iopg_DatabaseIO.C:966
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:104
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:53
Ioss_CodeTypes.h
Iopg::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iopg_DatabaseIO.h:228
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:136
Iopg::IOFactory::IOFactory
IOFactory()
Definition: Iopg_DatabaseIO.C:115
Iopg::DatabaseIO::commsetElemCount
int commsetElemCount
Definition: Iopg_DatabaseIO.h:238
Ioss_DatabaseIO.h
Ioss::SIDESET
Definition: Ioss_EntityType.h:48