Skip to content

Commit

Permalink
Add Auto EEID Assignment in FlexiblePatternGenerator
Browse files Browse the repository at this point in the history
closes #29529
  • Loading branch information
miaoyinb committed Dec 12, 2024
1 parent f46a73c commit 50b7683
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions modules/reactor/src/meshgenerators/FlexiblePatternGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ FlexiblePatternGenerator::validParams()
true,
"Whether to delete the default external boundary from the input meshes.");

params.addParam<std::string>(
"unit_mesh_id_name",
"The name of the extra element id to be assigned to the unit meshes used for patterning.");

params.addParam<dof_id_type>("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.");
Expand Down Expand Up @@ -207,6 +216,10 @@ FlexiblePatternGenerator::FlexiblePatternGenerator(const InputParameters & param
: SubdomainName()),
_delete_default_external_boundary_from_inputs(
getParam<bool>("delete_default_external_boundary_from_inputs")),
_unit_mesh_id_name(isParamValid("unit_mesh_id_name")
? getParam<std::string>("unit_mesh_id_name")
: std::string()),
_unit_mesh_id_shift(getParam<dof_id_type>("unit_mesh_id_shift")),
_external_boundary_id(isParamValid("external_boundary_id")
? getParam<boundary_id_type>("external_boundary_id")
: (boundary_id_type)OUTER_SIDESET_ID),
Expand All @@ -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<Point> extra_positions(getParam<std::vector<Point>>("extra_positions"));
const std::vector<unsigned int> extra_positions_mg_indices(
getParam<std::vector<unsigned int>>("extra_positions_mg_indices"));
Expand Down Expand Up @@ -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<MeshGeneratorName>("input") = patterned_pin_mg_series.back();
params.set<std::string>("expression") = std::to_string(i + _unit_mesh_id_shift);
params.set<std::string>("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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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
[]
[]
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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."
[]
[]
[]

0 comments on commit 50b7683

Please sign in to comment.