IOSS 2.0
Loading...
Searching...
No Matches
Ioexnl_Internals.h
Go to the documentation of this file.
1/*
2 * Copyright(C) 1999-2024 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8
9#pragma once
10
11#include <cstdint> // for int64_t
12#include <exodusII.h> // for MAX_LINE_LENGTH, etc
13#include <string> // for string
14#include <vector> // for vector
15
16#include "Ioss_ParallelUtils.h" // for ParallelUtils
17#include "Ioss_Utils.h"
18#include "ioexnl_export.h"
19
20namespace Ioss {
21 class Assembly;
22 class Blob;
23 class EdgeBlock;
24 class EdgeSet;
25 class ElementBlock;
26 class ElementSet;
27 class FaceBlock;
28 class FaceSet;
29 class NodeBlock;
30 class NodeSet;
31 class SideBlock;
32 class SideSet;
33 class Region;
34} // namespace Ioss
35
36using entity_id = int64_t;
37
38namespace Ioss {
39} // namespace Ioss
40/*!
41 * This set of classes provides a thin wrapper around the exodusII
42 * internals. It supplants several of the exodusII API calls in
43 * order to avoid ncredef calls which totally rewrite the existing
44 * database and can be very expensive. These routines provide all
45 * required variable, dimension, and attribute definitions to the
46 * underlying netcdf file with only a single ncredef call.
47 *
48 * To use the application must create an Internals instance
49 * and call the Internals::write_meta_data() function. This
50 * function requires several classes as arguments including:
51 * <ul>
52 * <li> Mesh -- defines mesh global metadata
53 * <li> Block -- defines metadata for each block
54 * <li> NodeSet -- defines metadata for each nodeset
55 * <li> SideSet -- defines metadata for each sideset
56 * <li> CommunicationMetaData -- global metadata relating to
57 * parallel info.
58 * </ul>
59 *
60 * Calling Internals::write_meta_data(), replaces the
61 * following exodusII and nemesis API calls:
62 * <ul>
63 * <li> ex_put_init(),
64 * <li> ex_put_elem_block(),
65 * <li> ex_put_node_set_param(),
66 * <li> ex_put_side_set_param(),
67 * <li> ne_put_init_info(),
68 * <li> ne_put_loadbal_param(),
69 * <li> ne_put_cmap_params(),
70 * </ul>
71 */
72namespace Ioexnl {
73 struct IOEXNL_EXPORT NodeBlock
74 {
75 explicit NodeBlock(const Ioss::NodeBlock &other);
76
77 std::string name{};
78 entity_id id{0};
79 int64_t entityCount{0};
80 int64_t localOwnedCount{0};
81 int64_t attributeCount{0};
82 int64_t procOffset{0};
83 };
84
85 struct IOEXNL_EXPORT Assembly
86 {
87 explicit Assembly(const Ioss::Assembly &other);
88
89 std::string name{};
90 entity_id id{0};
91 int64_t entityCount{0};
92 int64_t attributeCount{0};
93 ex_entity_type type{};
94 std::vector<int64_t> memberIdList;
95 };
96
97 struct IOEXNL_EXPORT Blob
98 {
99 explicit Blob(const Ioss::Blob &other);
100
101 std::string name{};
103 int64_t entityCount{0};
104 int64_t localOwnedCount{0};
105 int64_t attributeCount{0};
106 int64_t procOffset{0};
107 };
108
109 struct IOEXNL_EXPORT EdgeBlock
110 {
112
113 EdgeBlock(const EdgeBlock &other)
114 : name(other.name), id(other.id), entityCount(other.entityCount),
117 {
119 }
120
121 explicit EdgeBlock(const Ioss::EdgeBlock &other);
122
123 char elType[MAX_STR_LENGTH + 1]{};
124 std::string name{};
126 int64_t entityCount{0};
127 int64_t nodesPerEntity{0};
128 int64_t attributeCount{0};
129 int64_t procOffset{0};
130
131 private:
132 };
133
134 struct IOEXNL_EXPORT FaceBlock
135 {
137
145
146 explicit FaceBlock(const Ioss::FaceBlock &other);
147
148 char elType[MAX_STR_LENGTH + 1]{};
149 std::string name{};
151 int64_t entityCount{0};
152 int64_t nodesPerEntity{0};
153 int64_t edgesPerEntity{0};
154 int64_t attributeCount{0};
155 int64_t procOffset{0};
156
157 private:
158 };
159
160 struct IOEXNL_EXPORT ElemBlock
161 {
163
172
173 explicit ElemBlock(const Ioss::ElementBlock &other);
174
175 char elType[MAX_STR_LENGTH + 1]{};
176 std::string name{};
178 int64_t entityCount{0};
180 int64_t nodesPerEntity{0};
181 int64_t edgesPerEntity{0};
182 int64_t facesPerEntity{0};
183 int64_t attributeCount{0};
184 int64_t offset_{-1};
185 int64_t procOffset{0};
186 };
187
188 struct IOEXNL_EXPORT NodeSet
189 {
190 explicit NodeSet(const Ioss::NodeSet &other);
191
192 std::string name{};
194 int64_t entityCount{0};
196 int64_t localOwnedCount{0};
197 int64_t attributeCount{0};
198 int64_t dfCount{0};
199 int64_t procOffset{0};
200 };
201
202 struct IOEXNL_EXPORT EdgeSet
203 {
204 explicit EdgeSet(const Ioss::EdgeSet &other);
205
206 std::string name{};
208 int64_t entityCount{0};
209 int64_t attributeCount{0};
210 int64_t dfCount{0};
211 int64_t procOffset{0};
212 };
213
214 struct IOEXNL_EXPORT FaceSet
215 {
216 explicit FaceSet(const Ioss::FaceSet &other);
217
218 std::string name{};
220 int64_t entityCount{0};
221 int64_t attributeCount{0};
222 int64_t dfCount{0};
223 int64_t procOffset{0};
224 };
225
226 struct IOEXNL_EXPORT ElemSet
227 {
228 explicit ElemSet(const Ioss::ElementSet &other);
229
230 std::string name{};
232 int64_t entityCount{0};
233 int64_t attributeCount{0};
234 int64_t dfCount{0};
235 int64_t procOffset{0};
236 };
237
238 struct IOEXNL_EXPORT SideSet
239 {
240 explicit SideSet(const Ioss::SideBlock &other);
241 explicit SideSet(const Ioss::SideSet &other);
242
243 std::string name{};
245 int64_t entityCount{0};
247 int64_t dfCount{0};
248 int64_t procOffset{0};
249 int64_t dfProcOffset{0};
250 };
251
252 struct IOEXNL_EXPORT CommunicationMap
253 {
254 CommunicationMap(entity_id the_id, int64_t count, char the_type)
255 : id(the_id), entityCount(count), type(the_type)
256 {
257 }
259 int64_t entityCount{0};
260 char type{'U'}; // 'n' for node, 'e' for element
261 };
262
263 struct IOEXNL_EXPORT CommunicationMetaData
264 {
265 std::vector<CommunicationMap> nodeMap{};
266 std::vector<CommunicationMap> elementMap{};
269 int64_t globalNodes{0};
270 int64_t globalElements{0};
272 int64_t globalNodeSets{0};
273 int64_t globalSideSets{0};
274 int64_t nodesInternal{0};
275 int64_t nodesBorder{0};
276 int64_t nodesExternal{0};
278 int64_t elementsBorder{0};
279 bool outputNemesis{false};
280 };
281
282 class IOEXNL_EXPORT Redefine
283 {
284 public:
285 explicit Redefine(int exoid);
286 Redefine(const Redefine &from) = delete;
287 Redefine &operator=(const Redefine &from) = delete;
288
289 private:
291 };
292
293 class IOEXNL_EXPORT Mesh
294 {
295 public:
296 Mesh(int dim, const char *the_title, const Ioss::ParallelUtils &util, bool file_pp)
297 : dimensionality(dim), file_per_processor(file_pp), parallelUtil(util)
298 {
300 }
301
302 void populate(Ioss::Region *region);
303 void get_global_counts();
304
305 char title[MAX_LINE_LENGTH + 1]{};
308 bool use_node_map{true};
309 bool use_elem_map{true};
310 bool use_face_map{true};
311 bool use_edge_map{true};
313
314 std::vector<Assembly> assemblies{};
315 std::vector<Blob> blobs{};
316
317 std::vector<NodeBlock> nodeblocks{};
318 std::vector<EdgeBlock> edgeblocks{};
319 std::vector<FaceBlock> faceblocks{};
320 std::vector<ElemBlock> elemblocks{};
321 std::vector<NodeSet> nodesets{};
322 std::vector<EdgeSet> edgesets{};
323 std::vector<FaceSet> facesets{};
324 std::vector<ElemSet> elemsets{};
325 std::vector<SideSet> sidesets{};
328 };
329} // namespace Ioexnl
int64_t entity_id
Definition Ioex_Internals.h:36
std::vector< Assembly > assemblies
Definition Ioexnl_Internals.h:314
std::vector< ElemSet > elemsets
Definition Ioexnl_Internals.h:324
char title[MAX_LINE_LENGTH+1]
Definition Ioexnl_Internals.h:305
std::vector< Blob > blobs
Definition Ioexnl_Internals.h:315
bool use_elem_map
Definition Ioexnl_Internals.h:309
std::vector< FaceBlock > faceblocks
Definition Ioexnl_Internals.h:319
CommunicationMetaData comm
Definition Ioexnl_Internals.h:326
std::vector< EdgeSet > edgesets
Definition Ioexnl_Internals.h:322
bool full_nemesis_data
Definition Ioexnl_Internals.h:312
std::vector< ElemBlock > elemblocks
Definition Ioexnl_Internals.h:320
std::vector< NodeBlock > nodeblocks
Definition Ioexnl_Internals.h:317
int dimensionality
Definition Ioexnl_Internals.h:306
Mesh(int dim, const char *the_title, const Ioss::ParallelUtils &util, bool file_pp)
Definition Ioexnl_Internals.h:296
Ioss::ParallelUtils parallelUtil
Definition Ioexnl_Internals.h:327
std::vector< EdgeBlock > edgeblocks
Definition Ioexnl_Internals.h:318
std::vector< NodeSet > nodesets
Definition Ioexnl_Internals.h:321
bool use_face_map
Definition Ioexnl_Internals.h:310
std::vector< SideSet > sidesets
Definition Ioexnl_Internals.h:325
bool file_per_processor
Definition Ioexnl_Internals.h:307
std::vector< FaceSet > facesets
Definition Ioexnl_Internals.h:323
bool use_edge_map
Definition Ioexnl_Internals.h:311
bool use_node_map
Definition Ioexnl_Internals.h:308
int exodusFilePtr
Definition Ioexnl_Internals.h:290
Redefine(const Redefine &from)=delete
Redefine & operator=(const Redefine &from)=delete
Redefine(int exoid)
A homogeneous collection of other GroupingEntities.
Definition Ioss_Assembly.h:31
A homogeneous collection of other GroupingEntities.
Definition Ioss_Blob.h:31
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
A collection of all nodes in the region.
Definition Ioss_NodeBlock.h:33
A collection of nodes.
Definition Ioss_NodeSet.h:29
Definition Ioss_ParallelUtils.h:32
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
static void copy_string(char *dest, char const *source, size_t elements)
Definition Ioss_Utils.C:1293
A namespace for the exodus database format.
Definition Ioexnl_BaseDatabaseIO.C:93
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
std::vector< int64_t > memberIdList
Definition Ioexnl_Internals.h:94
std::string name
Definition Ioexnl_Internals.h:89
int64_t entityCount
Definition Ioexnl_Internals.h:91
ex_entity_type type
Definition Ioexnl_Internals.h:93
int64_t attributeCount
Definition Ioexnl_Internals.h:92
Assembly(const Ioss::Assembly &other)
Definition Ioexnl_Internals.C:44
int64_t entityCount
Definition Ioexnl_Internals.h:103
int64_t localOwnedCount
Definition Ioexnl_Internals.h:104
int64_t attributeCount
Definition Ioexnl_Internals.h:105
int64_t procOffset
Definition Ioexnl_Internals.h:106
std::string name
Definition Ioexnl_Internals.h:101
Blob(const Ioss::Blob &other)
Definition Ioexnl_Internals.C:65
entity_id id
Definition Ioexnl_Internals.h:258
int64_t entityCount
Definition Ioexnl_Internals.h:259
CommunicationMap(entity_id the_id, int64_t count, char the_type)
Definition Ioexnl_Internals.h:254
char type
Definition Ioexnl_Internals.h:260
Definition Ioexnl_Internals.h:264
int64_t globalSideSets
Definition Ioexnl_Internals.h:273
int64_t nodesExternal
Definition Ioexnl_Internals.h:276
std::vector< CommunicationMap > elementMap
Definition Ioexnl_Internals.h:266
int64_t elementsInternal
Definition Ioexnl_Internals.h:277
int processorCount
Definition Ioexnl_Internals.h:268
int64_t globalNodes
Definition Ioexnl_Internals.h:269
int64_t globalNodeSets
Definition Ioexnl_Internals.h:272
int64_t nodesBorder
Definition Ioexnl_Internals.h:275
int64_t globalElementBlocks
Definition Ioexnl_Internals.h:271
std::vector< CommunicationMap > nodeMap
Definition Ioexnl_Internals.h:265
int64_t nodesInternal
Definition Ioexnl_Internals.h:274
int64_t elementsBorder
Definition Ioexnl_Internals.h:278
bool outputNemesis
Definition Ioexnl_Internals.h:279
int processorId
Definition Ioexnl_Internals.h:267
int64_t globalElements
Definition Ioexnl_Internals.h:270
Definition Ioexnl_Internals.h:110
entity_id id
Definition Ioexnl_Internals.h:125
int64_t attributeCount
Definition Ioexnl_Internals.h:128
EdgeBlock()
Definition Ioexnl_Internals.h:111
std::string name
Definition Ioexnl_Internals.h:124
int64_t entityCount
Definition Ioexnl_Internals.h:126
char elType[MAX_STR_LENGTH+1]
Definition Ioexnl_Internals.h:123
int64_t nodesPerEntity
Definition Ioexnl_Internals.h:127
int64_t procOffset
Definition Ioexnl_Internals.h:129
EdgeBlock(const EdgeBlock &other)
Definition Ioexnl_Internals.h:113
int64_t dfCount
Definition Ioexnl_Internals.h:210
EdgeSet(const Ioss::EdgeSet &other)
Definition Ioexnl_Internals.C:214
int64_t procOffset
Definition Ioexnl_Internals.h:211
std::string name
Definition Ioexnl_Internals.h:206
int64_t entityCount
Definition Ioexnl_Internals.h:208
int64_t attributeCount
Definition Ioexnl_Internals.h:209
Definition Ioexnl_Internals.h:161
int64_t offset_
Definition Ioexnl_Internals.h:184
int64_t edgesPerEntity
Definition Ioexnl_Internals.h:181
ElemBlock()
Definition Ioexnl_Internals.h:162
int64_t facesPerEntity
Definition Ioexnl_Internals.h:182
int64_t procOffset
Definition Ioexnl_Internals.h:185
char elType[MAX_STR_LENGTH+1]
Definition Ioexnl_Internals.h:175
std::string name
Definition Ioexnl_Internals.h:176
int64_t nodesPerEntity
Definition Ioexnl_Internals.h:180
int64_t entityCount
Definition Ioexnl_Internals.h:178
ElemBlock(const ElemBlock &other)
Definition Ioexnl_Internals.h:164
int64_t globalEntityCount
Definition Ioexnl_Internals.h:179
int64_t attributeCount
Definition Ioexnl_Internals.h:183
entity_id id
Definition Ioexnl_Internals.h:177
std::string name
Definition Ioexnl_Internals.h:230
int64_t entityCount
Definition Ioexnl_Internals.h:232
int64_t procOffset
Definition Ioexnl_Internals.h:235
ElemSet(const Ioss::ElementSet &other)
Definition Ioexnl_Internals.C:246
int64_t dfCount
Definition Ioexnl_Internals.h:234
int64_t attributeCount
Definition Ioexnl_Internals.h:233
Definition Ioexnl_Internals.h:135
int64_t attributeCount
Definition Ioexnl_Internals.h:154
int64_t nodesPerEntity
Definition Ioexnl_Internals.h:152
entity_id id
Definition Ioexnl_Internals.h:150
char elType[MAX_STR_LENGTH+1]
Definition Ioexnl_Internals.h:148
int64_t procOffset
Definition Ioexnl_Internals.h:155
int64_t entityCount
Definition Ioexnl_Internals.h:151
std::string name
Definition Ioexnl_Internals.h:149
FaceBlock(const FaceBlock &other)
Definition Ioexnl_Internals.h:138
int64_t edgesPerEntity
Definition Ioexnl_Internals.h:153
FaceBlock()
Definition Ioexnl_Internals.h:136
std::string name
Definition Ioexnl_Internals.h:218
FaceSet(const Ioss::FaceSet &other)
Definition Ioexnl_Internals.C:230
int64_t procOffset
Definition Ioexnl_Internals.h:223
int64_t dfCount
Definition Ioexnl_Internals.h:222
int64_t attributeCount
Definition Ioexnl_Internals.h:221
int64_t entityCount
Definition Ioexnl_Internals.h:220
int64_t localOwnedCount
Definition Ioexnl_Internals.h:80
NodeBlock(const Ioss::NodeBlock &other)
Definition Ioexnl_Internals.C:79
std::string name
Definition Ioexnl_Internals.h:77
int64_t attributeCount
Definition Ioexnl_Internals.h:81
int64_t entityCount
Definition Ioexnl_Internals.h:79
int64_t procOffset
Definition Ioexnl_Internals.h:82
std::string name
Definition Ioexnl_Internals.h:192
int64_t localOwnedCount
Definition Ioexnl_Internals.h:196
int64_t entityCount
Definition Ioexnl_Internals.h:194
int64_t globalEntityCount
Definition Ioexnl_Internals.h:195
NodeSet(const Ioss::NodeSet &other)
Definition Ioexnl_Internals.C:193
int64_t dfCount
Definition Ioexnl_Internals.h:198
int64_t procOffset
Definition Ioexnl_Internals.h:199
int64_t attributeCount
Definition Ioexnl_Internals.h:197
int64_t dfCount
Definition Ioexnl_Internals.h:247
int64_t procOffset
Definition Ioexnl_Internals.h:248
std::string name
Definition Ioexnl_Internals.h:243
int64_t dfProcOffset
Definition Ioexnl_Internals.h:249
int64_t entityCount
Definition Ioexnl_Internals.h:245
SideSet(const Ioss::SideBlock &other)
Definition Ioexnl_Internals.C:262
int64_t globalEntityCount
Definition Ioexnl_Internals.h:246