IOSS 2.0
Loading...
Searching...
No Matches
Ioexnl_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// -*- Mode: c++ -*-
8#pragma once
9
10#include "Ioss_DBUsage.h"
11#include "Ioss_Field.h"
12#include "Ioss_Map.h"
13#include "Ioss_Utils.h"
15#include <algorithm>
16#include <cstdint>
17#include <ctime>
18#include <exodusII.h>
19#include <map>
20#include <set>
21#include <sstream>
22#include <string>
23#include <vector>
24
25#include "Ioss_CodeTypes.h"
26#include "ioexnl_export.h"
27
28namespace Ioss {
29 class GroupingEntity;
30 class Region;
31 class EntityBlock;
32 class NodeBlock;
33 class EdgeBlock;
34 class FaceBlock;
35 class ElementBlock;
36 class EntitySet;
37 class NodeSet;
38 class EdgeSet;
39 class FaceSet;
40 class ElementSet;
41 class SideBlock;
42 class SideSet;
43 class StructuredBlock;
44 class CommSet;
45 class ElementTopology;
46 class Assembly;
47 class Blob;
48 class Field;
49 class Map;
50 class PropertyManager;
51} // namespace Ioss
52
53namespace Ioexnl {
54 struct CommunicationMetaData;
55} // namespace Ioexnl
56
57/** \brief A namespace for the file-per-process version of the
58 * parallel exodus database format.
59 */
60namespace Ioexnl {
61 class IOEXNL_EXPORT DatabaseIO : public Ioexnl::BaseDatabaseIO
62 {
63 public:
64 DatabaseIO(Ioss::Region *region, const std::string &filename, Ioss::DatabaseUsage db_usage,
65 Ioss_MPI_Comm communicator, const Ioss::PropertyManager &props);
66
67 // Kluge -- a few applications need access so can directly access exodus API
68 IOSS_NODISCARD int get_file_pointer() const override; // Open file and set exodusFilePtr.
69
70 private:
71 void get_step_times_nl() override;
72
73 bool handle_output_file(bool write_message, std::string *error_msg, int *bad_count,
74 bool overwrite, bool abort_if_error) const override;
75 bool check_valid_file_ptr(bool write_message, std::string *error_msg, int *bad_count,
76 bool abort_if_error) const;
77
78 int64_t put_field_internal(const Ioss::Region *reg, const Ioss::Field &field, void *data,
79 size_t data_size) const override;
80 int64_t put_field_internal(const Ioss::Blob *blob, const Ioss::Field &field, void *data,
81 size_t data_size) const override;
82 int64_t put_field_internal(const Ioss::Assembly *assem, const Ioss::Field &field, void *data,
83 size_t data_size) const override;
84 int64_t put_field_internal(const Ioss::NodeBlock *nb, const Ioss::Field &field, void *data,
85 size_t data_size) const override;
86 int64_t put_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, void *data,
87 size_t data_size) const override;
88 int64_t put_field_internal(const Ioss::FaceBlock *eb, const Ioss::Field &field, void *data,
89 size_t data_size) const override;
90 int64_t put_field_internal(const Ioss::ElementBlock *eb, const Ioss::Field &field, void *data,
91 size_t data_size) const override;
92 int64_t put_field_internal(const Ioss::SideBlock *fb, const Ioss::Field &field, void *data,
93 size_t data_size) const override;
94 int64_t put_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
95 size_t data_size) const override;
96 int64_t put_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
97 size_t data_size) const override;
98 int64_t put_field_internal(const Ioss::FaceSet *ns, const Ioss::Field &field, void *data,
99 size_t data_size) const override;
100 int64_t put_field_internal(const Ioss::ElementSet *ns, const Ioss::Field &field, void *data,
101 size_t data_size) const override;
102 int64_t put_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field, void *data,
103 size_t data_size) const override;
104 int64_t put_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
105 size_t data_size) const override;
106
108 const Ioss::Field & /* field */, void * /* data */,
109 size_t /* data_size */) const override
110 {
111 return -1;
112 }
113 int64_t put_Xset_field_internal(const Ioss::EntitySet *ns, const Ioss::Field &field, void *data,
114 size_t data_size) const;
115 int64_t get_Xset_field_internal(const Ioss::EntitySet *ns, const Ioss::Field &field, void *data,
116 size_t data_size) const;
117
120
122
123 // Metadata-related functions.
124 void read_meta_data_nl() override;
126
127 int64_t read_transient_field(const Ioexnl::VariableNameMap &variables, const Ioss::Field &field,
128 const Ioss::GroupingEntity *ge, void *data) const;
129
131 void *data) const;
132
133 int64_t write_attribute_field(const Ioss::Field &field, const Ioss::GroupingEntity *ge,
134 void *data) const;
135
136 // Handles subsetting of side blocks.
137 int64_t read_ss_transient_field(const Ioss::Field &field, int64_t id, void *variables,
138 std::vector<int> &is_valid_side) const;
139
140 // Should be made more generic again so can rejoin with write_element_transient field
141 void write_nodal_transient_field(const Ioss::Field &field, const Ioss::NodeBlock *ge,
142 int64_t count, void *variables) const;
143 // Should be made more generic again so can rejoin with write_nodal_transient field
144 void write_entity_transient_field(const Ioss::Field &field, const Ioss::GroupingEntity *ge,
145 int64_t count, void *variables) const;
146 void write_meta_data(Ioss::IfDatabaseExistsBehavior behavior) override;
147 void gather_communication_metadata(Ioexnl::CommunicationMetaData *meta);
148
149 // Read related metadata and store it in the region...
150 void read_region();
154 void get_blocks(ex_entity_type entity_type, int rank_offset, const std::string &basename);
155
157
158 template <typename T>
159 void get_sets(ex_entity_type type, int64_t count, const std::string &base,
160 const T * /*unused*/);
165
167
168 // ID Mapping functions.
169 IOSS_NODISCARD const Ioss::Map &get_map(ex_entity_type type) const;
170 IOSS_NODISCARD const Ioss::Map &get_map(Ioss::Map &entity_map, int64_t entity_count,
171 ex_entity_type entity_type,
172 ex_inquiry inquiry_type) const;
173
174 // Internal data handling
175 int64_t handle_node_ids(void *ids, int64_t num_to_get) const;
176 int64_t handle_element_ids(const Ioss::ElementBlock *eb, void *ids, size_t num_to_get) const;
177 int64_t handle_face_ids(const Ioss::FaceBlock *eb, void *ids, size_t num_to_get) const;
178 int64_t handle_edge_ids(const Ioss::EdgeBlock *eb, void *ids, size_t num_to_get) const;
179
180 int64_t get_side_connectivity(const Ioss::SideBlock *sd_blk, int64_t id, int64_t my_side_count,
181 void *fconnect, bool map_ids) const;
182 template <typename INT>
183 int64_t get_side_connectivity_internal(const Ioss::SideBlock *sd_blk, int64_t id,
184 int64_t side_count, INT *fconnect, bool map_ids) const;
185 int64_t get_side_distributions(const Ioss::SideBlock *sd_blk, int64_t id, int64_t my_side_count,
186 double *dist_fact, size_t data_size) const;
187
188 int64_t get_side_field(const Ioss::SideBlock *sd_blk, const Ioss::Field &field, void *data,
189 size_t data_size) const;
190 int64_t put_side_field(const Ioss::SideBlock *sd_blk, const Ioss::Field &field, void *data,
191 size_t data_size) const;
192
193 //!< true if application code is controlling the processor id.
194 mutable bool isSerialParallel{false};
195 };
196} // namespace Ioexnl
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
int Ioss_MPI_Comm
Definition Ioss_CodeTypes.h:64
Definition Ioexnl_BaseDatabaseIO.h:78
Definition Ioexnl_DatabaseIO.h:62
void get_blocks(ex_entity_type entity_type, int rank_offset, const std::string &basename)
int64_t get_side_distributions(const Ioss::SideBlock *sd_blk, int64_t id, int64_t my_side_count, double *dist_fact, size_t data_size) const
int64_t read_attribute_field(const Ioss::Field &field, const Ioss::GroupingEntity *ge, void *data) const
void get_sets(ex_entity_type type, int64_t count, const std::string &base, const T *)
IOSS_NODISCARD const Ioss::Map & get_map(ex_entity_type type) const
int64_t get_side_field(const Ioss::SideBlock *sd_blk, const Ioss::Field &field, void *data, size_t data_size) const
void read_communication_metadata()
IOSS_NODISCARD const Ioss::Map & get_map(Ioss::Map &entity_map, int64_t entity_count, ex_entity_type entity_type, ex_inquiry inquiry_type) const
int64_t read_ss_transient_field(const Ioss::Field &field, int64_t id, void *variables, std::vector< int > &is_valid_side) const
int64_t get_side_connectivity(const Ioss::SideBlock *sd_blk, int64_t id, int64_t my_side_count, void *fconnect, bool map_ids) const
int64_t put_side_field(const Ioss::SideBlock *sd_blk, const Ioss::Field &field, void *data, size_t data_size) const
true if application code is controlling the processor id.
int64_t read_nodal_coordinates()
void read_elements(const Ioss::ElementBlock &block)
void compute_node_status() const
int64_t read_transient_field(const Ioexnl::VariableNameMap &variables, const Ioss::Field &field, const Ioss::GroupingEntity *ge, void *data) const
int64_t put_field_internal(const Ioss::StructuredBlock *, const Ioss::Field &, void *, size_t) const override
Definition Ioexnl_DatabaseIO.h:107
int64_t get_Xset_field_internal(const Ioss::EntitySet *ns, const Ioss::Field &field, void *data, size_t data_size) const
int64_t get_side_connectivity_internal(const Ioss::SideBlock *sd_blk, int64_t id, int64_t side_count, INT *fconnect, bool map_ids) const
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
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
DatabaseUsage
Specifies how an Ioss::DatabaseIO object will be used.
Definition Ioss_DBUsage.h:13
IfDatabaseExistsBehavior
Definition Ioss_DBUsage.h:32
Definition Ioexnl_Internals.h:264