IOSS 2.0
Loading...
Searching...
No Matches
Iofaodel_DatabaseIO.h
Go to the documentation of this file.
1// Copyright(C) 1999-2024 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// See packages/seacas/LICENSE for details
6
7#pragma once
8
9#include "iofaodel_export.h"
10
11#include "Ioss_CodeTypes.h"
12#include "Ioss_DBUsage.h" // for DatabaseUsage
13#include "Ioss_DatabaseIO.h" // for DatabaseIO
14#include "Ioss_IOFactory.h" // for IOFactory
15#include "Ioss_Map.h" // for Map
16#include "Ioss_Region.h" // for Region
17#include "Ioss_State.h" // for State
18#include "Ioss_VariableType.h" // for VariableType
19#include <atomic> // for atomic
20#include <cstddef> // for size_t
21#include <cstdint> // for int64_t
22#include <string> // for string
23#include <vector> // for vector
24
25#include "faodel-common/Common.hh"
26#include "kelpie/Kelpie.hh"
27
28namespace Ioss {
29 class CommSet;
30 class EdgeBlock;
31 class EdgeSet;
32 class ElementBlock;
33 class ElementSet;
34 class EntityBlock;
35 class FaceBlock;
36 class FaceSet;
37 class Field;
38 class GroupingEntity;
39 class NodeBlock;
40 class NodeSet;
41 class PropertyManager;
42 class Region;
43 class SideBlock;
44 class SideSet;
45 class StructuredBlock;
46} // namespace Ioss
47
48/** \brief A namespace for the pamgen database format.
49 */
50namespace Iofaodel {
51
52 class IOFAODEL_EXPORT IOFactory : public Ioss::IOFactory
53 {
54 public:
55 static const IOFactory *factory();
56
57 private:
58 IOFactory();
59 Ioss::DatabaseIO *make_IO(const std::string &filename, Ioss::DatabaseUsage db_usage,
60 Ioss_MPI_Comm communicator,
61 const Ioss::PropertyManager &properties) const;
62 };
63
64 class IOFAODEL_EXPORT DatabaseIO : public Ioss::DatabaseIO
65 {
66 public:
67 DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage,
68 Ioss_MPI_Comm communicator, const Ioss::PropertyManager &properties);
70
71 // TODO what should this be for Faodel?
72 int int_byte_size_db() const override { return sizeof(int); }
73
74 // Check capabilities of input/output database... Returns an
75 // unsigned int with the supported Ioss::EntityType or'ed
76 // together. If "return_value & Ioss::EntityType" is set, then the
77 // database supports that type (e.g. return_value & Ioss::FACESET)
78 unsigned entity_field_support() const override { return 0; }
79
80 std::string title() const { return databaseTitle; }
81 int spatial_dimension() const { return spatialDimension; }
82 int node_count() const { return nodeCount; }
83 int side_count() const { return 0; }
84 int element_count() const { return elementCount; }
85 int node_block_count() const { return nodeBlockCount; }
86 int element_block_count() const { return elementBlockCount; }
87 int sideset_count() const { return sidesetCount; }
88 int nodeset_count() const { return nodesetCount; }
89 int maximum_symbol_length() const override { return 32; }
90
92 std::vector<std::string> &block_membership) const;
93
94 std::string get_format() const override;
95
96 private:
97 bool put_properties() const;
98
99 void finalize_database() const override;
100
101 void read_meta_data_nl() override;
102
103 bool begin_state_nl(int /* state */, double /* time */) override;
104 bool end_state_nl(int /* state */, double /* time */) override;
105
106 bool begin_nl(Ioss::State state) override
107 {
108 dbState = state;
109 return true;
110 };
111 bool end_nl(Ioss::State state) override
112 {
113 dbState = Ioss::STATE_UNKNOWN;
114 return true;
115 };
116
117 void read_region();
118 void read_entity_properties(kelpie::ObjectCapacities oc, Ioss::GroupingEntity &entity);
119 Ioss::Property read_property(lunasa::DataObject &ldo);
120 void read_entity_fields(kelpie::ObjectCapacities oc, Ioss::GroupingEntity &entity);
121
122 void read_communication_metadata();
123
124 /*
125 * TODO identify all the get_*{blocks|sets} needed here
126 */
127 void get_step_times_nl() override;
128
129 std::vector<double> get_db_step_times_nl() override;
130
131 void get_edgeblocks();
132 void get_elemblocks();
133 void get_faceblocks();
134 void get_nodeblocks();
135 void get_structuredblocks();
136
137 void get_edgesets();
138 void get_elemsets();
139 void get_facesets();
140 void get_nodesets();
141 void get_sidesets();
142 void get_commsets();
143
144 int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect,
145 size_t data_size) const;
146 int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact,
147 size_t data_size) const;
148
149 const Ioss::Map &get_node_map() const;
151
152 int64_t get_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
153 size_t data_size) const override;
154 int64_t get_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
155 size_t data_size) const override;
156 int64_t get_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
157 size_t data_size) const override;
158 int64_t get_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
159 size_t data_size) const override;
160 int64_t get_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
161 size_t data_size) const override;
162 int64_t get_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
163 size_t data_size) const override;
164 int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
165 size_t data_size) const override;
166 int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
167 size_t data_size) const override;
168 int64_t get_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
169 size_t data_size) const override;
170 int64_t get_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
171 size_t data_size) const override;
172 int64_t get_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
173 size_t data_size) const override;
174 int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
175 size_t data_size) const override;
176 int64_t get_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
177 void *data, size_t data_size) const override;
178 int64_t get_field_internal(const Ioss::Assembly *a, const Ioss::Field &field, void *data,
179 size_t data_size) const override;
180 int64_t get_field_internal(const Ioss::Blob *b, const Ioss::Field &field, void *data,
181 size_t data_size) const override;
182 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
183 size_t data_size) const override;
184 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
185 size_t data_size) const override;
186 int64_t put_field_internal(const Ioss::EdgeBlock *nb, const Ioss::Field &field, void *data,
187 size_t data_size) const override;
188 int64_t put_field_internal(const Ioss::FaceBlock *nb, const Ioss::Field &field, void *data,
189 size_t data_size) const override;
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 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
199 size_t data_size) const override;
200 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
201 size_t data_size) const override;
202 int64_t put_field_internal(const Ioss::SideSet *fs, const Ioss::Field &field, void *data,
203 size_t data_size) const override;
204 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
205 size_t data_size) const override;
206 int64_t put_field_internal(const Ioss::StructuredBlock *sb, const Ioss::Field &field,
207 void *data, size_t data_size) const override;
208 int64_t put_field_internal(const Ioss::Assembly *a, const Ioss::Field &field, void *data,
209 size_t data_size) const override;
210 int64_t put_field_internal(const Ioss::Blob *b, const Ioss::Field &field, void *data,
211 size_t data_size) const override;
212
213 std::string databaseTitle;
214
216
221
222 // KEEP track of how many instances of this object exist, since each implicitly
223 // relies on a running instance of Faodel.
224 static std::atomic<int> instanceCount;
225
226 // Communication Set Data
233
234 // Faodel helpers
235 int64_t get_field_internal(const Ioss::GroupingEntity &e, const Ioss::Field &field, void *data,
236 size_t data_size) const;
237
238 int64_t put_field_internal(const Ioss::GroupingEntity &e, const Ioss::Field &field, void *data,
239 size_t data_size) const;
240
241 mutable kelpie::Pool pool;
242 faodel::Configuration faodel_config;
243
244 using PropertyPair = std::pair<std::string, bool>;
245 std::vector<PropertyPair> property_publish_state;
246 };
247} // namespace Iofaodel
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
Definition Iofaodel_DatabaseIO.h:65
void compute_block_membership(Ioss::SideBlock *efblock, std::vector< std::string > &block_membership) const
int spatialDimension
Definition Iofaodel_DatabaseIO.h:215
int side_count() const
Definition Iofaodel_DatabaseIO.h:83
Ioss::IntVector nodeCmapNodeCnts
Definition Iofaodel_DatabaseIO.h:228
int maximum_symbol_length() const override
Get the length of the longest name in the database file.
Definition Iofaodel_DatabaseIO.h:89
int commsetElemCount
Definition Iofaodel_DatabaseIO.h:232
std::vector< PropertyPair > property_publish_state
Definition Iofaodel_DatabaseIO.h:245
unsigned entity_field_support() const override
Definition Iofaodel_DatabaseIO.h:78
int nodesetCount
Definition Iofaodel_DatabaseIO.h:219
int get_side_distributions(const Ioss::SideBlock *fb, int id, int side_count, double *dist_fact, size_t data_size) const
int sideset_count() const
Definition Iofaodel_DatabaseIO.h:87
const Ioss::Map & get_element_map() const
int int_byte_size_db() const override
Definition Iofaodel_DatabaseIO.h:72
Ioss::IntVector elemCmapIds
Definition Iofaodel_DatabaseIO.h:229
int nodeBlockCount
Definition Iofaodel_DatabaseIO.h:217
std::string databaseTitle
Definition Iofaodel_DatabaseIO.h:213
int get_side_connectivity(const Ioss::SideBlock *fb, int id, int side_count, int *fconnect, size_t data_size) const
bool begin_nl(Ioss::State state) override
Definition Iofaodel_DatabaseIO.h:106
int nodeset_count() const
Definition Iofaodel_DatabaseIO.h:88
bool end_nl(Ioss::State state) override
Definition Iofaodel_DatabaseIO.h:111
Ioss::IntVector nodeCmapIds
Definition Iofaodel_DatabaseIO.h:227
int sidesetCount
Definition Iofaodel_DatabaseIO.h:220
int element_block_count() const
Definition Iofaodel_DatabaseIO.h:86
static std::atomic< int > instanceCount
Definition Iofaodel_DatabaseIO.h:224
int elementBlockCount
Definition Iofaodel_DatabaseIO.h:218
int commsetNodeCount
Definition Iofaodel_DatabaseIO.h:231
int node_block_count() const
Definition Iofaodel_DatabaseIO.h:85
int node_count() const
Definition Iofaodel_DatabaseIO.h:82
int spatial_dimension() const
Definition Iofaodel_DatabaseIO.h:81
faodel::Configuration faodel_config
Definition Iofaodel_DatabaseIO.h:242
Ioss::IntVector elemCmapElemCnts
Definition Iofaodel_DatabaseIO.h:230
kelpie::Pool pool
Definition Iofaodel_DatabaseIO.h:241
std::pair< std::string, bool > PropertyPair
Definition Iofaodel_DatabaseIO.h:244
const Ioss::Map & get_node_map() const
std::string title() const
Definition Iofaodel_DatabaseIO.h:80
int element_count() const
Definition Iofaodel_DatabaseIO.h:84
Definition Iofaodel_DatabaseIO.h:53
A homogeneous collection of other GroupingEntities.
Definition Ioss_Assembly.h:31
A homogeneous collection of other GroupingEntities.
Definition Ioss_Blob.h:31
Definition Ioss_CommSet.h:27
An input or output Database.
Definition Ioss_DatabaseIO.h:63
A collection of element edges with the same topology.
Definition Ioss_EdgeBlock.h:29
A collection of element edges.
Definition Ioss_EdgeSet.h:30
A collection of elements having the same topology.
Definition Ioss_ElementBlock.h:29
A collection of elements.
Definition Ioss_ElementSet.h:30
A collection of element faces with the same topology.
Definition Ioss_FaceBlock.h:29
A collection of element faces.
Definition Ioss_FaceSet.h:30
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
Base class for all 'grouping' entities. The following derived classes are typical:
Definition Ioss_GroupingEntity.h:67
The main public user interface for creating Ioss::DatabaseIO objects.
Definition Ioss_IOFactory.h:35
Definition Ioss_Map.h:46
A collection of all nodes in the region.
Definition Ioss_NodeBlock.h:33
A collection of nodes.
Definition Ioss_NodeSet.h:29
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
A named value that has a known type.
Definition Ioss_Property.h:27
A grouping entity that contains other grouping entities.
Definition Ioss_Region.h:93
A collection of element sides having the same topology.
Definition Ioss_SideBlock.h:37
A collection of element sides.
Definition Ioss_SideSet.h:29
A structured zone – i,j,k.
Definition Ioss_StructuredBlock.h:91
A namespace for the pamgen database format.
Definition Iofaodel_DatabaseIO.C:46
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
State
Access states for a database.
Definition Ioss_State.h:15
@ STATE_UNKNOWN
Definition Ioss_State.h:17
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition Ioss_DBUsage.h:13
std::vector< int > IntVector
Definition Ioss_CodeTypes.h:21