Skip to content

Commit

Permalink
Reactor module test regoldings and add MOOSE tests for new Exodus out…
Browse files Browse the repository at this point in the history
…put options / command line options

Refs idaholab#23386
  • Loading branch information
shikhar413 committed Feb 9, 2023
1 parent 1096a67 commit 17a5701
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 48 deletions.
9 changes: 9 additions & 0 deletions framework/doc/content/source/actions/ElementIDOutputAction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ElementIDOutputAction

!syntax description /Mesh/ElementIDOutputAction

This action is triggered when [!param](/Outputs/Exodus/output_extra_element_ids) is set to `true`. AuxVariables and AuxKernels relevant to the extra element ids defined on the mesh are automatically added to the problem, and the resulting element integers are also outputted to the Exodus file.

!listing test/tests/outputs/exodus/exodus_elem_id.i block=Outputs

More information can be found on the [Exodus output documentation page](outputs/Exodus.md).
13 changes: 6 additions & 7 deletions framework/src/actions/ElementIDOutputAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ElementIDOutputAction.h"
#include "MooseMesh.h"
#include "FEProblemBase.h"
#include "AddOutputAction.h"

registerMooseAction("MooseApp", ElementIDOutputAction, "add_aux_kernel");

Expand All @@ -23,10 +24,7 @@ ElementIDOutputAction::validParams()
return params;
}

ElementIDOutputAction::ElementIDOutputAction(const InputParameters & params)
: Action(params)
{
}
ElementIDOutputAction::ElementIDOutputAction(const InputParameters & params) : Action(params) {}

void
ElementIDOutputAction::act()
Expand All @@ -52,8 +50,7 @@ ElementIDOutputAction::act()
bool has_element_id_names = params.isParamValid("show_extra_element_ids");
std::vector<std::string> element_id_names;
if (has_element_id_names)
element_id_names =
params.get<std::vector<std::string>>("show_extra_element_ids");
element_id_names = params.get<std::vector<std::string>>("show_extra_element_ids");

unsigned int n = _mesh->getMesh().n_elem_integers();
auto var_params = _factory.getValidParams("MooseVariableConstMonomial");
Expand All @@ -62,7 +59,9 @@ ElementIDOutputAction::act()
for (unsigned int i = 0; i < n; ++i)
{
auto & var_name = _mesh->getMesh().get_elem_integer_name(i);
if (!has_element_id_names || (std::find(element_id_names.begin(), element_id_names.end(), var_name) != element_id_names.end()))
if (!has_element_id_names ||
(std::find(element_id_names.begin(), element_id_names.end(), var_name) !=
element_id_names.end()))
{
// Create aux variables based on the extra element id name
_problem->addAuxVariable("MooseVariableConstMonomial", var_name, var_params);
Expand Down
7 changes: 5 additions & 2 deletions framework/src/actions/MeshOnlyAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ void
MeshOnlyAction::act()
{
bool output_eeid_to_exodus = _app.isParamValid("initialize_only");
std::string mesh_file = output_eeid_to_exodus ? _app.parameters().get<std::string>("initialize_only") : _app.parameters().get<std::string>("mesh_only");
std::string mesh_file = output_eeid_to_exodus
? _app.parameters().get<std::string>("initialize_only")
: _app.parameters().get<std::string>("mesh_only");
auto & mesh_ptr = _app.actionWarehouse().mesh();

// Print information about the mesh
Expand Down Expand Up @@ -104,7 +106,8 @@ MeshOnlyAction::act()
std::vector<std::set<subdomain_id_type>> vars_active_subdomains;
vars_active_subdomains.resize(n_eeid);
exio_helper.initialize_element_variables(eeid_vars, vars_active_subdomains);
exio_helper.write_element_values(output_mesh, eeid_soln, empty_timestep, vars_active_subdomains);
exio_helper.write_element_values(
output_mesh, eeid_soln, empty_timestep, vars_active_subdomains);
}
}
else if (mesh_file.find(".cpr") + 4 == mesh_file.size())
Expand Down
8 changes: 4 additions & 4 deletions framework/src/base/MooseApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ MooseApp::validParams()
"mesh_only",
"--mesh-only [mesh_file_name]",
"Setup and Output the input mesh only (Default: \"<input_file_name>_in.e\")");
params.addCommandLineParam<std::string>(
"initialize_only",
"--initialize-only [mesh_file_name]",
"Setup and Output the input mesh with extra element integers only (Default: \"<input_file_name>_in.e\")");
params.addCommandLineParam<std::string>("initialize_only",
"--initialize-only [mesh_file_name]",
"Setup and Output the input mesh with extra element "
"integers only (Default: \"<input_file_name>_in.e\")");

params.addCommandLineParam<bool>("show_input",
"--show-input",
Expand Down
7 changes: 4 additions & 3 deletions framework/src/outputs/AdvancedOutput.C
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,10 @@ AdvancedOutput::addValidParams(InputParameters & params, const MultiMooseEnum &
params.addParamNamesToGroup("output_material_properties show_material_properties", "Materials");

// Add mesh extra element id control, which are output via elemental variables
params.addParam<bool>("output_extra_element_ids",
false,
"Flag indicating if extra element ids defined on the mesh should be outputted");
params.addParam<bool>(
"output_extra_element_ids",
false,
"Flag indicating if extra element ids defined on the mesh should be outputted");
params.addParam<std::vector<std::string>>(
"show_extra_element_ids",
"List of extra element ids defined on the mesh that should be written to the output");
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
60 changes: 60 additions & 0 deletions test/tests/mesh/mesh_only/initialize_only.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1
subdomain_ids = '0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 2 0 0 0 0 0 0 0
0 0 0 3 0 0 0 0 0 0
0 0 0 0 4 0 0 0 0 0
0 0 0 0 0 5 0 0 0 0
0 0 0 0 0 0 6 0 0 0
0 0 0 0 0 0 0 7 0 0
0 0 0 0 0 0 0 0 8 0
0 0 0 0 0 0 0 0 0 9'
extra_element_integers = 'pin_id'
[]
[pinid_1]
type = SubdomainBoundingBoxGenerator
input = gmg
bottom_left = '0 0 0'
top_right = '0.5 0.5 0'
block_id = 1
location = INSIDE
integer_name = pin_id
[]
[pinid_2]
type = SubdomainBoundingBoxGenerator
input = pinid_1
bottom_left = '0.5 0 0'
top_right = '1 0.5 0'
block_id = 2
location = INSIDE
integer_name = pin_id
[]
[pinid_3]
type = SubdomainBoundingBoxGenerator
input = pinid_2
bottom_left = '0 0.5 0'
top_right = '0.5 1 0'
block_id = 3
location = INSIDE
integer_name = pin_id
[]
[pinid_4]
type = SubdomainBoundingBoxGenerator
input = pinid_3
bottom_left = '0.5 0.5 0'
top_right = '1 1 0'
block_id = 4
location = INSIDE
integer_name = pin_id
[]
[]

# This input file is intended to be run with the "--initialize-only" option so
# no other sections are required
31 changes: 21 additions & 10 deletions test/tests/mesh/mesh_only/tests
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Tests]
design = 'Mesh/index.md'

[./mesh_only_test]
[mesh_only_test]
type = 'Exodiff'
input = 'mesh_only.i'
cli_args = '--mesh-only 3d_chimney.e'
Expand All @@ -10,9 +10,9 @@
method = '!dbg'
issues = '#1568'
requirement = 'The system shall allow writing out the mesh without running a simulation.'
[../]
[]

[./mesh_info]
[mesh_info]
type = 'RunApp'
input = 'mesh_only.i'
cli_args = '--mesh-only info_test.e'
Expand All @@ -21,9 +21,9 @@
expect_out = 'Mesh Information'
issues = '#11917 #11921'
requirement = 'The system shall print out information about the mesh when writing out the mesh.'
[../]
[]

[./mesh_only_warning]
[mesh_only_warning]
type = RunApp
input = 'mesh_only.i'
# Intentional error (not a mesh filename)
Expand All @@ -32,9 +32,9 @@
expect_out = 'The --mesh-only option should be followed by a file name.'
issues = '#1568'
requirement = 'The system shall warn when using --mesh-only and there is no clear filename to use'
[../]
[]

[./output_dimension_override]
[output_dimension_override]
type = 'Exodiff'
input = 'output_dimension_override.i'
cli_args = '--mesh-only output_dimension.e'
Expand All @@ -43,9 +43,9 @@
method = '!dbg'
issues = '#12757'
requirement = 'The system shall support overriding output dimension when necessary to store coordinates in higher planes'
[../]
[]

[./mesh_only_checkpoint]
[mesh_only_checkpoint]
type = 'CheckFiles'
input = 'mesh_only.i'
cli_args = 'Mesh/parallel_type=distributed --mesh-only 3d_chimney.cpr'
Expand All @@ -56,5 +56,16 @@
method = '!dbg'
issues = '#14312'
requirement = 'The system shall support writing parallel checkpoint files with --mesh-only'
[../]
[]

[initialize_only]
type = 'Exodiff'
input = 'initialize_only.i'
cli_args = '--initialize-only'
exodiff = 'initialize_only_in.e'
recover = false
method = '!dbg'
issues = '#23386'
requirement = 'The system shall allow writing out the mesh with extra element ids without running a simulation.'
[]
[]
113 changes: 113 additions & 0 deletions test/tests/outputs/exodus/exodus_elem_id.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 1
ymax = 1
subdomain_ids = '0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 2 0 0 0 0 0 0 0
0 0 0 3 0 0 0 0 0 0
0 0 0 0 4 0 0 0 0 0
0 0 0 0 0 5 0 0 0 0
0 0 0 0 0 0 6 0 0 0
0 0 0 0 0 0 0 7 0 0
0 0 0 0 0 0 0 0 8 0
0 0 0 0 0 0 0 0 0 9'
extra_element_integers = 'pin_id temp_id'
[]
[pinid_1]
type = SubdomainBoundingBoxGenerator
input = gmg
bottom_left = '0 0 0'
top_right = '0.5 0.5 0'
block_id = 1
location = INSIDE
integer_name = pin_id
[]
[pinid_2]
type = SubdomainBoundingBoxGenerator
input = pinid_1
bottom_left = '0.5 0 0'
top_right = '1 0.5 0'
block_id = 2
location = INSIDE
integer_name = pin_id
[]
[pinid_3]
type = SubdomainBoundingBoxGenerator
input = pinid_2
bottom_left = '0 0.5 0'
top_right = '0.5 1 0'
block_id = 3
location = INSIDE
integer_name = pin_id
[]
[pinid_4]
type = SubdomainBoundingBoxGenerator
input = pinid_3
bottom_left = '0.5 0.5 0'
top_right = '1 1 0'
block_id = 4
location = INSIDE
integer_name = pin_id
[]
[tempid_1]
type = SubdomainBoundingBoxGenerator
input = pinid_4
bottom_left = '0 0 0'
top_right = '0.5 0.5 0'
block_id = 1
location = INSIDE
integer_name = temp_id
[]
[tempid_2]
type = SubdomainBoundingBoxGenerator
input = tempid_1
bottom_left = '0.5 0 0'
top_right = '1 0.5 0'
block_id = 2
location = INSIDE
integer_name = temp_id
[]
[tempid_3]
type = SubdomainBoundingBoxGenerator
input = tempid_2
bottom_left = '0 0.5 0'
top_right = '0.5 1 0'
block_id = 3
location = INSIDE
integer_name = temp_id
[]
[tempid_4]
type = SubdomainBoundingBoxGenerator
input = tempid_3
bottom_left = '0.5 0.5 0'
top_right = '1 1 0'
block_id = 4
location = INSIDE
integer_name = temp_id
[]
[]

[Problem]
kernel_coverage_check = false
solve = false
[]

[Executioner]
type = Steady
[]

[Debug]
show_actions = true
[]

[Outputs]
[out]
type = Exodus
output_extra_element_ids = true
[]
[]
Binary file not shown.

0 comments on commit 17a5701

Please sign in to comment.