Skip to content

Commit

Permalink
IOSS: Add omit_sets option to io_shell
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed May 31, 2024
1 parent 4bfe2d5 commit 08a9c93
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 37 deletions.
73 changes: 45 additions & 28 deletions packages/seacas/libraries/ioss/src/Ioss_CopyDatabase.C
Original file line number Diff line number Diff line change
Expand Up @@ -1034,27 +1034,36 @@ namespace {
{
const auto &fss = region.get_sidesets();
for (const auto &ss : fss) {
const std::string &name = ss->name();
if (options.debug && rank == 0) {
fmt::print(Ioss::DebugOut(), "{}, ", name);
}
auto *surf = new Ioss::SideSet(*ss);
output_region.add(surf);

// Fix up the optional 'owner_block' in copied SideBlocks...
const auto &fbs = ss->get_side_blocks();
for (const auto &ifb : fbs) {
if (ifb->parent_block() != nullptr) {
const auto &fb_name = ifb->parent_block()->name();
auto *parent = dynamic_cast<Ioss::EntityBlock *>(
output_region.get_entity(fb_name, Ioss::ELEMENTBLOCK));
if (parent == nullptr) {
parent = dynamic_cast<Ioss::EntityBlock *>(
output_region.get_entity(fb_name, Ioss::STRUCTUREDBLOCK));
}
const std::string &name = ss->name();
auto lc_name = Ioss::Utils::lowercase(name);
if (std::find(options.omitted_sets.begin(), options.omitted_sets.end(), lc_name) ==
options.omitted_sets.end()) {
if (options.debug && rank == 0) {
fmt::print(Ioss::DebugOut(), "{}, ", name);
}
auto *surf = new Ioss::SideSet(*ss);
output_region.add(surf);

// Fix up the optional 'owner_block' in copied SideBlocks...
const auto &fbs = ss->get_side_blocks();
for (const auto &ifb : fbs) {
if (ifb->parent_block() != nullptr) {
const auto &fb_name = ifb->parent_block()->name();
auto *parent = dynamic_cast<Ioss::EntityBlock *>(
output_region.get_entity(fb_name, Ioss::ELEMENTBLOCK));
if (parent == nullptr) {
parent = dynamic_cast<Ioss::EntityBlock *>(
output_region.get_entity(fb_name, Ioss::STRUCTUREDBLOCK));
}

auto *ofb = surf->get_side_block(ifb->name());
ofb->set_parent_block(parent);
auto *ofb = surf->get_side_block(ifb->name());
ofb->set_parent_block(parent);
}
}
}
else {
if (options.debug && rank == 0) {
fmt::print(Ioss::DebugOut(), "{}(omitted), ", name);
}
}
}
Expand All @@ -1075,16 +1084,24 @@ namespace {
if (!sets.empty()) {
size_t total_entities = 0;
for (const auto &set : sets) {
const std::string &name = set->name();
if (options.debug && rank == 0) {
fmt::print(Ioss::DebugOut(), "{}, ", name);
const std::string &name = set->name();
auto lc_name = Ioss::Utils::lowercase(name);
if (std::find(options.omitted_sets.begin(), options.omitted_sets.end(), lc_name) ==
options.omitted_sets.end()) {
if (options.debug && rank == 0) {
fmt::print(Ioss::DebugOut(), "{}, ", name);
}
size_t count = set->entity_count();
total_entities += count;
auto *o_set = new T(*set);
output_region.add(o_set);
}
else {
if (options.debug && rank == 0) {
fmt::print(Ioss::DebugOut(), "{}(omitted), ", name);
}
}
size_t count = set->entity_count();
total_entities += count;
auto *o_set = new T(*set);
output_region.add(o_set);
}

if (options.output_summary && rank == 0) {
fmt::print(Ioss::DebugOut(), " Number of {:20s} = {:14}",
(*sets.begin())->type_string() + "s", fmt::group_digits(sets.size()));
Expand Down
13 changes: 7 additions & 6 deletions packages/seacas/libraries/ioss/src/Ioss_MeshCopyOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
namespace Ioss {
struct IOSS_EXPORT MeshCopyOptions
{
std::vector<double> selected_times{};
double minimum_time{0.0};
double maximum_time{0.0};
double delay{0.0};
double time_scale{1.0};
double time_offset{0.0};
std::vector<double> selected_times{};
std::vector<std::string> omitted_sets{};
double minimum_time{0.0};
double maximum_time{0.0};
double delay{0.0};
double time_scale{1.0};
double time_offset{0.0};

double rel_tolerance{};
double abs_tolerance{};
Expand Down
8 changes: 7 additions & 1 deletion packages/seacas/libraries/ioss/src/main/io_shell.C
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

namespace {
std::string codename;
std::string version = "6.7 (2024/05/01)";
std::string version = "6.8 (2024/05/31)";

bool mem_stats = false;

Expand Down Expand Up @@ -74,6 +74,12 @@ namespace {
options.boundary_sideset = interFace.boundary_sideset;
options.ignore_qa_info = interFace.ignore_qa_info;
options.omitted_blocks = !interFace.omitted_blocks.empty();

options.omitted_sets = interFace.omitted_sets;
Ioss::sort(options.omitted_sets);
for (auto &name : options.omitted_sets) {
name = Ioss::Utils::lowercase(name);
}
return options;
}

Expand Down
16 changes: 16 additions & 0 deletions packages/seacas/libraries/ioss/src/main/shell_interface.C
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ void IOShell::Interface::enroll_options()
"retained in the output.",
nullptr);

options_.enroll("omit_sets", Ioss::GetLongOption::MandatoryValue,
"comma-separated list of nodeset/edgeset/faceset/elemset/sideset names that "
"should NOT be transferred to "
"output database",
nullptr);

options_.enroll("boundary_sideset", Ioss::GetLongOption::NoValue,
"Output a sideset for all boundary faces of the model", nullptr);

Expand Down Expand Up @@ -623,6 +629,16 @@ bool IOShell::Interface::parse_options(int argc, char **argv, int my_processor)
}
}

{
const char *temp = options_.retrieve("omit_sets");
if (temp != nullptr) {
auto omit_str = Ioss::tokenize(std::string(temp), ",");
for (const auto &str : omit_str) {
omitted_sets.push_back(str);
}
}
}

{
const char *temp = options_.retrieve("surface_split_scheme");
if (temp != nullptr) {
Expand Down
5 changes: 3 additions & 2 deletions packages/seacas/libraries/ioss/src/main/shell_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ namespace IOShell {
//! If non-empty, then it is a list of times that should be transferred to the output file.
std::vector<double> selected_times{};

//! If non-empty, then it is a list of element blocks that should be omitted from the output
//! file
//! If non-empty, then it is a list of element blocks, nodesets,
//! sidesets that should be omitted from the output file
std::vector<std::string> omitted_blocks{};
std::vector<std::string> omitted_sets{};

//! If non-zero, then put `split_times` timesteps in each file. Then close file and start new
//! file.
Expand Down

0 comments on commit 08a9c93

Please sign in to comment.