Skip to content

Commit

Permalink
IOSS: Add option to omit_blocks to io_shell
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed May 16, 2024
1 parent 9136278 commit c65367a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/seacas/libraries/ioss/src/Ioss_CopyDatabase.C
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,19 @@ namespace {
fmt::print(Ioss::DebugOut(), " Number of Nodes = {:14}\n",
fmt::group_digits(num_nodes));
}

if (options.omitted_blocks) {
size_t isize = inb->get_field("node_connectivity_status").get_size();
pool.data.resize(isize);
inb->get_field_data("node_connectivity_status", pool.data.data(), isize);

// Count number of "active" nodes
size_t active =
std::count_if(pool.data.begin(), pool.data.end(), [](auto &val) { return val >= 2; });
fmt::print(Ioss::DebugOut(), " Number of Active Nodes = {:14}\n",
fmt::group_digits(active));
}

auto *nb = new Ioss::NodeBlock(*inb);
output_region.add(nb);

Expand Down
1 change: 1 addition & 0 deletions packages/seacas/libraries/ioss/src/Ioss_MeshCopyOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Ioss {
bool reverse{false}; // Used for testing CGNS
bool add_proc_id{false}; // CGNS: Add proc_id field.
bool boundary_sideset{false}; // Output a sideset of the boundary faces of the model
bool omitted_blocks{false};

// only used by Catalyst calls to `copy_database`; if false the
// copy process skips the defining of the mesh geometry and the
Expand Down
6 changes: 6 additions & 0 deletions packages/seacas/libraries/ioss/src/main/io_shell.C
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace {
options.add_proc_id = interFace.add_processor_id_field;
options.boundary_sideset = interFace.boundary_sideset;
options.ignore_qa_info = interFace.ignore_qa_info;
options.omitted_blocks = !interFace.omitted_blocks.empty();
return options;
}

Expand Down Expand Up @@ -263,6 +264,11 @@ namespace {
}
}

if (!interFace.omitted_blocks.empty()) {
std::vector<std::string> inclusions{};
dbi->set_block_omissions(interFace.omitted_blocks, inclusions);
}

// NOTE: 'region' owns 'db' pointer at this time...
Ioss::Region region(dbi, "region_1");

Expand Down
17 changes: 17 additions & 0 deletions packages/seacas/libraries/ioss/src/main/shell_interface.C
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,13 @@ void IOShell::Interface::enroll_options()
"\t\tDefault is to ignore empty blocks.",
nullptr);

options_.enroll("omit_blocks", Ioss::GetLongOption::MandatoryValue,
"comma-separated list of element block names that should NOT be transferred to "
"output database\n"
"\t\tNote that currently any nodes connected to only empty blocks will be "
"retained in the output.",
nullptr);

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

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

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

{
const char *temp = options_.retrieve("surface_split_scheme");
if (temp != nullptr) {
Expand Down
4 changes: 4 additions & 0 deletions packages/seacas/libraries/ioss/src/main/shell_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +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
std::vector<std::string> omitted_blocks{};

//! If non-zero, then put `split_times` timesteps in each file. Then close file and start new
//! file.
// If `split_cyclic == 0`, then filenames will be
Expand Down

0 comments on commit c65367a

Please sign in to comment.