Skip to content

Commit 49b93c7

Browse files
committed
IOSS: Modify io_info to use change_sets instead of groups
1 parent 28f9a87 commit 49b93c7

File tree

6 files changed

+85
-117
lines changed

6 files changed

+85
-117
lines changed

packages/seacas/libraries/ioss/src/Ioss_Region.C

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,20 @@ namespace Ioss {
592592
int num_width = Ioss::Utils::number_width(max_entity, true) + 2;
593593
int sb_width = Ioss::Utils::number_width(max_sb, true) + 2;
594594

595+
int change_set_count = get_database()->num_internal_change_set();
596+
auto change_set_name = get_internal_change_set_name();
597+
if (!change_set_name.empty() && change_set_name != "/") {
598+
change_set_name = ",\t[CS: " + change_set_name + "]";
599+
}
600+
else {
601+
change_set_name.clear();
602+
}
603+
595604
// clang-format off
596605
fmt::print(
597606
strm,
598-
"\n Database: {0}\n"
599-
" Mesh Type = {1}, {39}\n"
607+
"\n Database: {0}{56}\n"
608+
" Mesh Type = {1}, {39}. Change Sets = {57}\n"
600609
" {38:{24}s}\t {38:{23}s}\t Variables : Transient / Reduction\n"
601610
" Spatial dimensions = {2:{24}}\t {38:{23}s}\t Global = {26:{25}}\t{44:{25}}\n"
602611
" Node blocks = {7:{24}}\t Nodes = {3:{23}}\t Nodal = {27:{25}}\t{45:{25}}\n"
@@ -612,7 +621,7 @@ namespace Ioss {
612621
" Assemblies = {40:{24}}\t {38:{23}s}\t Assembly = {41:{25}}\t{54:{25}}\n"
613622
" Blobs = {42:{24}}\t {38:{23}s}\t Blob = {43:{25}}\t{55:{25}}\n\n"
614623
" Time steps = {32:{24}}\n",
615-
get_database()->get_filename(), mesh_type_string(),
624+
get_database()->get_filename(), mesh_type_string(), /* 0, 1 */
616625
fmt::group_digits(get_property("spatial_dimension").get_int()),
617626
fmt::group_digits(get_property("node_count").get_int()),
618627
fmt::group_digits(get_property("edge_count").get_int()),
@@ -621,7 +630,7 @@ namespace Ioss {
621630
fmt::group_digits(get_property("node_block_count").get_int()),
622631
fmt::group_digits(get_property("edge_block_count").get_int()),
623632
fmt::group_digits(get_property("face_block_count").get_int()),
624-
fmt::group_digits(get_property("element_block_count").get_int()),
633+
fmt::group_digits(get_property("element_block_count").get_int()), /* 10 */
625634
fmt::group_digits(get_property("structured_block_count").get_int()),
626635
fmt::group_digits(get_property("node_set_count").get_int()),
627636
fmt::group_digits(get_property("edge_set_count").get_int()),
@@ -631,7 +640,7 @@ namespace Ioss {
631640
fmt::group_digits(total_cells),
632641
fmt::group_digits(total_ns_nodes),
633642
fmt::group_digits(total_es_edges),
634-
fmt::group_digits(total_fs_faces),
643+
fmt::group_digits(total_fs_faces), /* 20 */
635644
fmt::group_digits(total_es_elements),
636645
fmt::group_digits(total_sides),
637646
num_width,
@@ -641,7 +650,7 @@ namespace Ioss {
641650
fmt::group_digits(num_nod_vars),
642651
fmt::group_digits(num_ele_vars),
643652
fmt::group_digits(num_str_vars),
644-
fmt::group_digits(num_ns_vars),
653+
fmt::group_digits(num_ns_vars), /* 30 */
645654
fmt::group_digits(num_ss_vars),
646655
fmt::group_digits(num_ts),
647656
fmt::group_digits(num_edg_vars),
@@ -651,8 +660,8 @@ namespace Ioss {
651660
fmt::group_digits(num_els_vars),
652661
" ",
653662
get_database()->get_format(),
654-
fmt::group_digits(get_property("assembly_count").get_int()),
655-
fmt::group_digits(num_asm_vars) ,
663+
fmt::group_digits(get_property("assembly_count").get_int()), /* 40 */
664+
fmt::group_digits(num_asm_vars),
656665
fmt::group_digits(get_property("blob_count").get_int()),
657666
fmt::group_digits(num_blob_vars),
658667
fmt::group_digits(num_glo_red_vars),
@@ -661,12 +670,13 @@ namespace Ioss {
661670
fmt::group_digits(num_fac_red_vars),
662671
fmt::group_digits(num_ele_red_vars),
663672
fmt::group_digits(num_str_red_vars),
664-
fmt::group_digits(num_ns_red_vars),
673+
fmt::group_digits(num_ns_red_vars), /* 50 */
665674
fmt::group_digits(num_es_red_vars),
666675
fmt::group_digits(num_fs_red_vars),
667676
fmt::group_digits(num_els_red_vars),
668677
fmt::group_digits(num_asm_red_vars),
669-
fmt::group_digits(num_blob_red_vars));
678+
fmt::group_digits(num_blob_red_vars),
679+
change_set_name, change_set_count);
670680
// clang-format on
671681
}
672682

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,19 @@ void Info::Interface::enroll_options()
143143
nullptr, nullptr, true);
144144

145145
#endif
146+
options_.enroll(
147+
"list_change_sets", Ioss::GetLongOption::NoValue,
148+
"Print a list of the names of all change_sets (previosly groups) in this file and then exit.",
149+
nullptr);
146150
options_.enroll("list_groups", Ioss::GetLongOption::NoValue,
147-
"Print a list of the names of all groups in this file and then exit.", nullptr);
151+
"[deprecated] Use --list_change_sets", nullptr);
148152

153+
options_.enroll("change_set_name", Ioss::GetLongOption::MandatoryValue,
154+
"List information only for the specified comma-separated list of change_set(s) "
155+
"or `ALL` to list for all.",
156+
nullptr);
149157
options_.enroll("group_name", Ioss::GetLongOption::MandatoryValue,
150-
"List information only for the specified group.", nullptr, nullptr, true);
158+
"[deprecated] Use --change_set_name.", nullptr, nullptr, true);
151159

152160
options_.enroll("query_timesteps_only", Ioss::GetLongOption::NoValue,
153161
"Only read and output the timestep data on the file", nullptr);
@@ -197,16 +205,18 @@ bool Info::Interface::parse_options(int argc, char **argv)
197205
ints64Bit_ = options_.retrieve("64-bit") != nullptr;
198206
computeVolume_ = options_.retrieve("compute_volume") != nullptr;
199207
computeBBox_ = options_.retrieve("compute_bbox") != nullptr;
200-
listGroups_ = options_.retrieve("list_groups") != nullptr;
208+
listChangeSets_ = options_.retrieve("list_change_sets") != nullptr ||
209+
options_.retrieve("list_groups") != nullptr;
201210
useGenericNames_ = options_.retrieve("use_generic_names") != nullptr;
202211
summary_ = options_.retrieve("summary") != nullptr;
203212
showConfig_ = options_.retrieve("configuration") != nullptr;
204213
queryTimeOnly_ = options_.retrieve("query_timesteps_only") != nullptr;
205214
fieldDetails_ = options_.retrieve("detailed_field_info") != nullptr;
206215

207-
filetype_ = options_.get_option_value("db_type", filetype_);
208-
filetype_ = options_.get_option_value("in_type", filetype_);
209-
groupname_ = options_.get_option_value("group_name", groupname_);
216+
filetype_ = options_.get_option_value("db_type", filetype_);
217+
filetype_ = options_.get_option_value("in_type", filetype_);
218+
changeSetName_ = options_.get_option_value("change_set_name", changeSetName_);
219+
changeSetName_ = options_.get_option_value("group_name", changeSetName_);
210220

211221
{
212222
const char *temp = options_.retrieve("surface_split_scheme");

packages/seacas/libraries/ioss/src/main/info_interface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Info {
2929
bool compute_bbox() const { return computeBBox_; }
3030
bool adjacencies() const { return adjacencies_; }
3131
bool ints_64_bit() const { return ints64Bit_; }
32-
bool list_groups() const { return listGroups_; }
32+
bool list_change_sets() const { return listChangeSets_; }
3333
bool show_config() const { return showConfig_; }
3434
bool query_timesteps_only() const { return queryTimeOnly_; }
3535
bool field_details() const { return fieldDetails_; }
@@ -41,7 +41,7 @@ namespace Info {
4141
std::string decomp_method() const { return decompMethod_; }
4242
std::string filename() const { return filename_; }
4343
std::string type() const { return filetype_; }
44-
std::string groupname() const { return groupname_; }
44+
std::string change_set_name() const { return changeSetName_; }
4545
std::string custom_field() const { return customField_; }
4646

4747
//! Dumps representation of data in this class to cerr
@@ -52,7 +52,7 @@ namespace Info {
5252
Ioss::GetLongOption options_;
5353
std::string filetype_{"exodus"};
5454
std::string filename_{};
55-
std::string groupname_{};
55+
std::string changeSetName_{};
5656
std::string decompMethod_{};
5757
std::string customField_{};
5858

@@ -61,7 +61,7 @@ namespace Info {
6161
bool adjacencies_{false};
6262
bool ints64Bit_{false};
6363
bool computeBBox_{false};
64-
bool listGroups_{false};
64+
bool listChangeSets_{false};
6565
bool useGenericNames_{false};
6666
bool disableFieldRecognition_{false};
6767
bool showConfig_{false};

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

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace {
9393
}
9494

9595
void file_info(const Info::Interface &interFace);
96-
void group_info(Info::Interface &interFace);
96+
void change_set_info(Info::Interface &interFace);
9797

9898
void info_df(const Ioss::GroupingEntity *ge, const std::string &prefix)
9999
{
@@ -163,45 +163,22 @@ namespace {
163163
}
164164
}
165165

166-
#if defined(SEACAS_HAVE_EXODUS)
167-
int print_groups(int exoid, std::string prefix)
168-
{
169-
int idum;
170-
float rdum;
171-
char group_name[33];
172-
// Print name of this group...
173-
ex_inquire(exoid, EX_INQ_GROUP_NAME, &idum, &rdum, group_name);
174-
if (group_name[0] == '/') {
175-
fmt::print("{}/ (root)\n", prefix);
176-
}
177-
else {
178-
fmt::print("{}{}\n", prefix, group_name);
179-
}
180-
181-
int num_children = ex_inquire_int(exoid, EX_INQ_NUM_CHILD_GROUPS);
182-
std::vector<int> children(num_children);
183-
ex_get_group_ids(exoid, nullptr, Data(children));
184-
prefix += '\t';
185-
for (int i = 0; i < num_children; i++) {
186-
print_groups(children[i], prefix);
187-
}
188-
return 0;
189-
}
190-
#endif
191-
192-
void group_info(Info::Interface &interFace)
166+
void change_set_info(Info::Interface &interFace)
193167
{
194-
#if defined(SEACAS_HAVE_EXODUS)
195-
// Assume exodusII...
196-
std::string inpfile = interFace.filename();
197-
float vers = 0.0;
198-
int CPU_word_size = 0;
199-
int IO_word_size = 0;
168+
std::string inpfile = interFace.filename();
169+
std::string input_type = interFace.type();
170+
Ioss::PropertyManager properties = set_properties(interFace);
200171

201-
int exoid = ex_open(inpfile.c_str(), EX_READ, &CPU_word_size, &IO_word_size, &vers);
172+
auto mode = Ioss::READ_RESTART;
173+
Ioss::DatabaseIO *dbi = Ioss::IOFactory::create(input_type, inpfile, mode,
174+
Ioss::ParallelUtils::comm_world(), properties);
202175

203-
print_groups(exoid, "\t");
204-
#endif
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+
}
205182
}
206183

207184
void file_info(const Info::Interface &interFace)
@@ -235,7 +212,32 @@ namespace {
235212
info_timesteps(region);
236213
}
237214
else {
238-
Ioss::io_info_file_info(interFace, region);
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 = dbi->open_internal_change_set(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+
}
239241
}
240242
}
241243

@@ -652,7 +654,7 @@ namespace {
652654

653655
namespace Ioss {
654656
void io_info_file_info(const Info::Interface &interFace) { file_info(interFace); }
655-
void io_info_group_info(Info::Interface &interFace) { group_info(interFace); }
657+
void io_info_change_set_info(Info::Interface &interFace) { change_set_info(interFace); }
656658

657659
void io_info_set_db_properties(const Info::Interface &interFace, Ioss::DatabaseIO *dbi)
658660
{
@@ -672,16 +674,6 @@ namespace Ioss {
672674
if (interFace.ints_64_bit()) {
673675
dbi->set_int_byte_size_api(Ioss::USE_INT64_API);
674676
}
675-
676-
if (!interFace.groupname().empty()) {
677-
bool success = dbi->open_internal_change_set(interFace.groupname());
678-
if (!success) {
679-
std::string inpfile = interFace.filename();
680-
fmt::print("ERROR: Unable to open group '{}' in file '{}'\n", interFace.groupname(),
681-
inpfile);
682-
return;
683-
}
684-
}
685677
}
686678

687679
void io_info_file_info(const Info::Interface &interFace, Ioss::Region &region)

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

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,13 @@
11
/*
2-
* Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
2+
* Copyright(C) 1999-2020, 2022, 2023, 2024 National Technology & Engineering Solutions
33
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
44
* NTESS, the U.S. Government retains certain rights in this software.
55
*
66
* See packages/seacas/LICENSE for details
77
*/
88
#pragma once
99

10-
#include "Ionit_Initializer.h"
11-
#include "Ioss_CodeTypes.h"
12-
#include "Ioss_SurfaceSplit.h"
13-
#include "Ioss_Utils.h"
14-
#include <cstddef>
15-
#include <cstdlib>
16-
#include <cstring>
17-
#include <iomanip>
18-
#include <iostream>
19-
#include <string>
20-
#include <utility>
21-
#include <vector>
22-
23-
#include "info_interface.h"
2410
#include "io_info_lib_export.h"
25-
#if defined(SEACAS_HAVE_EXODUS)
26-
#include <exodusII.h>
27-
#endif
28-
29-
#include <cassert>
30-
31-
#include "Ioss_Assembly.h"
32-
#include "Ioss_Blob.h"
33-
#include "Ioss_CommSet.h"
34-
#include "Ioss_CoordinateFrame.h"
35-
#include "Ioss_DBUsage.h"
36-
#include "Ioss_DatabaseIO.h"
37-
#include "Ioss_EdgeBlock.h"
38-
#include "Ioss_EdgeSet.h"
39-
#include "Ioss_ElementBlock.h"
40-
#include "Ioss_ElementSet.h"
41-
#include "Ioss_ElementTopology.h"
42-
#include "Ioss_FaceBlock.h"
43-
#include "Ioss_FaceSet.h"
44-
#include "Ioss_Field.h"
45-
#include "Ioss_GroupingEntity.h"
46-
#include "Ioss_IOFactory.h"
47-
#include "Ioss_NodeBlock.h"
48-
#include "Ioss_NodeSet.h"
49-
#include "Ioss_Property.h"
50-
#include "Ioss_Region.h"
51-
#include "Ioss_SideBlock.h"
52-
#include "Ioss_SideSet.h"
53-
#include "Ioss_StructuredBlock.h"
54-
#include "Ioss_VariableType.h"
5511

5612
namespace Info {
5713
class Interface;
@@ -63,7 +19,7 @@ namespace Ioss {
6319

6420
// internal to io_info
6521
IO_INFO_LIB_EXPORT void io_info_file_info(const Info::Interface &interFace);
66-
IO_INFO_LIB_EXPORT void io_info_group_info(Info::Interface &interFace);
22+
IO_INFO_LIB_EXPORT void io_info_change_set_info(Info::Interface &interFace);
6723

6824
// for external calls
6925
IO_INFO_LIB_EXPORT void io_info_set_db_properties(const Info::Interface &interFace,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ int main(int argc, char *argv[])
6161
codename = codename.substr(ind + 1, codename.size());
6262
}
6363

64-
if (interFace.list_groups()) {
65-
Ioss::io_info_group_info(interFace);
64+
if (interFace.list_change_sets()) {
65+
Ioss::io_info_change_set_info(interFace);
6666
}
6767
else {
6868
Ioss::io_info_file_info(interFace);

0 commit comments

Comments
 (0)