IOSS 2.0

Iodw_DatabaseIO.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2010
2 // Sandia Corporation. Under the terms of Contract
3 // DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
4 // certain rights in this software.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 // * Neither the name of Sandia Corporation 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 Iodw_DatabaseIO_h
34 #define Iodw_DatabaseIO_h
35
36 #include <Ioss_CodeTypes.h>
37 #include <Ioss_DBUsage.h> // for DatabaseUsage
38 #include <Ioss_DatabaseIO.h> // for DatabaseIO
39 #include <Ioss_IOFactory.h> // for IOFactory
40 #include <Ioss_Map.h> // for Map
41 #include <Ioss_State.h> // for State
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 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 Iodw {
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 { return 0; }
95
96 std::string title() const { return databaseTitle; }
97 int spatial_dimension() const { return spatialDimension; }
98 int node_count() const { return nodeCount; }
99 int side_count() const { return 0; }
100 int element_count() const { return elementCount; }
101 int node_block_count() const { return nodeBlockCount; }
102 int element_block_count() const { return elementBlockCount; }
103 int sideset_count() const { return sidesetCount; }
104 int nodeset_count() const { return nodesetCount; }
105 int maximum_symbol_length() const override { return 32; }
106
107 void compute_block_membership(Ioss::SideBlock * efblock,
108 std::vector<std::string> &block_membership) const;
109
110 private:
111 void read_meta_data__() override;
112
113 bool begin__(Ioss::State state) override { return false; };
114 bool end__(Ioss::State state) override { return false; };
115
116 bool begin_state__(Ioss::Region *region, int state, double time) override { return false; };
117 bool end_state__(Ioss::Region *region, int state, double time) override { return false; };
118
119 void read_region();
120 void read_communication_metadata();
121
122 /*
123 * TODO identify all the get_*{blocks|sets} needed here
124 */
125 void get_edgeblocks();
126 void get_elemblocks();
127 void get_faceblocks();
128 void get_nodeblocks();
129
130 void get_edgesets();
131 void get_elemsets();
132 void get_facesets();
133 void get_nodesets();
134
135 int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect,
136 size_t data_size) const;
137 int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact,
138 size_t data_size) const;
139
140 const Ioss::Map &get_node_map() const;
141 const Ioss::Map &get_element_map() const;
142
143 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
144 size_t data_size) const override;
145 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
146 size_t data_size) const override;
147 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
148 size_t data_size) const override;
149 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
150 size_t data_size) const override;
151 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
152 size_t data_size) const override;
153 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
154 size_t data_size) const override;
155 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
156 size_t data_size) const override;
157 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
158 size_t data_size) const override;
159 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
160 size_t data_size) const override;
161 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
162 size_t data_size) const override;
163 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
164 size_t data_size) const override;
165 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
166 size_t data_size) const override;
167 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
168 void *data, size_t data_size) const override;
169 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
170 size_t data_size) const override;
171 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
172 size_t data_size) const override;
173 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
174 size_t data_size) const override;
175 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
176 size_t data_size) const override;
177 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
178 size_t data_size) const override;
179 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
180 size_t data_size) const override;
181 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
182 size_t data_size) const override;
183 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
184 size_t data_size) const override;
185 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
186 size_t data_size) const override;
187 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
188 size_t data_size) const override;
189 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
190 size_t data_size) const override;
191 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
192 size_t data_size) const override;
193 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
194 void *data, size_t data_size) const override;
195
196 std::string databaseTitle;
197
198 int spatialDimension;
199
200 int nodeBlockCount;
201 int elementBlockCount;
202 int nodesetCount;
203 int sidesetCount;
204
205 // Communication Set Data
206 Ioss::IntVector nodeCmapIds;
207 Ioss::IntVector nodeCmapNodeCnts;
208 Ioss::IntVector elemCmapIds;
209 Ioss::IntVector elemCmapElemCnts;
210 int commsetNodeCount;
211 int commsetElemCount;
212 };
213 } // namespace Iodw
214 #endif // Iodw_DatabaseIO_h
Ioss_CodeTypes.h
Iodw::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Iodw::DatabaseIO::side_count
int side_count() const
Definition: Iodw_DatabaseIO.h:99
Iodw::DatabaseIO::get_node_map
const Ioss::Map & get_node_map() const
Iodw::DatabaseIO::nodeBlockCount
int nodeBlockCount
Definition: Iodw_DatabaseIO.h:200
Iodw::DatabaseIO::end_state__
bool end_state__(Ioss::Region *region, int state, double time) override
Definition: Iodw_DatabaseIO.h:117
Iodw::DatabaseIO::elemCmapElemCnts
Ioss::IntVector elemCmapElemCnts
Definition: Iodw_DatabaseIO.h:209
Iodw::DatabaseIO::element_block_count
int element_block_count() const
Definition: Iodw_DatabaseIO.h:102
Iodw::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iodw_DatabaseIO.h:113
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Iodw::DatabaseIO::get_facesets
void get_facesets()
Definition: Iodw_DatabaseIO.C:147
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:80
Ioss_DBUsage.h
Iodw::DatabaseIO::get_side_connectivity
int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect, size_t data_size) const
Iodw::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iodw_DatabaseIO.h:94
Iodw::DatabaseIO::nodeset_count
int nodeset_count() const
Definition: Iodw_DatabaseIO.h:104
Iodw::DatabaseIO::begin_state__
bool begin_state__(Ioss::Region *region, int state, double time) override
Definition: Iodw_DatabaseIO.h:116
Iodw::DatabaseIO::nodeCmapIds
Ioss::IntVector nodeCmapIds
Definition: Iodw_DatabaseIO.h:206
Iodw::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iodw_DatabaseIO.C:141
Iodw::IOFactory::IOFactory
IOFactory()
Definition: Iodw_DatabaseIO.C:87
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
Iodw::DatabaseIO::read_region
void read_region()
Definition: Iodw_DatabaseIO.C:131
Iodw::DatabaseIO::spatial_dimension
int spatial_dimension() const
Definition: Iodw_DatabaseIO.h:97
Ioss::FaceSet
A collection of element faces.
Definition: Ioss_FaceSet.h:54
Iodw::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: Iodw_DatabaseIO.C:151
Iodw::DatabaseIO::sideset_count
int sideset_count() const
Definition: Iodw_DatabaseIO.h:103
Iodw::DatabaseIO::nodeCmapNodeCnts
Ioss::IntVector nodeCmapNodeCnts
Definition: Iodw_DatabaseIO.h:207
Ioss::DatabaseIO::elementCount
int64_t elementCount
Definition: Ioss_DatabaseIO.h:556
Iodw::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iodw_DatabaseIO.h:202
Iodw::DatabaseIO::get_faceblocks
void get_faceblocks()
Definition: Iodw_DatabaseIO.C:139
Iodw::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iodw_DatabaseIO.h:201
Ioss::EdgeSet
A collection of element edges.
Definition: Ioss_EdgeSet.h:54
Ioss_Map.h
Iodw::DatabaseIO::databaseTitle
std::string databaseTitle
Definition: Iodw_DatabaseIO.h:196
Iodw::DatabaseIO::node_block_count
int node_block_count() const
Definition: Iodw_DatabaseIO.h:101
Iodw::DatabaseIO::get_elemblocks
void get_elemblocks()
Definition: Iodw_DatabaseIO.C:137
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:61
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:43
Iodw::DatabaseIO::~DatabaseIO
~DatabaseIO()
Definition: Iodw_DatabaseIO.C:114
Iodw::DatabaseIO::title
std::string title() const
Definition: Iodw_DatabaseIO.h:96
Ioss_DatabaseIO.h
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::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Ioss_State.h
Iodw::IOFactory::make_IO
Ioss::DatabaseIO * make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage, MPI_Comm communicator, const Ioss::PropertyManager &properties) const
Definition: Iodw_DatabaseIO.C:89
Iodw::DatabaseIO::read_communication_metadata
void read_communication_metadata()
Definition: Iodw_DatabaseIO.C:133
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::properties
Ioss::PropertyManager properties
Definition: Ioss_DatabaseIO.h:516
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
Iodw::DatabaseIO::element_count
int element_count() const
Definition: Iodw_DatabaseIO.h:100
Iodw::IOFactory
Definition: Iodw_DatabaseIO.h:70
Iodw::DatabaseIO::get_nodesets
void get_nodesets()
Definition: Iodw_DatabaseIO.C:149
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iodw::DatabaseIO::commsetElemCount
int commsetElemCount
Definition: Iodw_DatabaseIO.h:211
Iodw::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
Iodw::IOFactory::factory
static const IOFactory * factory()
Definition: Iodw_DatabaseIO.C:81
Iodw::DatabaseIO::commsetNodeCount
int commsetNodeCount
Definition: Iodw_DatabaseIO.h:210
Ioss::Map
Definition: Ioss_Map.h:52
Ioss::CommSet
Definition: Ioss_CommSet.h:51
Iodw::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: Iodw_DatabaseIO.C:216
Iodw::DatabaseIO
Definition: Iodw_DatabaseIO.h:81
Iodw
A namespace for the pamgen database format.
Definition: Iodw_DatabaseIO.C:79
Iodw::DatabaseIO::get_edgesets
void get_edgesets()
Definition: Iodw_DatabaseIO.C:143
Iodw::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iodw_DatabaseIO.C:116
Iodw::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iodw_DatabaseIO.h:198
Iodw::DatabaseIO::node_count
int node_count() const
Definition: Iodw_DatabaseIO.h:98
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:73
Iodw::DatabaseIO::get_elemsets
void get_elemsets()
Definition: Iodw_DatabaseIO.C:145
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
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:80
Iodw::DatabaseIO::get_edgeblocks
void get_edgeblocks()
Definition: Iodw_DatabaseIO.C:135
Ioss::DatabaseIO::nodeCount
int64_t nodeCount
Definition: Ioss_DatabaseIO.h:555
Iodw::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
Iodw::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iodw_DatabaseIO.h:114
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iodw::DatabaseIO::compute_block_membership
void compute_block_membership(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iodw::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iodw_DatabaseIO.h:203
Iodw::DatabaseIO::elemCmapIds
Ioss::IntVector elemCmapIds
Definition: Iodw_DatabaseIO.h:208
Iodw::DatabaseIO::maximum_symbol_length
int maximum_symbol_length() const override
Get the length of the longest name in the database file.
Definition: Iodw_DatabaseIO.h:105