Skip to content

Commit

Permalink
Merge pull request idaholab#29530 from miaoyinb/flexPatternEEID
Browse files Browse the repository at this point in the history
Add Auto EEID Assignment in FlexiblePatternGenerator
  • Loading branch information
GiudGiud authored Dec 16, 2024
2 parents 38207e8 + cd8f050 commit 70a6fb6
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ 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, two types of extra element IDs can be automatically assigned to facilitate subsequent data analysis, using different assignment modes.

The `cell` style extra element ID can be specified using the [!param](/Mesh/FlexiblePatternGenerator/cell_id_name) parameter. It is similar to the `cell` option in [`PatternedHexMeshGenerator`](/PatternedHexMeshGenerator.md)'s [!param](/Mesh/PatternedHexMeshGenerator/assign_type) parameter, which assigns a unique extra element ID for each component unit mesh in sequential order. On the other hand, the `pattern` style extra element ID can be specified using the [!param](/Mesh/FlexiblePatternGenerator/pattern_id_name) parameter. It is similar to the `pattern` option in [`PatternedHexMeshGenerator`](/PatternedHexMeshGenerator.md)'s [!param](/Mesh/PatternedHexMeshGenerator/assign_type) parameter, which assigns the extra element ID based on the IDs (i.e., sequential order) of the input meshes defined in [!param](/Mesh/FlexiblePatternGenerator/inputs). By default, both assigned extra element IDs begin with 0 and increment by 1. Alternatively, these generated extra element IDs can be shifted using the [!param](/Mesh/FlexiblePatternGenerator/cell_id_shift) and [!param](/Mesh/FlexiblePatternGenerator/pattern_id_shift), respectively.

!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,15 @@ 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 component unit cell meshes
const ExtraElementIDName _cell_id_name;
/// Shift value to be added to the extra element id to distinguish component unit cell meshes
const dof_id_type _cell_id_shift;
/// Name of the extra element id to be assigned to distinguish input unit meshes
const ExtraElementIDName _pattern_id_name;
/// Shift value to be added to the extra element id to distinguish input unit meshes
const dof_id_type _pattern_id_shift;

/// Boundary ID of the external boundary
const boundary_id_type _external_boundary_id;
/// Boundary Name of the external boundary
Expand Down
60 changes: 60 additions & 0 deletions modules/reactor/src/meshgenerators/FlexiblePatternGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,26 @@ FlexiblePatternGenerator::validParams()
true,
"Whether to delete the default external boundary from the input meshes.");

params.addParam<ExtraElementIDName>(
"cell_id_name",
"The name of the extra element id to be assigned for each component "
"unit mesh in sequential order.");

params.addParam<dof_id_type>(
"cell_id_shift",
0,
"The shift value to be added to the cell id to avoid conflicts with ids in other meshes.");

params.addParam<ExtraElementIDName>(
"pattern_id_name",
"The name of the extra element id to be assigned based on the ID of "
"the input meshes in sequential order.");

params.addParam<dof_id_type>(
"pattern_id_shift",
0,
"The shift value to be added to the pattern 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 All @@ -151,6 +171,8 @@ FlexiblePatternGenerator::validParams()
"boundary_type boundary_mesh boundary_sectors boundary_size "
"delete_default_external_boundary_from_inputs external_boundary_id external_boundary_name",
"Boundary");
params.addParamNamesToGroup("cell_id_name cell_id_shift pattern_id_name pattern_id_shift",
"Reporting Id");

return params;
}
Expand Down Expand Up @@ -207,6 +229,13 @@ FlexiblePatternGenerator::FlexiblePatternGenerator(const InputParameters & param
: SubdomainName()),
_delete_default_external_boundary_from_inputs(
getParam<bool>("delete_default_external_boundary_from_inputs")),
_cell_id_name(isParamValid("cell_id_name") ? getParam<ExtraElementIDName>("cell_id_name")
: ExtraElementIDName()),
_cell_id_shift(getParam<dof_id_type>("cell_id_shift")),
_pattern_id_name(isParamValid("pattern_id_name")
? getParam<ExtraElementIDName>("pattern_id_name")
: ExtraElementIDName()),
_pattern_id_shift(getParam<dof_id_type>("pattern_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 +246,15 @@ FlexiblePatternGenerator::FlexiblePatternGenerator(const InputParameters & param
{
declareMeshesForSub("inputs");

if (_cell_id_name.empty() && isParamSetByUser("cell_id_name"))
paramError("cell_id_name", "This parameter must be non empty if provided.");
if (_cell_id_name.empty() && isParamSetByUser("cell_id_shift"))
paramError("cell_id_name", "This parameter must be provided if cell_id_shift is set.");
if (_pattern_id_name.empty() && isParamSetByUser("pattern_id_name"))
paramError("pattern_id_name", "This parameter must be non empty if provided.");
if (_pattern_id_name.empty() && isParamSetByUser("pattern_id_shift"))
paramError("pattern_id_name", "This parameter must be provided if pattern_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 +547,28 @@ 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 (_cell_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 + _cell_id_shift);
params.set<std::string>("extra_elem_integer_name") = _cell_id_name;

patterned_pin_mg_series.back() = name() + "_ceeid_" + std::to_string(i);
addMeshSubgenerator("ParsedExtraElementIDGenerator", patterned_pin_mg_series.back(), params);
}
if (_pattern_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(_positions[i].second + _pattern_id_shift);
params.set<std::string>("extra_elem_integer_name") = _pattern_id_name;

patterned_pin_mg_series.back() = name() + "_peeid_" + 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,104 @@
[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
[]
[fpg]
type = FlexiblePatternGenerator
inputs = 'accg_1 accg_2'
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 0'

pattern_id_name = pattern_id
pattern_id_shift = 20

desired_area = 1.0
[]
[]

[Problem]
solve = false
[]

[AuxVariables]
[pattern_id]
order = CONSTANT
family = MONOMIAL
[]
[]

[AuxKernels]
[pin_id]
type = ExtraElementIDAux
extra_id_name = pattern_id
variable = pattern_id
[]
[]

[Postprocessors]
[accg_1_pin_id_avg]
type = ElementAverageValue
variable = pattern_id
block = 10
[]
[accg_1_pin_id_max]
type = ElementExtremeValue
variable = pattern_id
block = 10
[]
[accg_1_pin_id_min]
type = ElementExtremeValue
variable = pattern_id
block = 10
value_type = min
[]
[accg_2_pin_id_avg]
type = ElementAverageValue
variable = pattern_id
block = 20
[]
[accg_2_pin_id_max]
type = ElementExtremeValue
variable = pattern_id
block = 20
[]
[accg_2_pin_id_min]
type = ElementExtremeValue
variable = pattern_id
block = 20
value_type = min
[]
[]

[Executioner]
type = Transient
num_steps = 1
[]

[Outputs]
[csv]
type = CSV
execute_on = FINAL
file_base = 'fp_eeid_pattern'
[]
[]
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
@@ -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
1,20,20,20,21,21,21
Loading

0 comments on commit 70a6fb6

Please sign in to comment.