Debian Codegraph @

packages/seacas/libraries/ioss/src/main/io_info.C

raw
1 // Copyright(C) 1999-2025 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 #include "io_info.h"
8
9 #include "Ioss_Hex8.h"
10 #include "Ioss_Sort.h"
11 #include "Ioss_StructuredBlock.h"
12 #include "Ioss_ZoneConnectivity.h"
13 #include <fmt/core.h>
14 #include <fmt/ranges.h>
15 #include <stdint.h>
16 #include <tokenize.h>
17
18 #define FMT_DEPRECATED_OSTREAM
19 #include <cstddef>
20 #include <cstdlib>
21 #include <fmt/format.h>
22 #include <iostream>
23 #include <string>
24 #include <vector>
25
26 #include "Ioss_Assembly.h"
27 #include "Ioss_Blob.h"
28 #include "Ioss_BoundingBox.h"
29 #include "Ioss_CoordinateFrame.h"
30 #include "Ioss_DBUsage.h"
31 #include "Ioss_DataSize.h"
32 #include "Ioss_DatabaseIO.h"
33 #include "Ioss_EdgeBlock.h"
34 #include "Ioss_EdgeSet.h"
35 #include "Ioss_ElementBlock.h"
36 #include "Ioss_ElementSet.h"
37 #include "Ioss_ElementTopology.h"
38 #include "Ioss_FaceBlock.h"
39 #include "Ioss_FaceSet.h"
40 #include "Ioss_Field.h"
41 #include "Ioss_GroupingEntity.h"
42 #include "Ioss_IOFactory.h"
43 #include "Ioss_NodeBlock.h"
44 #include "Ioss_NodeSet.h"
45 #include "Ioss_ParallelUtils.h"
46 #include "Ioss_Property.h"
47 #include "Ioss_PropertyManager.h"
48 #include "Ioss_Region.h"
49 #include "Ioss_SideBlock.h"
50 #include "Ioss_SideSet.h"
51 #include "Ioss_SurfaceSplit.h"
52 #include "Ioss_Utils.h"
53 #include "Ioss_VariableType.h"
54 #include "Ioss_use_fmt.h"
55 #if defined(SEACAS_HAVE_EXODUS)
56 #include "exodusII.h"
57 #endif
58 #include "info_interface.h"
59 #if defined(SEACAS_HAVE_CGNS)
60 #include <cgnslib.h>
61 #endif
62
63 // ========================================================================
64
65 namespace {
66 void info_timesteps(Ioss::Region &region);
67 void info_nodeblock(Ioss::Region &region, const Info::Interface &interFace);
68 void info_edgeblock(Ioss::Region &region, const Info::Interface &interFace);
69 void info_faceblock(Ioss::Region &region, const Info::Interface &interFace);
70 void info_elementblock(Ioss::Region &region, const Info::Interface &interFace);
71 void info_structuredblock(Ioss::Region &region, const Info::Interface &interFace);
72
73 void info_nodesets(Ioss::Region &region, const Info::Interface &interFace);
74 void info_edgesets(Ioss::Region &region, const Info::Interface &interFace);
75 void info_facesets(Ioss::Region &region, const Info::Interface &interFace);
76 void info_elementsets(Ioss::Region &region, const Info::Interface &interFace);
77
78 void info_sidesets(Ioss::Region &region, const Info::Interface &interFace);
79 void info_coordinate_frames(Ioss::Region &region);
80 void info_assemblies(Ioss::Region &region);
81 void info_region(Ioss::Region &region);
82 void info_blobs(Ioss::Region &region);
83
84 void info_aliases(const Ioss::Region &region, const Ioss::GroupingEntity *ige, bool nl_pre,
85 bool nl_post);
86
87 void info_variable_types()
88 {
89 auto var_list = Ioss::VariableType::external_types(Ioss::VariableType::Type::UNKNOWN);
90 for (auto &var : var_list) {
91 var->print();
92 }
93 }
94
95 void file_info(const Info::Interface &interFace);
96 void change_set_info(Info::Interface &interFace);
97
98 void info_df(const Ioss::GroupingEntity *ge, const std::string &prefix)
99 {
100 int64_t num_dist = ge->get_property("distribution_factor_count").get_int();
101 std::vector<double> df;
102 // Do even if num_dist == 0 so parallel does not assert.
103 if (ge->field_exists("distribution_factors")) {
104 ge->get_field_data("distribution_factors", df);
105 }
106 if (num_dist > 0) {
107 auto mm = std::minmax_element(df.begin(), df.end());
108 fmt::print("{}Distribution Factors: ", prefix);
109 if (*mm.first == *mm.second) {
110 fmt::print("all values = {:#}\n", *mm.first);
111 }
112 else {
113 fmt::print("minimum value = {:#}, maximum value = {:#}\n", *mm.first, *mm.second);
114 }
115 }
116 }
117
118 template <typename T> void print_bbox(const T &entity)
119 {
120 Ioss::AxisAlignedBoundingBox bbox = entity.get_bounding_box();
121 fmt::print("\tBounding Box: Minimum X,Y,Z = {:12.4e}\t{:12.4e}\t{:12.4e}\n"
122 "\t Maximum X,Y,Z = {:12.4e}\t{:12.4e}\t{:12.4e}\n"
123 "\t Range X,Y,Z = {:12.4e}\t{:12.4e}\t{:12.4e}\n",
124 bbox.xmin, bbox.ymin, bbox.zmin, bbox.xmax, bbox.ymax, bbox.zmax,
125 bbox.xmax - bbox.xmin, bbox.ymax - bbox.ymin, bbox.zmax - bbox.zmin);
126 }
127
128 std::string name(const Ioss::GroupingEntity *entity)
129 {
130 return entity->type_string() + " '" + entity->name() + "'";
131 }
132
133 int64_t id(Ioss::GroupingEntity *entity)
134 {
135 int64_t id = entity->get_optional_property("id", -1);
136 return id;
137 }
138
139 Ioss::PropertyManager set_properties(const Info::Interface &interFace)
140 {
141 Ioss::PropertyManager properties{};
142 if (!interFace.decomp_method().empty()) {
143 properties.add(Ioss::Property("DECOMPOSITION_METHOD", interFace.decomp_method()));
144 }
145 return properties;
146 }
147 } // namespace
148
149 void hex_volume(Ioss::ElementBlock *block, const std::vector<double> &coordinates);
150
151 namespace {
152 void element_volume(Ioss::Region &region)
153 {
154 std::vector<double> coordinates;
155 Ioss::NodeBlock *nb = region.get_node_blocks()[0];
156 nb->get_field_data("mesh_model_coordinates", coordinates);
157
158 const Ioss::ElementBlockContainer &ebs = region.get_element_blocks();
159 for (auto &eb : ebs) {
160 if (eb->topology()->name() == Ioss::Hex8::name) {
161 hex_volume(eb, coordinates);
162 }
163 }
164 }
165
166 void change_set_info(Info::Interface &interFace)
167 {
168 std::string inpfile = interFace.filename();
169 std::string input_type = interFace.type();
170 Ioss::PropertyManager properties = set_properties(interFace);
171
172 auto mode = Ioss::READ_RESTART;
173 Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(input_type, inpfile, mode,
174 Ioss::ParallelUtils::comm_world(), properties);
175
176 Ioss::io_info_set_db_properties(interFace, dbi);
177 auto cs_names = dbi->internal_change_set_describe();
178 fmt::print("\t/ (root)\n");
179 for (const auto &cs_name : cs_names) {
180 fmt::print("\t\t{}\n", cs_name);
181 }
182 }
183
184 void file_info(const Info::Interface &interFace)
185 {
186 std::string inpfile = interFace.filename();
187 std::string input_type = interFace.type();
188
189 Ioss::PropertyManager properties = set_properties(interFace);
190
191 const auto custom_field = interFace.custom_field();
192 if (!custom_field.empty()) {
193 auto suffices = Ioss::tokenize(custom_field, ",");
194 if (suffices.size() > 1) {
195 Ioss::VariableType::create_named_suffix_type("UserDefined", suffices);
196 }
197 }
198
199 //========================================================================
200 // INPUT ...
201 // NOTE: The "READ_RESTART" mode ensures that the node and element ids will be mapped.
202 //========================================================================
203 auto mode = interFace.query_timesteps_only() ? Ioss::QUERY_TIMESTEPS_ONLY : Ioss::READ_RESTART;
204 Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(input_type, inpfile, mode,
205 Ioss::ParallelUtils::comm_world(), properties);
206
207 Ioss::io_info_set_db_properties(interFace, dbi);
208
209 // NOTE: 'region' owns 'db' pointer at this time...
210 Ioss::Region region(dbi, "region_1");
211 if (interFace.query_timesteps_only()) {
212 info_timesteps(region);
213 }
214 else {
215 auto cs_list = Ioss::tokenize(interFace.change_set_name(), ",");
216 if (cs_list.empty()) {
217 cs_list.push_back("/");
218 }
219 else {
220 if (cs_list[0] == "ALL") {
221 cs_list = dbi->internal_change_set_describe();
222 }
223 }
224
225 bool first = true;
226 for (const auto &cs_name : cs_list) {
227 if (!first) {
228 fmt::print("-----------------------------------------------------------------------------"
229 "-----------------------\n");
230 }
231 if (cs_name != "/") {
232 bool success = region.load_internal_change_set_mesh(cs_name);
233 if (!success) {
234 fmt::print("ERROR: Unable to open change set '{}' in file '{}'\n", cs_name, inpfile);
235 return;
236 }
237 first = false;
238 }
239 Ioss::io_info_file_info(interFace, region);
240 }
241 }
242 }
243
244 void info_nodeblock(Ioss::Region &region, const Ioss::NodeBlock &nb,
245 const Info::Interface &interFace, const std::string &prefix = "")
246 {
247 int64_t num_nodes = nb.entity_count();
248 int64_t num_attrib = nb.get_property("attribute_count").get_int();
249 fmt::print("\n{}{} {:14} nodes, {:3d} attributes.\n", prefix, name(&nb),
250 fmt::group_digits(num_nodes), num_attrib);
251 if (interFace.check_node_status()) {
252 std::vector<char> node_status;
253 std::vector<int64_t> ids;
254 nb.get_field_data("node_connectivity_status", node_status);
255 nb.get_field_data("ids", ids);
256 bool header = false;
257 for (size_t j = 0; j < node_status.size(); j++) {
258 if (node_status[j] == 0) {
259 if (!header) {
260 header = true;
261 fmt::print("\t{}Unconnected nodes: {}", prefix, ids[j]);
262 }
263 else {
264 fmt::print(", {}", ids[j]);
265 }
266 }
267 }
268 if (header) {
269 fmt::print("\n");
270 }
271 }
272 if (!nb.is_nonglobal_nodeblock()) {
273 info_aliases(region, &nb, false, true);
274 }
275 Ioss::Utils::info_fields(&nb, Ioss::Field::MAP, prefix + "\tMap Fields: ", "\n\t\t" + prefix);
276 Ioss::Utils::info_fields(&nb, Ioss::Field::ATTRIBUTE,
277 prefix + "\tAttributes: ", "\n\t\t" + prefix);
278 Ioss::Utils::info_fields(&nb, Ioss::Field::TRANSIENT,
279 prefix + "\tTransient: ", "\n\t\t" + prefix,
280 interFace.field_details());
281
282 if (interFace.compute_bbox() && region.mesh_type() != Ioss::MeshType::STRUCTURED) {
283 print_bbox(nb);
284 }
285 }
286
287 void info_nodeblock(Ioss::Region &region, const Info::Interface &interFace)
288 {
289 const Ioss::NodeBlockContainer &nbs = region.get_node_blocks();
290 for (const auto &nb : nbs) {
291 info_nodeblock(region, *nb, interFace, "");
292 }
293 }
294
295 void info_structuredblock(Ioss::Region &region, const Info::Interface &interFace)
296 {
297 bool parallel = region.get_database()->is_parallel();
298 const Ioss::StructuredBlockContainer &sbs = region.get_structured_blocks();
299 for (auto &sb : sbs) {
300 int64_t num_cell = sb->get_property("cell_count").get_int();
301 int64_t num_node = sb->get_property("node_count").get_int();
302
303 fmt::print("\n{} {}", name(sb), fmt::join(sb->get_ijk_global(), "x"));
304
305 if (parallel) {
306 fmt::print(" [{}, Offset = {}] ", fmt::join(sb->get_ijk_local(), "x"),
307 fmt::join(sb->get_ijk_offset(), ", "));
308 }
309
310 fmt::print(" {:14} cells, {:14} nodes ", fmt::group_digits(num_cell),
311 fmt::group_digits(num_node));
312
313 info_aliases(region, sb, true, false);
314 Ioss::Utils::info_fields(sb, Ioss::Field::TRANSIENT, "\n\tTransient: ", "\n\t",
315 interFace.field_details());
316 Ioss::Utils::info_fields(sb, Ioss::Field::REDUCTION, "\n\tTransient (Reduction): ", "\t");
317 info_nodeblock(region, sb->get_node_block(), interFace, "\t");
318 fmt::print("\n");
319
320 if (!sb->m_zoneConnectivity.empty()) {
321 fmt::print("\tConnectivity with other blocks:\n");
322 for (const auto &zgc : sb->m_zoneConnectivity) {
323 #if defined __NVCC__
324 std::cout << zgc << "\n";
325 #else
326 fmt::print("{}\n", zgc);
327 #endif
328 }
329 }
330 if (!sb->m_boundaryConditions.empty()) {
331 fmt::print("\tBoundary Conditions:\n");
332 // NOTE: The sort here is just to make io_info more useful for regression testing.
333 // With the sort, we get more reproducible output. For now, only needed for BC...
334 auto sb_bc = sb->m_boundaryConditions;
335 Ioss::sort(sb_bc.begin(), sb_bc.end(),
336 [](const Ioss::BoundaryCondition &a, const Ioss::BoundaryCondition &b) {
337 return a.m_bcName < b.m_bcName;
338 });
339
340 for (const auto &bc : sb_bc) {
341 #if defined __NVCC__
342 std::cout << bc << "\n";
343 #else
344 fmt::print("{}\n", bc);
345 #endif
346 }
347 }
348 if (interFace.compute_bbox()) {
349 print_bbox(*sb);
350 }
351 }
352 }
353
354 void info_region(Ioss::Region &region)
355 {
356 fmt::print("\nRegion '{}' (global)\n", region.name());
357 Ioss::Utils::info_property(&region, Ioss::Property::ATTRIBUTE,
358 "\tAttributes (Reduction): ", "\t");
359 Ioss::Utils::info_fields(&region, Ioss::Field::REDUCTION, "\tTransient (Reduction): ", "\t");
360 info_variable_types();
361 }
362
363 void info_assemblies(Ioss::Region &region)
364 {
365 const auto &assem = region.get_assemblies();
366 for (auto &as : assem) {
367 fmt::print("\n{} id: {:6d}, contains: {} member(s) of type {:>10s}.\n\tMembers: ", name(as),
368 id(as), as->member_count(), as->contains_string());
369 for (const auto &mem : as->get_members()) {
370 fmt::print("'{}', ", mem->name());
371 }
372
373 info_aliases(region, as, true, false);
374 fmt::print("\n");
375 Ioss::Utils::info_property(as, Ioss::Property::ATTRIBUTE, "\tAttributes (Reduction): ", "\t");
376 Ioss::Utils::info_fields(as, Ioss::Field::REDUCTION, "\tTransient (Reduction): ", "\t");
377 }
378 }
379
380 void info_blobs(Ioss::Region &region)
381 {
382 const auto &blobs = region.get_blobs();
383 for (auto &blob : blobs) {
384 fmt::print("\n{} id: {:6d}, contains: {} item(s).\n", name(blob), id(blob),
385 blob->entity_count());
386
387 info_aliases(region, blob, true, false);
388 fmt::print("\n");
389 Ioss::Utils::info_property(blob, Ioss::Property::ATTRIBUTE,
390 "\tAttributes (Reduction): ", "\t");
391 Ioss::Utils::info_fields(blob, Ioss::Field::TRANSIENT, "\tTransient: ", "\t");
392 Ioss::Utils::info_fields(blob, Ioss::Field::REDUCTION, "\tTransient (Reduction): ", "\t");
393 }
394 }
395
396 void info_elementblock(Ioss::Region &region, const Info::Interface &interFace)
397 {
398 const Ioss::ElementBlockContainer &ebs = region.get_element_blocks();
399 for (auto &eb : ebs) {
400 int64_t num_elem = eb->entity_count();
401
402 std::string type = eb->topology()->name();
403 int64_t num_attrib = eb->get_property("attribute_count").get_int();
404 fmt::print("\n{} id: {:6d}, topology: {:>10s}, {:14} elements, {:3d} attributes.", name(eb),
405 id(eb), type, fmt::group_digits(num_elem), num_attrib);
406
407 info_aliases(region, eb, true, false);
408 fmt::print("\n");
409 Ioss::Utils::info_fields(eb, Ioss::Field::MAP, "\n\tMap Fields: ");
410 Ioss::Utils::info_fields(eb, Ioss::Field::ATTRIBUTE, "\n\tAttributes: ");
411 Ioss::Utils::info_property(eb, Ioss::Property::ATTRIBUTE, "\tAttributes (Reduction): ", "\t");
412
413 if (interFace.adjacencies()) {
414 Ioss::NameList blocks = eb->get_block_adjacencies();
415 fmt::print("\tAdjacent to {} element block(s):\t", blocks.size());
416 for (const auto &block : blocks) {
417 fmt::print("{} ", block);
418 }
419 fmt::print("\n");
420 }
421 Ioss::Utils::info_fields(eb, Ioss::Field::TRANSIENT, "\n\tTransient: ", "\n\t",
422 interFace.field_details());
423 Ioss::Utils::info_fields(eb, Ioss::Field::REDUCTION, "\n\tTransient (Reduction): ");
424
425 if (interFace.compute_bbox()) {
426 print_bbox(*eb);
427 }
428 }
429 }
430
431 void info_edgeblock(Ioss::Region &region, const Info::Interface &interFace)
432 {
433 const Ioss::EdgeBlockContainer &ebs = region.get_edge_blocks();
434 for (auto &eb : ebs) {
435 int64_t num_edge = eb->entity_count();
436
437 std::string type = eb->topology()->name();
438 int64_t num_attrib = eb->get_property("attribute_count").get_int();
439 fmt::print("\n{} id: {:6d}, topology: {:>10s}, {:14} edges, {:3d} attributes.\n", name(eb),
440 id(eb), type, fmt::group_digits(num_edge), num_attrib);
441
442 info_aliases(region, eb, false, true);
443 Ioss::Utils::info_fields(eb, Ioss::Field::ATTRIBUTE, "\tAttributes: ");
444
445 #if 0
446 Ioss::NameList blocks = eb->get_block_adjacencies();
447 fmt::print("\tAdjacent to {} edge block(s):\t", blocks.size());
448 for (auto &block : blocks) {
449 fmt::print("{} ", block);
450 }
451 #endif
452 Ioss::Utils::info_fields(eb, Ioss::Field::TRANSIENT, "\n\tTransient: ", "\n\t",
453 interFace.field_details());
454 Ioss::Utils::info_fields(eb, Ioss::Field::REDUCTION, "\n\tTransient (Reduction): ");
455 fmt::print("\n");
456 }
457 }
458
459 void info_faceblock(Ioss::Region &region, const Info::Interface &interFace)
460 {
461 const Ioss::FaceBlockContainer &ebs = region.get_face_blocks();
462 for (auto &eb : ebs) {
463 int64_t num_face = eb->entity_count();
464
465 std::string type = eb->topology()->name();
466 int64_t num_attrib = eb->get_property("attribute_count").get_int();
467 fmt::print("\n{} id: {:6d}, topology: {:>10s}, {:14} faces, {:3d} attributes.\n", name(eb),
468 id(eb), type, fmt::group_digits(num_face), num_attrib);
469
470 info_aliases(region, eb, false, true);
471 Ioss::Utils::info_fields(eb, Ioss::Field::ATTRIBUTE, "\tAttributes: ");
472
473 #if 0
474 Ioss::NameList blocks = eb->get_block_adjacencies();
475 fmt::print("\tAdjacent to {} face block(s):\t", blocks.size());
476 for (auto &block : blocks) {
477 fmt::print("{} ", block);
478 }
479 #endif
480 Ioss::Utils::info_fields(eb, Ioss::Field::TRANSIENT, "\n\tTransient: ", "\n\t",
481 interFace.field_details());
482 Ioss::Utils::info_fields(eb, Ioss::Field::REDUCTION, "\n\tTransient (Reduction): ");
483 fmt::print("\n");
484 }
485 }
486
487 void info_sidesets(Ioss::Region &region, const Info::Interface &interFace)
488 {
489 const Ioss::SideSetContainer &fss = region.get_sidesets();
490 for (auto &fs : fss) {
491 fmt::print("\n{} id: {:6d}", name(fs), id(fs));
492 if (fs->property_exists("bc_type")) {
493 #if defined(SEACAS_HAVE_CGNS)
494 auto bc_type = fs->get_property("bc_type").get_int();
495 fmt::print(", boundary condition type: {} ({})", BCTypeName[bc_type], bc_type);
496 #else
497 fmt::print(", boundary condition type: {}", fs->get_property("bc_type").get_int());
498 #endif
499 }
500 info_aliases(region, fs, true, false);
501 Ioss::Utils::info_fields(fs, Ioss::Field::TRANSIENT, "\n\tTransient: ", "\n\t",
502 interFace.field_details());
503 Ioss::Utils::info_fields(fs, Ioss::Field::REDUCTION, "\n\tTransient (Reduction): ");
504 if (interFace.adjacencies()) {
505 Ioss::NameList blocks;
506 fs->block_membership(blocks);
507 fmt::print("\n\t\tTouches {} element block(s):\t", blocks.size());
508 for (const auto &block : blocks) {
509 fmt::print("{} ", block);
510 }
511 }
512 fmt::print("\n");
513 const Ioss::SideBlockContainer &fbs = fs->get_side_blocks();
514 for (auto &fb : fbs) {
515 int64_t count = fb->entity_count();
516 int64_t num_attrib = fb->get_property("attribute_count").get_int();
517 int64_t num_dist = fb->get_property("distribution_factor_count").get_int();
518 fmt::print("\t{}, {:8} sides, {:3d} attributes, {:8} distribution factors.\n", name(fb),
519 fmt::group_digits(count), num_attrib, fmt::group_digits(num_dist));
520 info_df(fb, "\t\t");
521 Ioss::Utils::info_fields(fb, Ioss::Field::TRANSIENT, "\t\tTransient: ", "\n\t\t",
522 interFace.field_details());
523 Ioss::Utils::info_fields(fb, Ioss::Field::REDUCTION,
524 "\t\tTransient (Reduction): ", "\n\t\t");
525 }
526 }
527 }
528
529 void info_nodesets(Ioss::Region &region, const Info::Interface &interFace)
530 {
531 const Ioss::NodeSetContainer &nss = region.get_nodesets();
532 for (auto &ns : nss) {
533 int64_t count = ns->entity_count();
534 int64_t num_attrib = ns->get_property("attribute_count").get_int();
535 int64_t num_dist = ns->get_property("distribution_factor_count").get_int();
536 fmt::print("\n{} id: {:6d}, {:8} nodes, {:3d} attributes, {:8} distribution factors.\n",
537 name(ns), id(ns), fmt::group_digits(count), num_attrib,
538 fmt::group_digits(num_dist));
539 info_aliases(region, ns, false, true);
540 info_df(ns, "\t");
541 Ioss::Utils::info_fields(ns, Ioss::Field::ATTRIBUTE, "\tAttributes: ");
542 Ioss::Utils::info_fields(ns, Ioss::Field::TRANSIENT, "\tTransient: ", "\n\t",
543 interFace.field_details());
544 Ioss::Utils::info_fields(ns, Ioss::Field::REDUCTION, "\tTransient (Reduction): ");
545 }
546 }
547
548 void info_edgesets(Ioss::Region &region, const Info::Interface &interFace)
549 {
550 const Ioss::EdgeSetContainer &nss = region.get_edgesets();
551 for (auto &ns : nss) {
552 int64_t count = ns->entity_count();
553 int64_t num_attrib = ns->get_property("attribute_count").get_int();
554 fmt::print("\n{} id: {:6d}, {:8} edges, {:3d} attributes.\n", name(ns), id(ns),
555 fmt::group_digits(count), num_attrib);
556 info_aliases(region, ns, false, true);
557 info_df(ns, "\t");
558 Ioss::Utils::info_fields(ns, Ioss::Field::ATTRIBUTE, "\tAttributes: ");
559 Ioss::Utils::info_fields(ns, Ioss::Field::TRANSIENT, "\tTransient: ", "\n\t",
560 interFace.field_details());
561 Ioss::Utils::info_fields(ns, Ioss::Field::REDUCTION, "\tTransient (Reduction): ");
562 }
563 }
564
565 void info_facesets(Ioss::Region &region, const Info::Interface &interFace)
566 {
567 const Ioss::FaceSetContainer &fss = region.get_facesets();
568 for (auto &fs : fss) {
569 int64_t count = fs->entity_count();
570 int64_t num_attrib = fs->get_property("attribute_count").get_int();
571 fmt::print("\n{} id: {:6d}, {:8} faces, {:3d} attributes.\n", name(fs), id(fs),
572 fmt::group_digits(count), num_attrib);
573 info_aliases(region, fs, false, true);
574 info_df(fs, "\t");
575 Ioss::Utils::info_fields(fs, Ioss::Field::ATTRIBUTE, "\tAttributes: ");
576 Ioss::Utils::info_fields(fs, Ioss::Field::TRANSIENT, "\tTransient: ", "\n\t",
577 interFace.field_details());
578 Ioss::Utils::info_fields(fs, Ioss::Field::REDUCTION, "\tTransient (Reduction): ");
579 }
580 }
581
582 void info_elementsets(Ioss::Region &region, const Info::Interface &interFace)
583 {
584 const Ioss::ElementSetContainer &ess = region.get_elementsets();
585 for (auto &es : ess) {
586 int64_t count = es->entity_count();
587 fmt::print("\n{} id: {:6d}, {:8} elements.\n", name(es), id(es), fmt::group_digits(count));
588 info_aliases(region, es, false, true);
589 info_df(es, "\t");
590 Ioss::Utils::info_fields(es, Ioss::Field::ATTRIBUTE, "\tAttributes: ");
591 Ioss::Utils::info_fields(es, Ioss::Field::TRANSIENT, "\tTransient: ", "\n\t",
592 interFace.field_details());
593 Ioss::Utils::info_fields(es, Ioss::Field::REDUCTION, "\tTransient (Reduction): ");
594 }
595 }
596
597 void info_coordinate_frames(Ioss::Region &region)
598 {
599 const Ioss::CoordinateFrameContainer &cf = region.get_coordinate_frames();
600 for (const auto &frame : cf) {
601 const double *origin = frame.origin();
602 const double *a3pt = frame.axis_3_point();
603 const double *p13pt = frame.plane_1_3_point();
604
605 fmt::print("\nCoordinate Frame id: {:6d}, type tag '{}'\n"
606 "\tOrigin: {}\t{}\t{}\n"
607 "\tAxis 3 Point: {}\t{}\t{}\n"
608 "\tPlane 1-3 Point: {}\t{}\t{}\n",
609 frame.id(), frame.tag(), origin[0], origin[1], origin[2], a3pt[0], a3pt[1],
610 a3pt[2], p13pt[0], p13pt[1], p13pt[2]);
611 }
612 }
613
614 void info_aliases(const Ioss::Region &region, const Ioss::GroupingEntity *ige, bool nl_pre,
615 bool nl_post)
616 {
617 Ioss::NameList aliases;
618 if (region.get_aliases(ige->name(), ige->type(), aliases) > 0) {
619 if (nl_pre) {
620 fmt::print("\n");
621 }
622 fmt::print("\tAliases: ");
623 for (size_t i = 0; i < aliases.size(); i++) {
624 if (aliases[i] != ige->name()) {
625 if (i > 0) {
626 fmt::print(", ");
627 }
628 fmt::print("{}", aliases[i]);
629 }
630 }
631 if (nl_post) {
632 fmt::print("\n");
633 }
634 }
635 }
636
637 void info_timesteps(Ioss::Region &region)
638 {
639 int step_count = (int)region.get_property("state_count").get_int();
640 std::vector<double> steps(step_count);
641
642 for (int step = 0; step < step_count; step++) {
643 double db_time = region.get_state_time(step + 1);
644 steps[step] = db_time;
645 }
646 auto mm = std::minmax_element(steps.begin(), steps.end());
647
648 fmt::print("\nThere are {} time steps on the database.\n", step_count);
649 fmt::print("\tMinimum Time = {:12.6e}, Maximum Time = {:12.6e}\n\n", *mm.first, *mm.second);
650
651 fmt::print("\tStep Times: {:12.6e}\n", fmt::join(steps, ", "));
652 }
653
654 } // namespace
655
656 namespace Ioss {
657 void io_info_file_info(const Info::Interface &interFace) { file_info(interFace); }
658 void io_info_change_set_info(Info::Interface &interFace) { change_set_info(interFace); }
659
660 void io_info_set_db_properties(const Info::Interface &interFace, Ioss::DatabaseIO *dbi)
661 {
662 if (dbi == nullptr || !dbi->ok(true)) {
663 std::exit(EXIT_FAILURE);
664 }
665
666 if (interFace.use_generic_names()) {
667 dbi->set_use_generic_canonical_name(true);
668 }
669
670 if (interFace.surface_split_scheme() != Ioss::SPLIT_INVALID) {
671 dbi->set_surface_split_type(Ioss::int_to_surface_split(interFace.surface_split_scheme()));
672 }
673 dbi->set_field_separator(interFace.field_suffix_separator());
674 dbi->set_field_recognition(!interFace.disable_field_recognition());
675 if (interFace.ints_64_bit()) {
676 dbi->set_int_byte_size_api(Ioss::USE_INT64_API);
677 }
678 }
679
680 void io_info_file_info(const Info::Interface &interFace, Ioss::Region &region)
681 {
682 Ioss::DatabaseIO *dbi = region.get_database();
683
684 if (dbi == nullptr || !dbi->ok(true)) {
685 std::exit(EXIT_FAILURE);
686 }
687
688 bool parallel = region.get_database()->is_parallel();
689 int parallel_size = region.get_database()->parallel_size();
690 int parallel_rank = region.get_database()->parallel_rank();
691 region.get_database()->set_parallel_consistency(false);
692
693 for (int proc = 0; proc < parallel_size; proc++) {
694 if (proc == parallel_rank) {
695 if (parallel) {
696 fmt::print("\nProcessor {}", proc);
697 }
698 region.output_summary(std::cout, true);
699
700 if (!interFace.summary()) {
701
702 info_region(region);
703 info_assemblies(region);
704 info_nodeblock(region, interFace);
705 info_edgeblock(region, interFace);
706 info_faceblock(region, interFace);
707 info_elementblock(region, interFace);
708 info_structuredblock(region, interFace);
709
710 info_nodesets(region, interFace);
711 info_edgesets(region, interFace);
712 info_facesets(region, interFace);
713 info_elementsets(region, interFace);
714
715 info_sidesets(region, interFace);
716 info_blobs(region);
717 info_coordinate_frames(region);
718 }
719 }
720 region.get_database()->util().barrier();
721 }
722
723 if (interFace.compute_volume()) {
724 element_volume(region);
725 }
726 }
727 } // namespace Ioss