diff --git a/modules/reactor/doc/content/source/meshgenerators/FlexiblePatternGenerator.md b/modules/reactor/doc/content/source/meshgenerators/FlexiblePatternGenerator.md index 1bec42b7bada..1ad2c6b7ed09 100644 --- a/modules/reactor/doc/content/source/meshgenerators/FlexiblePatternGenerator.md +++ b/modules/reactor/doc/content/source/meshgenerators/FlexiblePatternGenerator.md @@ -91,6 +91,10 @@ In both [!param](/Mesh/FlexiblePatternGenerator/hex_patterns) and [!param](/Mesh id=mixed_pattern_m caption=Output example of mixed patterning with dummy unit meshes. +## Extra Element ID Assignment for Unit Meshes + +For each unit mesh involved in the patterning, an additional element ID can be automatically assigned to facilitate subsequent data analysis. This extra element ID can be specified using the [!param](/Mesh/FlexiblePatternGenerator/unit_mesh_id_name) parameter. By default, the assigned extra element ID begins with 0 and increments by 1. Alternatively, the generated extra element ID can be shifted using the [!param](/Mesh/FlexiblePatternGenerator/unit_mesh_id_shift) parameter. + !syntax parameters /Mesh/FlexiblePatternGenerator !syntax inputs /Mesh/FlexiblePatternGenerator diff --git a/modules/reactor/include/meshgenerators/FlexiblePatternGenerator.h b/modules/reactor/include/meshgenerators/FlexiblePatternGenerator.h index c6250331ab10..c607f46f9ab0 100644 --- a/modules/reactor/include/meshgenerators/FlexiblePatternGenerator.h +++ b/modules/reactor/include/meshgenerators/FlexiblePatternGenerator.h @@ -74,6 +74,11 @@ class FlexiblePatternGenerator : public PolygonMeshGeneratorBase // PolygonMeshGeneratorBase::INTRINSIC_SIDESET_ID::OUTER_SIDESET_ID) from the inputs const bool _delete_default_external_boundary_from_inputs; + /// Name of the extra element id to be assigned to distinguish each unit mesh + const std::string _unit_mesh_id_name; + /// Shift value to be added to the extra element id to distinguish each unit mesh + const dof_id_type _unit_mesh_id_shift; + /// Boundary ID of the external boundary const boundary_id_type _external_boundary_id; /// Boundary Name of the external boundary diff --git a/modules/reactor/src/meshgenerators/FlexiblePatternGenerator.C b/modules/reactor/src/meshgenerators/FlexiblePatternGenerator.C index 41849fed526b..0e6b3920bf4b 100644 --- a/modules/reactor/src/meshgenerators/FlexiblePatternGenerator.C +++ b/modules/reactor/src/meshgenerators/FlexiblePatternGenerator.C @@ -129,6 +129,15 @@ FlexiblePatternGenerator::validParams() true, "Whether to delete the default external boundary from the input meshes."); + params.addParam( + "unit_mesh_id_name", + "The name of the extra element id to be assigned to the unit meshes used for patterning."); + + params.addParam("unit_mesh_id_shift", + 0, + "The shift value to be added to the unit mesh id to avoid conflicts " + "with ids in other meshes."); + params.addClassDescription("This FlexiblePatternGenerator object is designed to generate a " "mesh with a background region with dispersed unit meshes in " "it and distributed based on a series of flexible patterns."); @@ -207,6 +216,10 @@ FlexiblePatternGenerator::FlexiblePatternGenerator(const InputParameters & param : SubdomainName()), _delete_default_external_boundary_from_inputs( getParam("delete_default_external_boundary_from_inputs")), + _unit_mesh_id_name(isParamValid("unit_mesh_id_name") + ? getParam("unit_mesh_id_name") + : std::string()), + _unit_mesh_id_shift(getParam("unit_mesh_id_shift")), _external_boundary_id(isParamValid("external_boundary_id") ? getParam("external_boundary_id") : (boundary_id_type)OUTER_SIDESET_ID), @@ -217,6 +230,12 @@ FlexiblePatternGenerator::FlexiblePatternGenerator(const InputParameters & param { declareMeshesForSub("inputs"); + if (_unit_mesh_id_name.empty() && isParamSetByUser("unit_mesh_id_name")) + paramError("unit_mesh_id_name", "This parameter must be non empty if provided."); + if (_unit_mesh_id_name.empty() && isParamSetByUser("unit_mesh_id_shift")) + paramError("unit_mesh_id_name", + "This parameter must be provided if unit_mesh_id_shift is set."); + const std::vector extra_positions(getParam>("extra_positions")); const std::vector extra_positions_mg_indices( getParam>("extra_positions_mg_indices")); @@ -509,6 +528,17 @@ FlexiblePatternGenerator::FlexiblePatternGenerator(const InputParameters & param patterned_pin_mg_series.push_back(name() + "_pos_" + std::to_string(i)); addMeshSubgenerator("TransformGenerator", patterned_pin_mg_series.back(), params); + + if (_unit_mesh_id_name.size()) + { + auto params = _app.getFactory().getValidParams("ParsedExtraElementIDGenerator"); + params.set("input") = patterned_pin_mg_series.back(); + params.set("expression") = std::to_string(i + _unit_mesh_id_shift); + params.set("extra_elem_integer_name") = _unit_mesh_id_name; + + patterned_pin_mg_series.back() = name() + "_eeid_" + std::to_string(i); + addMeshSubgenerator("ParsedExtraElementIDGenerator", patterned_pin_mg_series.back(), params); + } } auto params = _app.getFactory().getValidParams("XYDelaunayGenerator"); diff --git a/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/fp_eeid.i b/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/fp_eeid.i new file mode 100644 index 000000000000..ce01d612eed8 --- /dev/null +++ b/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/fp_eeid.i @@ -0,0 +1,125 @@ +[Mesh] + [accg_1] + type = AdvancedConcentricCircleGenerator + num_sectors = 9 + ring_radii = '2' + ring_intervals = '1' + ring_block_ids = '10' + ring_block_names = 'accg_1' + create_outward_interface_boundaries = false + [] + [accg_2] + type = AdvancedConcentricCircleGenerator + num_sectors = 9 + ring_radii = '2' + ring_intervals = '1' + ring_block_ids = '20' + ring_block_names = 'accg_2' + create_outward_interface_boundaries = false + [] + [accg_3] + type = AdvancedConcentricCircleGenerator + num_sectors = 9 + ring_radii = '2' + ring_intervals = '1' + ring_block_ids = '30' + ring_block_names = 'accg_3' + create_outward_interface_boundaries = false + [] + [fpg] + type = FlexiblePatternGenerator + inputs = 'accg_1 accg_2 accg_3' + boundary_type = HEXAGON + boundary_size = ${fparse 12.0*sqrt(3.0)} + boundary_sectors = 10 + + extra_positions = '0.0 6.0 0.0 + 0.0 -6.0 0.0 + 0.0 0.0 0.0' + extra_positions_mg_indices = '0 1 2' + + desired_area = 1.0 + [] +[] + +[Problem] + solve = false +[] + +[AuxVariables] + [pin_id] + order = CONSTANT + family = MONOMIAL + [] +[] + +[AuxKernels] + [pin_id] + type = ExtraElementIDAux + extra_id_name = pin_id + variable = pin_id + [] +[] + +[Postprocessors] + [accg_1_pin_id_avg] + type = ElementAverageValue + variable = pin_id + block = 10 + [] + [accg_2_pin_id_avg] + type = ElementAverageValue + variable = pin_id + block = 20 + [] + [accg_3_pin_id_avg] + type = ElementAverageValue + variable = pin_id + block = 30 + [] + [accg_1_pin_id_max] + type = ElementExtremeValue + variable = pin_id + block = 10 + [] + [accg_2_pin_id_max] + type = ElementExtremeValue + variable = pin_id + block = 20 + [] + [accg_3_pin_id_max] + type = ElementExtremeValue + variable = pin_id + block = 30 + [] + [accg_1_pin_id_min] + type = ElementExtremeValue + variable = pin_id + block = 10 + value_type = min + [] + [accg_2_pin_id_min] + type = ElementExtremeValue + variable = pin_id + block = 20 + value_type = min + [] + [accg_3_pin_id_min] + type = ElementExtremeValue + variable = pin_id + block = 30 + value_type = min + [] +[] + +[Executioner] + type = Transient + num_steps = 1 +[] + +[Outputs] + [csv] + type = CSV + execute_on = FINAL + [] +[] diff --git a/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/gold/fp_eeid_csv.csv b/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/gold/fp_eeid_csv.csv new file mode 100644 index 000000000000..206dde01e3f1 --- /dev/null +++ b/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/gold/fp_eeid_csv.csv @@ -0,0 +1,2 @@ +time,accg_1_pin_id_avg,accg_1_pin_id_max,accg_1_pin_id_min,accg_2_pin_id_avg,accg_2_pin_id_max,accg_2_pin_id_min,accg_3_pin_id_avg,accg_3_pin_id_max,accg_3_pin_id_min +1,1,1,1,2,2,2,3,3,3 diff --git a/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/tests b/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/tests index 574f7aa771c6..c0761af83881 100644 --- a/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/tests +++ b/modules/reactor/test/tests/meshgenerators/flexible_pattern_generator/tests @@ -1,6 +1,6 @@ [Tests] design = 'meshgenerators/FlexiblePatternGenerator.md' - issues = '#24938 #26776 #27471' + issues = '#24938 #26776 #27471 #29529' [test] requirement = "The system shall generate " [single_hex_pattern_hex] @@ -89,6 +89,15 @@ recover = false detail = "a mixed patterned mesh with hexagonal background." [] + [eeid] + type = CSVDiff + input = fp_eeid.i + csvdiff = fp_eeid_csv.csv + cli_args = "Mesh/fpg/unit_mesh_id_name='pin_id' + Mesh/fpg/unit_mesh_id_shift=1" + recover = false + detail = "a patterned mesh with an extra element id assigned to each unit mesh." + [] [patterned_assm] type = CSVDiff input = patterned_assm.i @@ -333,5 +342,19 @@ expect_err = "this parameter must be provided for non-CUSTOM" detail = "if the boundary pitch value is not provided when the boundary type is not custom." [] + [error_empty_eeid_name] + type = RunException + input = fp_eeid.i + cli_args = "Mesh/fpg/unit_mesh_id_name=''" + expect_err = "This parameter must be non empty if provided." + detail = "if an empty unit mesh id name is provided." + [] + [error_standalone_eeid_shift] + type = RunException + input = fp_eeid.i + cli_args = "Mesh/fpg/unit_mesh_id_shift=1" + expect_err = "This parameter must be provided if unit_mesh_id_shift is set." + detail = "if a unit mesh id shift is set without specifying the unit mesh id name." + [] [] []