Skip to content

Commit

Permalink
IOSS: Modify io_info to use change_sets instead of groups
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed Nov 8, 2024
1 parent 28f9a87 commit 49b93c7
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 117 deletions.
30 changes: 20 additions & 10 deletions packages/seacas/libraries/ioss/src/Ioss_Region.C
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,20 @@ namespace Ioss {
int num_width = Ioss::Utils::number_width(max_entity, true) + 2;
int sb_width = Ioss::Utils::number_width(max_sb, true) + 2;

int change_set_count = get_database()->num_internal_change_set();
auto change_set_name = get_internal_change_set_name();
if (!change_set_name.empty() && change_set_name != "/") {
change_set_name = ",\t[CS: " + change_set_name + "]";
}
else {
change_set_name.clear();
}

// clang-format off
fmt::print(
strm,
"\n Database: {0}\n"
" Mesh Type = {1}, {39}\n"
"\n Database: {0}{56}\n"
" Mesh Type = {1}, {39}. Change Sets = {57}\n"
" {38:{24}s}\t {38:{23}s}\t Variables : Transient / Reduction\n"
" Spatial dimensions = {2:{24}}\t {38:{23}s}\t Global = {26:{25}}\t{44:{25}}\n"
" Node blocks = {7:{24}}\t Nodes = {3:{23}}\t Nodal = {27:{25}}\t{45:{25}}\n"
Expand All @@ -612,7 +621,7 @@ namespace Ioss {
" Assemblies = {40:{24}}\t {38:{23}s}\t Assembly = {41:{25}}\t{54:{25}}\n"
" Blobs = {42:{24}}\t {38:{23}s}\t Blob = {43:{25}}\t{55:{25}}\n\n"
" Time steps = {32:{24}}\n",
get_database()->get_filename(), mesh_type_string(),
get_database()->get_filename(), mesh_type_string(), /* 0, 1 */
fmt::group_digits(get_property("spatial_dimension").get_int()),
fmt::group_digits(get_property("node_count").get_int()),
fmt::group_digits(get_property("edge_count").get_int()),
Expand All @@ -621,7 +630,7 @@ namespace Ioss {
fmt::group_digits(get_property("node_block_count").get_int()),
fmt::group_digits(get_property("edge_block_count").get_int()),
fmt::group_digits(get_property("face_block_count").get_int()),
fmt::group_digits(get_property("element_block_count").get_int()),
fmt::group_digits(get_property("element_block_count").get_int()), /* 10 */
fmt::group_digits(get_property("structured_block_count").get_int()),
fmt::group_digits(get_property("node_set_count").get_int()),
fmt::group_digits(get_property("edge_set_count").get_int()),
Expand All @@ -631,7 +640,7 @@ namespace Ioss {
fmt::group_digits(total_cells),
fmt::group_digits(total_ns_nodes),
fmt::group_digits(total_es_edges),
fmt::group_digits(total_fs_faces),
fmt::group_digits(total_fs_faces), /* 20 */
fmt::group_digits(total_es_elements),
fmt::group_digits(total_sides),
num_width,
Expand All @@ -641,7 +650,7 @@ namespace Ioss {
fmt::group_digits(num_nod_vars),
fmt::group_digits(num_ele_vars),
fmt::group_digits(num_str_vars),
fmt::group_digits(num_ns_vars),
fmt::group_digits(num_ns_vars), /* 30 */
fmt::group_digits(num_ss_vars),
fmt::group_digits(num_ts),
fmt::group_digits(num_edg_vars),
Expand All @@ -651,8 +660,8 @@ namespace Ioss {
fmt::group_digits(num_els_vars),
" ",
get_database()->get_format(),
fmt::group_digits(get_property("assembly_count").get_int()),
fmt::group_digits(num_asm_vars) ,
fmt::group_digits(get_property("assembly_count").get_int()), /* 40 */
fmt::group_digits(num_asm_vars),
fmt::group_digits(get_property("blob_count").get_int()),
fmt::group_digits(num_blob_vars),
fmt::group_digits(num_glo_red_vars),
Expand All @@ -661,12 +670,13 @@ namespace Ioss {
fmt::group_digits(num_fac_red_vars),
fmt::group_digits(num_ele_red_vars),
fmt::group_digits(num_str_red_vars),
fmt::group_digits(num_ns_red_vars),
fmt::group_digits(num_ns_red_vars), /* 50 */
fmt::group_digits(num_es_red_vars),
fmt::group_digits(num_fs_red_vars),
fmt::group_digits(num_els_red_vars),
fmt::group_digits(num_asm_red_vars),
fmt::group_digits(num_blob_red_vars));
fmt::group_digits(num_blob_red_vars),
change_set_name, change_set_count);
// clang-format on
}

Expand Down
22 changes: 16 additions & 6 deletions packages/seacas/libraries/ioss/src/main/info_interface.C
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,19 @@ void Info::Interface::enroll_options()
nullptr, nullptr, true);

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

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

options_.enroll("query_timesteps_only", Ioss::GetLongOption::NoValue,
"Only read and output the timestep data on the file", nullptr);
Expand Down Expand Up @@ -197,16 +205,18 @@ bool Info::Interface::parse_options(int argc, char **argv)
ints64Bit_ = options_.retrieve("64-bit") != nullptr;
computeVolume_ = options_.retrieve("compute_volume") != nullptr;
computeBBox_ = options_.retrieve("compute_bbox") != nullptr;
listGroups_ = options_.retrieve("list_groups") != nullptr;
listChangeSets_ = options_.retrieve("list_change_sets") != nullptr ||
options_.retrieve("list_groups") != nullptr;
useGenericNames_ = options_.retrieve("use_generic_names") != nullptr;
summary_ = options_.retrieve("summary") != nullptr;
showConfig_ = options_.retrieve("configuration") != nullptr;
queryTimeOnly_ = options_.retrieve("query_timesteps_only") != nullptr;
fieldDetails_ = options_.retrieve("detailed_field_info") != nullptr;

filetype_ = options_.get_option_value("db_type", filetype_);
filetype_ = options_.get_option_value("in_type", filetype_);
groupname_ = options_.get_option_value("group_name", groupname_);
filetype_ = options_.get_option_value("db_type", filetype_);
filetype_ = options_.get_option_value("in_type", filetype_);
changeSetName_ = options_.get_option_value("change_set_name", changeSetName_);
changeSetName_ = options_.get_option_value("group_name", changeSetName_);

{
const char *temp = options_.retrieve("surface_split_scheme");
Expand Down
8 changes: 4 additions & 4 deletions packages/seacas/libraries/ioss/src/main/info_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Info {
bool compute_bbox() const { return computeBBox_; }
bool adjacencies() const { return adjacencies_; }
bool ints_64_bit() const { return ints64Bit_; }
bool list_groups() const { return listGroups_; }
bool list_change_sets() const { return listChangeSets_; }
bool show_config() const { return showConfig_; }
bool query_timesteps_only() const { return queryTimeOnly_; }
bool field_details() const { return fieldDetails_; }
Expand All @@ -41,7 +41,7 @@ namespace Info {
std::string decomp_method() const { return decompMethod_; }
std::string filename() const { return filename_; }
std::string type() const { return filetype_; }
std::string groupname() const { return groupname_; }
std::string change_set_name() const { return changeSetName_; }
std::string custom_field() const { return customField_; }

//! Dumps representation of data in this class to cerr
Expand All @@ -52,7 +52,7 @@ namespace Info {
Ioss::GetLongOption options_;
std::string filetype_{"exodus"};
std::string filename_{};
std::string groupname_{};
std::string changeSetName_{};
std::string decompMethod_{};
std::string customField_{};

Expand All @@ -61,7 +61,7 @@ namespace Info {
bool adjacencies_{false};
bool ints64Bit_{false};
bool computeBBox_{false};
bool listGroups_{false};
bool listChangeSets_{false};
bool useGenericNames_{false};
bool disableFieldRecognition_{false};
bool showConfig_{false};
Expand Down
90 changes: 41 additions & 49 deletions packages/seacas/libraries/ioss/src/main/io_info.C
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ namespace {
}

void file_info(const Info::Interface &interFace);
void group_info(Info::Interface &interFace);
void change_set_info(Info::Interface &interFace);

void info_df(const Ioss::GroupingEntity *ge, const std::string &prefix)
{
Expand Down Expand Up @@ -163,45 +163,22 @@ namespace {
}
}

#if defined(SEACAS_HAVE_EXODUS)
int print_groups(int exoid, std::string prefix)
{
int idum;
float rdum;
char group_name[33];
// Print name of this group...
ex_inquire(exoid, EX_INQ_GROUP_NAME, &idum, &rdum, group_name);
if (group_name[0] == '/') {
fmt::print("{}/ (root)\n", prefix);
}
else {
fmt::print("{}{}\n", prefix, group_name);
}

int num_children = ex_inquire_int(exoid, EX_INQ_NUM_CHILD_GROUPS);
std::vector<int> children(num_children);
ex_get_group_ids(exoid, nullptr, Data(children));
prefix += '\t';
for (int i = 0; i < num_children; i++) {
print_groups(children[i], prefix);
}
return 0;
}
#endif

void group_info(Info::Interface &interFace)
void change_set_info(Info::Interface &interFace)
{
#if defined(SEACAS_HAVE_EXODUS)
// Assume exodusII...
std::string inpfile = interFace.filename();
float vers = 0.0;
int CPU_word_size = 0;
int IO_word_size = 0;
std::string inpfile = interFace.filename();
std::string input_type = interFace.type();
Ioss::PropertyManager properties = set_properties(interFace);

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

print_groups(exoid, "\t");
#endif
Ioss::io_info_set_db_properties(interFace, dbi);
auto cs_names = dbi->internal_change_set_describe();
fmt::print("\t/ (root)\n");
for (const auto &cs_name : cs_names) {
fmt::print("\t\t{}\n", cs_name);
}
}

void file_info(const Info::Interface &interFace)
Expand Down Expand Up @@ -235,7 +212,32 @@ namespace {
info_timesteps(region);
}
else {
Ioss::io_info_file_info(interFace, region);
auto cs_list = Ioss::tokenize(interFace.change_set_name(), ",");
if (cs_list.empty()) {
cs_list.push_back("/");
}
else {
if (cs_list[0] == "ALL") {
cs_list = dbi->internal_change_set_describe();
}
}

bool first = true;
for (const auto &cs_name : cs_list) {
if (!first) {
fmt::print("-----------------------------------------------------------------------------"
"-----------------------\n");
}
if (cs_name != "/") {
bool success = dbi->open_internal_change_set(cs_name);
if (!success) {
fmt::print("ERROR: Unable to open change set '{}' in file '{}'\n", cs_name, inpfile);
return;
}
first = false;
}
Ioss::io_info_file_info(interFace, region);
}
}
}

Expand Down Expand Up @@ -652,7 +654,7 @@ namespace {

namespace Ioss {
void io_info_file_info(const Info::Interface &interFace) { file_info(interFace); }
void io_info_group_info(Info::Interface &interFace) { group_info(interFace); }
void io_info_change_set_info(Info::Interface &interFace) { change_set_info(interFace); }

void io_info_set_db_properties(const Info::Interface &interFace, Ioss::DatabaseIO *dbi)
{
Expand All @@ -672,16 +674,6 @@ namespace Ioss {
if (interFace.ints_64_bit()) {
dbi->set_int_byte_size_api(Ioss::USE_INT64_API);
}

if (!interFace.groupname().empty()) {
bool success = dbi->open_internal_change_set(interFace.groupname());
if (!success) {
std::string inpfile = interFace.filename();
fmt::print("ERROR: Unable to open group '{}' in file '{}'\n", interFace.groupname(),
inpfile);
return;
}
}
}

void io_info_file_info(const Info::Interface &interFace, Ioss::Region &region)
Expand Down
48 changes: 2 additions & 46 deletions packages/seacas/libraries/ioss/src/main/io_info.h
Original file line number Diff line number Diff line change
@@ -1,57 +1,13 @@
/*
* Copyright(C) 1999-2020, 2022, 2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2020, 2022, 2023, 2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
* See packages/seacas/LICENSE for details
*/
#pragma once

#include "Ionit_Initializer.h"
#include "Ioss_CodeTypes.h"
#include "Ioss_SurfaceSplit.h"
#include "Ioss_Utils.h"
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

#include "info_interface.h"
#include "io_info_lib_export.h"
#if defined(SEACAS_HAVE_EXODUS)
#include <exodusII.h>
#endif

#include <cassert>

#include "Ioss_Assembly.h"
#include "Ioss_Blob.h"
#include "Ioss_CommSet.h"
#include "Ioss_CoordinateFrame.h"
#include "Ioss_DBUsage.h"
#include "Ioss_DatabaseIO.h"
#include "Ioss_EdgeBlock.h"
#include "Ioss_EdgeSet.h"
#include "Ioss_ElementBlock.h"
#include "Ioss_ElementSet.h"
#include "Ioss_ElementTopology.h"
#include "Ioss_FaceBlock.h"
#include "Ioss_FaceSet.h"
#include "Ioss_Field.h"
#include "Ioss_GroupingEntity.h"
#include "Ioss_IOFactory.h"
#include "Ioss_NodeBlock.h"
#include "Ioss_NodeSet.h"
#include "Ioss_Property.h"
#include "Ioss_Region.h"
#include "Ioss_SideBlock.h"
#include "Ioss_SideSet.h"
#include "Ioss_StructuredBlock.h"
#include "Ioss_VariableType.h"

namespace Info {
class Interface;
Expand All @@ -63,7 +19,7 @@ namespace Ioss {

// internal to io_info
IO_INFO_LIB_EXPORT void io_info_file_info(const Info::Interface &interFace);
IO_INFO_LIB_EXPORT void io_info_group_info(Info::Interface &interFace);
IO_INFO_LIB_EXPORT void io_info_change_set_info(Info::Interface &interFace);

// for external calls
IO_INFO_LIB_EXPORT void io_info_set_db_properties(const Info::Interface &interFace,
Expand Down
4 changes: 2 additions & 2 deletions packages/seacas/libraries/ioss/src/main/io_info_main.C
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ int main(int argc, char *argv[])
codename = codename.substr(ind + 1, codename.size());
}

if (interFace.list_groups()) {
Ioss::io_info_group_info(interFace);
if (interFace.list_change_sets()) {
Ioss::io_info_change_set_info(interFace);
}
else {
Ioss::io_info_file_info(interFace);
Expand Down

0 comments on commit 49b93c7

Please sign in to comment.