IOSS 2.0
Loading...
Searching...
No Matches
Ioexnl_ParallelDatabaseIO.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// -*- Mode: c++ -*-
8#pragma once
9
10#include <exodusII.h>
11
12#include "ioexnl_export.h"
13#if defined PARALLEL_AWARE_EXODUS
14#include "Ioss_CodeTypes.h"
15#include "Ioss_DBUsage.h" // for DatabaseUsage
16#include "Ioss_Map.h" // for Map
17#include "Ioss_State.h" // for State
18#include "exonull/Ioexnl_BaseDatabaseIO.h" // for DatabaseIO
19#include <functional> // for less
20#include <map> // for map, map<>::value_compare
21#include <memory>
22#include <set> // for set
23#include <stddef.h> // for size_t
24#include <stdint.h> // for int64_t
25#include <string> // for string, operator<
26#include <time.h> // for nullptr, time_t
27#include <utility> // for pair
28#include <vector> // for vector
29
30namespace Ioexnl {
31 class DecompositionDataBase;
32}
33namespace Ioexnl {
34 template <typename INT> class DecompositionData;
35}
36
37namespace Ioss {
38 class Assembly;
39 class Blob;
40 class EntityBlock;
41 class ElementTopology;
42 class CommSet;
43 class EdgeBlock;
44 class EdgeSet;
45 class ElementBlock;
46 class ElementSet;
47 class EntitySet;
48 class FaceBlock;
49 class FaceSet;
50 class Field;
51 class GroupingEntity;
52 class NodeBlock;
53 class NodeSet;
54 class PropertyManager;
55 class Region;
56 class SideBlock;
57 class SideSet;
58 class StructuredBlock;
59} // namespace Ioss
60
61/** \brief A namespace for the decompose-on-the-fly version of the
62 * parallel exodus database format.
63 */
64namespace Ioexnl {
65 class IOEXNL_EXPORT ParallelDatabaseIO : public Ioexnl::BaseDatabaseIO
66 {
67 public:
68 ParallelDatabaseIO(Ioss::Region *region, const std::string &filename,
69 Ioss::DatabaseUsage db_usage, Ioss_MPI_Comm communicator,
70 const Ioss::PropertyManager &properties);
71
72 IOSS_NODISCARD int get_file_pointer() const override; // Open file and set exodusFilePtr.
73 IOSS_NODISCARD bool needs_shared_node_information() const override { return true; }
74
75 private:
76 void compute_node_status() const;
77
78 void release_memory_nl() override;
79
80 void get_step_times_nl() override {}
81
82 bool handle_output_file(bool write_message, std::string *error_msg, int *bad_count,
83 bool overwrite, bool abort_if_error) const override;
84 bool check_valid_file_ptr(bool write_message, std::string *error_msg, int *bad_count,
85 bool abort_if_error) const;
86
87 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
88 size_t data_size) const override;
89 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
90 size_t data_size) const override;
91 int64_t put_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, void *data,
92 size_t data_size) const override;
93 int64_t put_field_internal(const Ioss::FaceBlock *eb, const Ioss::Field &field, void *data,
94 size_t data_size) const override;
95 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
96 size_t data_size) const override;
97 int64_t put_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field, void *data,
98 size_t data_size) const override;
99 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
100 size_t data_size) const override;
101 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
102 size_t data_size) const override;
103 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
104 size_t data_size) const override;
105 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
106 size_t data_size) const override;
107 int64_t put_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field, void *data,
108 size_t data_size) const override;
109 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
110 size_t data_size) const override;
111 int64_t put_field_internal(const Ioss::Assembly *sb, const Ioss::Field &field, void *data,
112 size_t data_size) const override;
113 int64_t put_field_internal(const Ioss::Blob *sb, const Ioss::Field &field, void *data,
114 size_t data_size) const override;
115 int64_t put_field_internal(const Ioss::StructuredBlock * /* sb */,
116 const Ioss::Field & /* field */, void * /* data */,
117 size_t /* data_size */) const override
118 {
119 return -1;
120 }
121
122 int64_t put_Xset_field_internal(const Ioss::EntitySet *ns, const Ioss::Field &field, void *data,
123 size_t data_size) const;
124 int64_t get_Xset_field_internal(const Ioss::EntitySet *ns, const Ioss::Field &field, void *data,
125 size_t data_size) const;
126
127 int free_file_pointer() const override;
128
129 int64_t read_nodal_coordinates();
130 void read_elements(const Ioss::ElementBlock &block);
131
132 void create_implicit_global_map() const;
133 void output_node_map() const;
134
135 // Metadata-related functions.
136 void read_meta_data_nl() override;
137
138 int64_t read_transient_field(const Ioexnl::VariableNameMap &variables, const Ioss::Field &field,
139 const Ioss::GroupingEntity *ge, void *data) const;
140
141 int64_t read_attribute_field(const Ioss::Field &field, const Ioss::GroupingEntity *ge,
142 void *data) const;
143
144 int64_t write_attribute_field(const Ioss::Field &field, const Ioss::GroupingEntity *ge,
145 void *data) const;
146
147 // Handles subsetting of side blocks.
148 int64_t read_ss_transient_field(const Ioss::Field &field, int64_t id, void *variables,
149 std::vector<int> &is_valid_side) const;
150
151 // Should be made more generic again so can rejoin with write_element_transient field
152 void write_nodal_transient_field(const Ioss::Field &field, const Ioss::NodeBlock *nb,
153 int64_t count, void *variables) const;
154 // Should be made more generic again so can rejoin with write_nodal_transient field
155 void write_entity_transient_field(const Ioss::Field &field, const Ioss::GroupingEntity *ge,
156 int64_t count, void *variables) const;
157 void write_meta_data(Ioss::IfDatabaseExistsBehavior behavior) override;
158
159 // Read related metadata and store it in the region...
160 void read_region();
161 void get_edgeblocks();
162 void get_faceblocks();
163 void get_elemblocks();
164 void get_blocks(ex_entity_type entity_type, int rank_offset, const std::string &basename);
165
166 void get_sidesets();
167
168 template <typename T>
169 void get_sets(ex_entity_type type, int64_t count, const std::string &base, const T *);
170 void get_nodesets();
171 void get_edgesets();
172 void get_facesets();
173 void get_elemsets();
174
175 void get_commsets();
176
177 void check_valid_values() const;
178
179 // ID Mapping functions.
180 IOSS_NODISCARD const Ioss::Map &get_map(ex_entity_type type) const;
181 IOSS_NODISCARD const Ioss::Map &get_map(Ioss::Map &entity_map, int64_t entityCount,
182 int64_t file_offset, int64_t file_count,
183 ex_entity_type entity_type,
184 ex_inquiry inquiry_type) const;
185
186 // Internal data handling
187 int64_t handle_node_ids(void *ids, int64_t num_to_get, size_t offset, size_t count) const;
188 int64_t handle_element_ids(const Ioss::ElementBlock *eb, void *ids, size_t num_to_get,
189 size_t offset, size_t count) const;
190 int64_t handle_face_ids(const Ioss::FaceBlock *eb, void *ids, size_t num_to_get) const;
191 int64_t handle_edge_ids(const Ioss::EdgeBlock *eb, void *ids, size_t num_to_get) const;
192
193 int64_t get_side_connectivity(const Ioss::SideBlock *sd_blk, int64_t id, int64_t side_count,
194 void *fconnect, bool map_ids) const;
195 int64_t get_side_distributions(const Ioss::SideBlock *sd_blk, int64_t id, int64_t my_side_count,
196 double *dist_fact, size_t data_size) const;
197
198 int64_t get_side_field(const Ioss::SideBlock *sd_blk, const Ioss::Field &field, void *data,
199 size_t data_size) const;
200 int64_t put_side_field(const Ioss::SideBlock *sd_blk, const Ioss::Field &field, void *data,
201 size_t data_size) const;
202
203 // Private member data...
204 mutable std::unique_ptr<DecompositionDataBase> decomp;
205
206 mutable Ioss::IntVector nodeOwningProcessor; // Processor that owns each node on this processor
207 mutable Ioss::Int64Vector
208 nodeGlobalImplicitMap; // Position of this node in the global-implicit ordering
209 mutable Ioss::Int64Vector
210 elemGlobalImplicitMap; // Position of this element in the global-implicit ordering
211
212 // Contains the indices of all owned nodes in each nodeset on this processor to pull data
213 // from the global list down to the file list.
214 // NOTE: Even though map type is GroupingEntity*, it is only valid
215 // for a GroupingEntity* which is a NodeSet*
216 mutable std::map<const Ioss::GroupingEntity *, Ioss::Int64Vector> nodesetOwnedNodes;
217
218 mutable bool metaDataWritten{false};
219 mutable bool nodeGlobalImplicitMapDefined{false};
220 mutable bool elemGlobalImplicitMapDefined{false};
221 };
222} // namespace Ioexnl
223#endif
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
Definition Ioexnl_BaseDatabaseIO.h:78
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
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
Base class for all 'set'-type grouping entities, which means that members of the set are not necessar...
Definition Ioss_EntitySet.h:38
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
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 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 exodus database format.
Definition Ioexnl_BaseDatabaseIO.C:93
std::map< std::string, int, std::less<> > VariableNameMap
Definition Ioexnl_BaseDatabaseIO.h:61
int get_file_pointer()
Definition Iofaodel_DatabaseIO.C:55
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
std::vector< int64_t > Int64Vector
Definition Ioss_CodeTypes.h:22
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition Ioss_DBUsage.h:13
std::vector< int > IntVector
Definition Ioss_CodeTypes.h:21
IfDatabaseExistsBehavior
Definition Ioss_DBUsage.h:32