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 void read_region();
117 void read_communication_metadata();
118
119 /*
120 * TODO identify all the get_*{blocks|sets} needed here
121 */
122 void get_edgeblocks();
123 void get_elemblocks();
124 void get_faceblocks();
125 void get_nodeblocks();
126
127 void get_edgesets();
128 void get_elemsets();
129 void get_facesets();
130 void get_nodesets();
131
132 int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect,
133 size_t data_size) const;
134 int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact,
135 size_t data_size) const;
136
137 const Ioss::Map &get_node_map() const;
138 const Ioss::Map &get_element_map() const;
139
140 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
141 size_t data_size) const override;
142 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
143 size_t data_size) const override;
144 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
145 size_t data_size) const override;
146 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
147 size_t data_size) const override;
148 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
149 size_t data_size) const override;
150 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
151 size_t data_size) const override;
152 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
153 size_t data_size) const override;
154 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
155 size_t data_size) const override;
156 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
157 size_t data_size) const override;
158 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
159 size_t data_size) const override;
160 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
161 size_t data_size) const override;
162 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
163 size_t data_size) const override;
164 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
165 void *data, size_t data_size) const override;
166 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
167 size_t data_size) const override;
168 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
173 size_t data_size) const override;
174 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
175 size_t data_size) const override;
176 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
177 size_t data_size) const override;
178 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
179 size_t data_size) const override;
180 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
181 size_t data_size) const override;
182 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
183 size_t data_size) const override;
184 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
185 size_t data_size) const override;
186 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
187 size_t data_size) const override;
188 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
189 size_t data_size) const override;
190 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
191 void *data, size_t data_size) const override;
192
193 std::string databaseTitle;
194
195 int spatialDimension;
196
197 int nodeBlockCount;
198 int elementBlockCount;
199 int nodesetCount;
200 int sidesetCount;
201
202 // Communication Set Data
203 Ioss::IntVector nodeCmapIds;
204 Ioss::IntVector nodeCmapNodeCnts;
205 Ioss::IntVector elemCmapIds;
206 Ioss::IntVector elemCmapElemCnts;
207 int commsetNodeCount;
208 int commsetElemCount;
209 };
210 } // namespace Iodw
211 #endif // Iodw_DatabaseIO_h
Iodw::DatabaseIO::commsetNodeCount
int commsetNodeCount
Definition: Iodw_DatabaseIO.h:207
Iodw::DatabaseIO::node_block_count
int node_block_count() const
Definition: Iodw_DatabaseIO.h:101
Ioss_DBUsage.h
Iodw::DatabaseIO::end__
bool end__(Ioss::State state) override
Definition: Iodw_DatabaseIO.h:114
Iodw::DatabaseIO::~DatabaseIO
~DatabaseIO()
Definition: Iodw_DatabaseIO.C:114
Iodw::DatabaseIO
Definition: Iodw_DatabaseIO.h:81
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:47
Iodw::DatabaseIO::databaseTitle
std::string databaseTitle
Definition: Iodw_DatabaseIO.h:193
Iodw::DatabaseIO::get_faceblocks
void get_faceblocks()
Definition: Iodw_DatabaseIO.C:139
Ioss_Map.h
Iodw::DatabaseIO::get_element_map
const Ioss::Map & get_element_map() const
Ioss::IntVector
std::vector< int > IntVector
Definition: Ioss_CodeTypes.h:51
Iodw::DatabaseIO::get_elemsets
void get_elemsets()
Definition: Iodw_DatabaseIO.C:145
Iodw::DatabaseIO::side_count
int side_count() const
Definition: Iodw_DatabaseIO.h:99
Ioss::EdgeBlock
A collection of element edges with the same topology.
Definition: Ioss_EdgeBlock.h:53
Iodw::DatabaseIO::read_region
void read_region()
Definition: Iodw_DatabaseIO.C:131
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
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
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::Region
A grouping entity that contains other grouping entities.
Definition: Ioss_Region.h:98
Iodw::DatabaseIO::element_count
int element_count() const
Definition: Iodw_DatabaseIO.h:100
Ioss::NodeSet
A collection of nodes.
Definition: Ioss_NodeSet.h:53
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
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::title
std::string title() const
Definition: Iodw_DatabaseIO.h:96
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Iodw::IOFactory
Definition: Iodw_DatabaseIO.h:70
Ioss::DatabaseIO::elementCount
int64_t elementCount
Definition: Ioss_DatabaseIO.h:629
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
Iodw::IOFactory::IOFactory
IOFactory()
Definition: Iodw_DatabaseIO.C:87
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
Ioss::DatabaseIO::nodeCount
int64_t nodeCount
Definition: Ioss_DatabaseIO.h:628
Iodw::DatabaseIO::elemCmapIds
Ioss::IntVector elemCmapIds
Definition: Iodw_DatabaseIO.h:205
Ioss::FaceBlock
A collection of element faces with the same topology.
Definition: Ioss_FaceBlock.h:53
Ioss::DatabaseIO::properties
Ioss::PropertyManager properties
Definition: Ioss_DatabaseIO.h:578
Iodw::DatabaseIO::get_nodesets
void get_nodesets()
Definition: Iodw_DatabaseIO.C:149
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
Ioss::DatabaseIO
An input or output Database.
Definition: Ioss_DatabaseIO.h:82
Ioss::DatabaseIO::DatabaseIO
DatabaseIO()=delete
Iodw::DatabaseIO::read_communication_metadata
void read_communication_metadata()
Definition: Iodw_DatabaseIO.C:133
Iodw::DatabaseIO::elemCmapElemCnts
Ioss::IntVector elemCmapElemCnts
Definition: Iodw_DatabaseIO.h:206
Ioss_State.h
Ioss::SideBlock
A collection of element sides having the same topology.
Definition: Ioss_SideBlock.h:59
Iodw::DatabaseIO::begin__
bool begin__(Ioss::State state) override
Definition: Iodw_DatabaseIO.h:113
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::get_node_map
const Ioss::Map & get_node_map() const
Iodw::DatabaseIO::get_edgesets
void get_edgesets()
Definition: Iodw_DatabaseIO.C:143
Iodw::DatabaseIO::nodesetCount
int nodesetCount
Definition: Iodw_DatabaseIO.h:199
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::compute_block_membership
void compute_block_membership(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
Ioss_IOFactory.h
Ioss::ElementBlock
A collection of elements having the same topology.
Definition: Ioss_ElementBlock.h:48
Iodw::DatabaseIO::nodeCmapNodeCnts
Ioss::IntVector nodeCmapNodeCnts
Definition: Iodw_DatabaseIO.h:204
Ioss::Map
Definition: Ioss_Map.h:52
Iodw::DatabaseIO::get_facesets
void get_facesets()
Definition: Iodw_DatabaseIO.C:147
Iodw::DatabaseIO::operator=
DatabaseIO & operator=(const DatabaseIO &from)=delete
anonymous_namespace{cth_pressure_map.C}::data
std::vector< char > data
Definition: cth_pressure_map.C:74
Iodw::DatabaseIO::nodeBlockCount
int nodeBlockCount
Definition: Iodw_DatabaseIO.h:197
Iodw::DatabaseIO::sidesetCount
int sidesetCount
Definition: Iodw_DatabaseIO.h:200
Iodw::DatabaseIO::spatial_dimension
int spatial_dimension() const
Definition: Iodw_DatabaseIO.h:97
Iodw::DatabaseIO::get_elemblocks
void get_elemblocks()
Definition: Iodw_DatabaseIO.C:137
Ioss::NodeBlock
A collection of all nodes in the region.
Definition: Ioss_NodeBlock.h:53
Iodw::IOFactory::factory
static const IOFactory * factory()
Definition: Iodw_DatabaseIO.C:81
Iodw::DatabaseIO::read_meta_data__
void read_meta_data__() override
Definition: Iodw_DatabaseIO.C:116
MPI_Comm
int MPI_Comm
Definition: Ioss_CodeTypes.h:96
Iodw::DatabaseIO::spatialDimension
int spatialDimension
Definition: Iodw_DatabaseIO.h:195
Iodw::DatabaseIO::node_count
int node_count() const
Definition: Iodw_DatabaseIO.h:98
Iodw::DatabaseIO::commsetElemCount
int commsetElemCount
Definition: Iodw_DatabaseIO.h:208
Iodw
A namespace for the pamgen database format.
Definition: Iodw_DatabaseIO.C:79
Ioss::SideSet
A collection of element sides.
Definition: Ioss_SideSet.h:53
Ioss_CodeTypes.h
Iodw::DatabaseIO::nodeCmapIds
Ioss::IntVector nodeCmapIds
Definition: Iodw_DatabaseIO.h:203
Iodw::DatabaseIO::nodeset_count
int nodeset_count() const
Definition: Iodw_DatabaseIO.h:104
Iodw::DatabaseIO::get_edgeblocks
void get_edgeblocks()
Definition: Iodw_DatabaseIO.C:135
Iodw::DatabaseIO::entity_field_support
unsigned entity_field_support() const override
Definition: Iodw_DatabaseIO.h:94
Iodw::DatabaseIO::element_block_count
int element_block_count() const
Definition: Iodw_DatabaseIO.h:102
Iodw::DatabaseIO::elementBlockCount
int elementBlockCount
Definition: Iodw_DatabaseIO.h:198
Ioss_DatabaseIO.h
Iodw::DatabaseIO::get_nodeblocks
void get_nodeblocks()
Definition: Iodw_DatabaseIO.C:141
Iodw::DatabaseIO::sideset_count
int sideset_count() const
Definition: Iodw_DatabaseIO.h:103