22 params.
addRequiredParam<std::vector<MeshGeneratorName>>(
"inputs",
"The input MeshGenerators.");
23 MooseEnum boundary_type(
"HEXAGON CARTESIAN CIRCLE CUSTOM",
"CUSTOM");
26 "what type of boundary is used as background for patterning.");
29 "The boundary mesh consisting of EDGE2 elements to be used as the 'CUSTOM' boundary.");
33 "The number of sectors on each side of the HEXAGON or CARTESIAN boundary mesh or on the " 34 "circular boundary of the CIRCLE boundary mesh.");
37 "The pitch size of the HEXAGON or CARTESIAN boundary mesh; or " 38 "the diameter of the CIRCLE boundary mesh.");
41 "extra_positions", {},
"The extra non-patterned positions to set the input MeshGenerators.");
42 params.
addParam<std::vector<unsigned int>>(
43 "extra_positions_mg_indices",
45 "the indices of the input mesh generators for the extra position.");
47 params.
addParam<std::vector<std::vector<std::vector<unsigned int>>>>(
"hex_patterns",
48 "Hexagonal patterns set.");
50 "hex_pitches",
"hex_pitches>0",
"pitch sizes used to generate the hexagonal patterns.");
51 params.
addParam<std::vector<Point>>(
"hex_origins",
52 "the origin positions of the hexagonal patterns,");
53 params.
addParam<std::vector<Real>>(
"hex_rotations",
54 "the rotation angles of the hexagonal patterns,");
56 params.
addParam<std::vector<std::vector<std::vector<unsigned int>>>>(
"rect_patterns",
57 "Rectangular patterns set.");
61 "pitch sizes in x direction used to generate the rectangular patterns.");
65 "pitch sizes in y direction used to generate the rectangular patterns.");
66 params.
addParam<std::vector<Point>>(
"rect_origins",
67 "the origin positions of the rectangular patterns,");
68 params.
addParam<std::vector<Real>>(
"rect_rotations",
69 "the rotation angles of the rectangular patterns.");
71 params.
addParam<std::vector<std::vector<unsigned int>>>(
"circular_patterns",
72 "Circular patterns set.");
74 "circular_radii",
"circular_radii>0",
"the radii of the circular patterns.");
75 params.
addParam<std::vector<Point>>(
"circular_origins",
76 "the origin positions of the circular patterns,");
79 "the rotation angles of the circular patterns (the azimuthal angle of the first unit mesh).");
82 params.
addParam<
Real>(
"desired_area", 0.0,
"Desired are for the background area meshing.");
86 "Desired area as a function of x,y; omit to skip non-uniform refinement");
88 params.
addParam<
bool>(
"use_auto_area_func",
90 "Use the automatic area function for triangle-meshing in the background.");
92 "auto_area_func_default_size",
94 "Background size for automatic area function, or 0 to use non background size");
95 params.
addParam<
Real>(
"auto_area_func_default_size_dist",
97 "Effective distance of background size for automatic area " 98 "function, or negative to use non background size");
99 params.
addParam<
unsigned int>(
"auto_area_function_num_points",
101 "Maximum number of nearest points used for the inverse distance " 102 "interpolation algorithm for automatic area function calculation.");
104 "auto_area_function_power",
106 "auto_area_function_power>0",
107 "Polynomial power of the inverse distance interpolation algorithm for automatic area " 108 "function calculation.");
110 params.
addParam<
bool>(
"verify_holes",
true,
"Whether the holes are verified.");
112 "background_subdomain_id",
113 "background_subdomain_id>0",
114 "Subdomain id to set on the background area meshed by Delaunay algorithm.");
116 "background_subdomain_name",
117 "Subdomain name to set on the background area meshed by Delaunay algorithm.");
118 MooseEnum tri_elem_type(
"TRI3 TRI6 TRI7 DEFAULT",
"DEFAULT");
120 "tri_element_type", tri_elem_type,
"Type of the triangular elements to be generated.");
123 "external_boundary_id",
124 "The boundary id of the external boundary in addition to the default 10000.");
125 params.
addParam<BoundaryName>(
"external_boundary_name",
126 "Optional boundary name for the external boundary.");
128 params.
addParam<
bool>(
"delete_default_external_boundary_from_inputs",
130 "Whether to delete the default external boundary from the input meshes.");
132 params.
addParam<ExtraElementIDName>(
134 "The name of the extra element id to be assigned for each component " 135 "unit mesh in sequential order.");
140 "The shift value to be added to the cell id to avoid conflicts with ids in other meshes.");
142 params.
addParam<ExtraElementIDName>(
144 "The name of the extra element id to be assigned based on the ID of " 145 "the input meshes in sequential order.");
150 "The shift value to be added to the pattern id to avoid conflicts with ids in other meshes.");
152 params.
addClassDescription(
"This FlexiblePatternGenerator object is designed to generate a " 153 "mesh with a background region with dispersed unit meshes in " 154 "it and distributed based on a series of flexible patterns.");
157 "Hexagonal Pattern");
159 "rect_patterns rect_pitches_x rect_pitches_y rect_origins rect_rotations",
160 "Rectangular Pattern");
162 "circular_patterns circular_radii circular_origins circular_rotations",
"Circular Pattern");
164 "Extra Positions (Free-Style Patterns)");
165 params.
addParamNamesToGroup(
"desired_area desired_area_func verify_holes background_subdomain_id " 166 "background_subdomain_name use_auto_area_func " 167 "auto_area_func_default_size auto_area_func_default_size_dist " 168 "auto_area_function_num_points auto_area_function_power",
169 "Background Area Delaunay");
171 "boundary_type boundary_mesh boundary_sectors boundary_size " 172 "delete_default_external_boundary_from_inputs external_boundary_id external_boundary_name",
182 _input_names(getParam<
std::vector<MeshGeneratorName>>(
"inputs")),
183 _boundary_type(getParam<
MooseEnum>(
"boundary_type").template getEnum<
BdryType>()),
184 _boundary_mesh_name(isParamValid(
"boundary_mesh") ? getParam<MeshGeneratorName>(
"boundary_mesh")
185 : MeshGeneratorName()),
186 _boundary_sectors(isParamValid(
"boundary_sectors") ? getParam<unsigned
int>(
"boundary_sectors")
188 _boundary_size(isParamValid(
"boundary_size") ? getParam<
Real>(
"boundary_size") : 0.0),
190 isParamValid(
"hex_patterns")
191 ? getParam<
std::vector<
std::vector<
std::vector<unsigned
int>>>>(
"hex_patterns")
192 :
std::vector<
std::vector<
std::vector<unsigned
int>>>()),
193 _hex_pitches(isParamValid(
"hex_pitches") ? getParam<
std::vector<
Real>>(
"hex_pitches")
195 _hex_origins(isParamValid(
"hex_origins")
196 ? getParam<
std::vector<Point>>(
"hex_origins")
197 :
std::vector<Point>(_hex_patterns.size(), Point(0.0, 0.0, 0.0))),
198 _hex_rotations(isParamValid(
"hex_rotations") ? getParam<
std::vector<
Real>>(
"hex_rotations")
199 :
std::vector<
Real>(_hex_patterns.size(), 0.0)),
201 isParamValid(
"rect_patterns")
202 ? getParam<
std::vector<
std::vector<
std::vector<unsigned
int>>>>(
"rect_patterns")
203 :
std::vector<
std::vector<
std::vector<unsigned
int>>>()),
204 _rect_pitches_x(isParamValid(
"rect_pitches_x") ? getParam<
std::vector<
Real>>(
"rect_pitches_x")
206 _rect_pitches_y(isParamValid(
"rect_pitches_y") ? getParam<
std::vector<
Real>>(
"rect_pitches_y")
208 _rect_origins(isParamValid(
"rect_origins")
209 ? getParam<
std::vector<Point>>(
"rect_origins")
210 :
std::vector<Point>(_rect_patterns.size(), Point(0.0, 0.0, 0.0))),
211 _rect_rotations(isParamValid(
"rect_rotations") ? getParam<
std::vector<
Real>>(
"rect_rotations")
212 :
std::vector<
Real>(_rect_patterns.size(), 0.0)),
213 _circ_patterns(isParamValid(
"circular_patterns")
214 ? getParam<
std::vector<
std::vector<unsigned
int>>>(
"circular_patterns")
215 :
std::vector<
std::vector<unsigned
int>>()),
216 _circ_radii(isParamValid(
"circular_radii") ? getParam<
std::vector<
Real>>(
"circular_radii")
218 _circ_origins(isParamValid(
"circular_origins")
219 ? getParam<
std::vector<Point>>(
"circular_origins")
220 :
std::vector<Point>(_circ_patterns.size(), Point(0.0, 0.0, 0.0))),
221 _circ_rotations(isParamValid(
"circular_rotations")
222 ? getParam<
std::vector<
Real>>(
"circular_rotations")
223 :
std::vector<
Real>(_circ_patterns.size(), 0.0)),
224 _background_subdomain_id(isParamValid(
"background_subdomain_id")
227 _background_subdomain_name(isParamValid(
"background_subdomain_name")
228 ? getParam<SubdomainName>(
"background_subdomain_name")
230 _delete_default_external_boundary_from_inputs(
231 getParam<bool>(
"delete_default_external_boundary_from_inputs")),
232 _cell_id_name(isParamValid(
"cell_id_name") ? getParam<ExtraElementIDName>(
"cell_id_name")
233 : ExtraElementIDName()),
234 _cell_id_shift(getParam<
dof_id_type>(
"cell_id_shift")),
235 _pattern_id_name(isParamValid(
"pattern_id_name")
236 ? getParam<ExtraElementIDName>(
"pattern_id_name")
237 : ExtraElementIDName()),
238 _pattern_id_shift(getParam<
dof_id_type>(
"pattern_id_shift")),
239 _external_boundary_id(isParamValid(
"external_boundary_id")
242 _external_boundary_name(isParamValid(
"external_boundary_name")
243 ? getParam<BoundaryName>(
"external_boundary_name")
250 paramError(
"cell_id_name",
"This parameter must be non empty if provided.");
252 paramError(
"cell_id_name",
"This parameter must be provided if cell_id_shift is set.");
254 paramError(
"pattern_id_name",
"This parameter must be non empty if provided.");
256 paramError(
"pattern_id_name",
"This parameter must be provided if pattern_id_shift is set.");
258 const std::vector<Point> extra_positions(
getParam<std::vector<Point>>(
"extra_positions"));
259 const std::vector<unsigned int> extra_positions_mg_indices(
260 getParam<std::vector<unsigned int>>(
"extra_positions_mg_indices"));
261 if (extra_positions.size() != extra_positions_mg_indices.size())
263 "This parameter must have the same size as extra_positions.");
264 std::vector<unsigned int> input_usage_count(
_input_names.size(), 0);
265 for (
unsigned int i = 0; i < extra_positions.size(); i++)
267 if (extra_positions_mg_indices[i] >=
_input_names.size())
269 "the index used for extra positions must be available in 'inputs'.");
270 input_usage_count[extra_positions_mg_indices[i]]++;
271 _positions.push_back(std::make_pair(extra_positions[i], extra_positions_mg_indices[i]));
276 "This parameter must be provided if background_subdomain_name is provided.");
281 paramError(
"boundary_mesh",
"boundary_mesh must be specified for CUSTOM boundary_type.");
285 "this parameter should not be provided for CUSTOM boundary_type.");
288 "this parameter should not be provided for CUSTOM boundary_type.");
294 "this parameter should not be provided for non-CUSTOM " 298 "this parameter must be provided for non-CUSTOM " 301 paramError(
"boundary_size",
"this parameter must be provided for non-CUSTOM boundary_type.");
308 params.
set<
bool>(
"loop") =
true;
310 params.set<std::vector<Point>>(
"points") = {
325 params.
set<
bool>(
"loop") =
true;
327 params.set<std::vector<Point>>(
"points") = {
341 params.
set<
bool>(
"loop") =
true;
342 params.set<
unsigned int>(
"num_edges_between_points") = 1;
346 std::vector<Point> circular_points;
350 circular_points.push_back(Point(
_boundary_size * corr_factor * std::cos(angle) / 2.0,
354 params.set<std::vector<Point>>(
"points") = circular_points;
360 declareMeshProperty<bool>(
"is_control_drum_meta",
false);
366 "The length of this parameter must be the same as that of hex_patterns.");
370 "if provided, the length of this parameter must be the same as that of hex_patterns.");
374 "if provided, the length of this parameter must be the same as that of hex_patterns.");
375 std::vector<Point> hex_positions;
378 unsigned int hex_index = 0;
381 const unsigned int n_hex_pattern_layers = hex_pattern.size();
382 if (n_hex_pattern_layers % 2 == 0)
384 "The length (layer number) of each element of this parameter must be odd to " 385 "ensure hexagonal shapes.");
386 if (n_hex_pattern_layers == 1)
388 "The length (layer number) of each element of this parameter must be larger " 390 for (
unsigned int i = 0; i <= n_hex_pattern_layers / 2; i++)
392 if (hex_pattern[i].size() != n_hex_pattern_layers / 2 + i + 1 ||
393 hex_pattern[n_hex_pattern_layers - 1 - i].size() != n_hex_pattern_layers / 2 + i + 1)
395 "The two-dimentional array element of this parameter must have a correct " 399 const Point unit_shift_1 = Point(
_hex_pitches[hex_index], 0.0, 0.0);
400 const Point unit_shift_2 =
403 for (
unsigned int i = 0; i < hex_pattern.size(); i++)
405 const Real param_2 = ((
Real)hex_pattern.size() - 1.0) / 2.0 - (
Real)i;
406 const Real param_1_init = -((
Real)hex_pattern.size() - 1.0) / 2.0 -
407 ((i <= (hex_pattern.size() - 1) / 2)
409 : (((
Real)(hex_pattern.size() - 1) / 2) - (
Real)i));
410 for (
unsigned int j = 0;
j < hex_pattern[i].size();
j++)
415 input_usage_count[hex_pattern[i][
j]]++;
416 Point pt_buffer = unit_shift_1 * (param_1_init + (
Real)
j) + unit_shift_2 * param_2;
419 std::make_pair(pt_buffer +
_hex_origins[hex_index], hex_pattern[i][
j]));
430 "The length of this parameter must be the same as that of rect_patterns.");
433 "The length of this parameter must be the same as that of rect_patterns.");
437 "if provided, the length of this parameter must be the same as that of rect_patterns.");
441 "if provided, the length of this parameter must be the same as that of rect_patterns.");
444 unsigned int rect_index = 0;
447 std::set<unsigned int> rect_pattern_elem_size;
448 for (
const auto & rect_pattern_elem : rect_pattern)
450 if (rect_pattern_elem.empty())
451 paramError(
"rect_patterns",
"Each row of the element pattern must not be empty.");
452 rect_pattern_elem_size.emplace(rect_pattern_elem.size());
454 if (rect_pattern_elem_size.size() > 1)
456 "The two-dimensional array element of this parameter must have a correct " 457 "rectangular shape.");
459 const Point unit_shift_1 = Point(
_rect_pitches_x[rect_index], 0.0, 0.0);
460 const Point unit_shift_2 = Point(0.0,
_rect_pitches_y[rect_index], 0.0);
462 for (
unsigned int i = 0; i < rect_pattern.size(); i++)
464 const Real param_2 = ((
Real)rect_pattern.size() - 1.0) / 2.0 - (
Real)i;
465 const Real param_1_init = -((
Real)rect_pattern[i].size() - 1.0) / 2.0;
466 for (
unsigned int j = 0;
j < rect_pattern[i].size();
j++)
470 input_usage_count[rect_pattern[i][
j]]++;
471 Point pt_buffer = unit_shift_1 * (param_1_init + (
Real)
j) + unit_shift_2 * param_2;
474 std::make_pair(pt_buffer +
_rect_origins[rect_index], rect_pattern[i][
j]));
485 "The length of this parameter must be the same as that of circular_patterns.");
489 "if provided, the length of this parameter must be the same as that of circular_patterns.");
492 "circular_rotations",
493 "if provided, the length of this parameter must be the same as that of circular_patterns.");
496 unsigned int circ_index = 0;
499 const Real angle_step = 2.0 * M_PI / (
Real)circ_pattern.size();
501 for (
unsigned int i = 0; i < circ_pattern.size(); i++)
505 input_usage_count[circ_pattern[i]]++;
506 Point pt_buffer = Point(
_circ_radii[circ_index] * std::cos((
Real)i * angle_step),
511 std::make_pair(pt_buffer +
_circ_origins[circ_index], circ_pattern[i]));
518 if (std::count(input_usage_count.begin(), input_usage_count.end(), 0))
519 paramError(
"inputs",
"All the input mesh generator names are not used.");
526 params.
set<MeshGeneratorName>(
"input") = input_name;
527 params.set<std::vector<BoundaryName>>(
"boundary_names") = {std::to_string(
OUTER_SIDESET_ID)};
531 static_cast<MeshGeneratorName>(
"_" +
name() +
"_del_ext_bdry"),
536 std::vector<MeshGeneratorName> patterned_pin_mg_series;
537 for (
unsigned int i = 0; i <
_positions.size(); i++)
540 params.
set<MeshGeneratorName>(
"input") =
542 static_cast<MeshGeneratorName>(
547 patterned_pin_mg_series.push_back(
name() +
"_pos_" + std::to_string(i));
554 params.
set<MeshGeneratorName>(
"input") = patterned_pin_mg_series.back();
555 params.set<std::string>(
"expression") = std::to_string(i +
_cell_id_shift);
556 params.set<std::string>(
"extra_elem_integer_name") =
_cell_id_name;
558 patterned_pin_mg_series.back() =
name() +
"_ceeid_" + std::to_string(i);
559 addMeshSubgenerator(
"ParsedExtraElementIDGenerator", patterned_pin_mg_series.back(), params);
564 params.
set<MeshGeneratorName>(
"input") = patterned_pin_mg_series.back();
565 params.set<std::string>(
"expression") =
569 patterned_pin_mg_series.back() =
name() +
"_peeid_" + std::to_string(i);
570 addMeshSubgenerator(
"ParsedExtraElementIDGenerator", patterned_pin_mg_series.back(), params);
576 params.set<std::vector<MeshGeneratorName>>(
"holes") = patterned_pin_mg_series;
577 params.set<
bool>(
"refine_boundary") =
false;
579 params.set<
bool>(
"verify_holes") = getParam<bool>(
"verify_holes");
580 params.set<std::vector<bool>>(
"stitch_holes") =
581 std::vector<bool>(patterned_pin_mg_series.size(),
true);
582 params.set<std::vector<bool>>(
"refine_holes") =
583 std::vector<bool>(patterned_pin_mg_series.size(),
false);
584 params.set<
Real>(
"desired_area") = getParam<Real>(
"desired_area");
585 params.set<std::string>(
"desired_area_func") = getParam<std::string>(
"desired_area_func");
586 params.set<
bool>(
"use_auto_area_func") = getParam<bool>(
"use_auto_area_func");
588 params.set<
Real>(
"auto_area_func_default_size") = getParam<Real>(
"auto_area_func_default_size");
590 params.set<
Real>(
"auto_area_func_default_size_dist") =
591 getParam<Real>(
"auto_area_func_default_size_dist");
593 params.set<
unsigned int>(
"auto_area_function_num_points") =
594 getParam<unsigned int>(
"auto_area_function_num_points");
596 params.set<
Real>(
"auto_area_function_power") = getParam<Real>(
"auto_area_function_power");
597 params.set<BoundaryName>(
"output_boundary") = std::to_string(
OUTER_SIDESET_ID);
598 params.set<
MooseEnum>(
"tri_element_type") = getParam<MooseEnum>(
"tri_element_type");
601 MeshGeneratorName final_mg_name(
name() +
"_pattern");
605 params.
set<MeshGeneratorName>(
"input") =
name() +
"_pattern";
606 params.set<std::vector<SubdomainName>>(
"old_block") = {
"0"};
607 params.set<std::vector<SubdomainName>>(
"new_block") = {
613 params.
set<MeshGeneratorName>(
"input") =
name() +
"_back_rename_1";
614 params.set<std::vector<SubdomainName>>(
"old_block") = {
618 final_mg_name =
name() +
"_back_rename_2";
621 final_mg_name =
name() +
"_back_rename_1";
627 std::unique_ptr<MeshBase>
635 const auto external_id_by_name =
641 " is already associated with id " + std::to_string(external_id_by_name) +
642 ", which differs from the user-specified external_boundary_id " +
650 (*_build_mesh)->find_neighbors();
651 (*_build_mesh)->set_isnt_prepared();
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
registerMooseObject("ReactorApp", FlexiblePatternGenerator)
BdryType
Type of boundary mesh to be used for the background region.
const bool _delete_default_external_boundary_from_inputs
This FlexiblePatternGenerator object is designed to generate a complex mesh with a background region ...
const BoundaryID INVALID_BOUNDARY_ID
const BoundaryName _external_boundary_name
Boundary Name of the external boundary.
const std::vector< MeshGeneratorName > & _input_names
Names of input meshes that are used as unit meshes in patterning.
static InputParameters validParams()
const std::vector< std::vector< std::vector< unsigned int > > > _hex_patterns
Hexagonal patterns.
const std::vector< std::vector< std::vector< unsigned int > > > _rect_patterns
Rectangular patterns.
InputParameters getValidParams(const std::string &name) const
const ExtraElementIDName _pattern_id_name
Name of the extra element id to be assigned to distinguish input unit meshes.
const subdomain_id_type _background_subdomain_id
const std::vector< Point > _circ_origins
List of origins of the circular patterns.
const Real _boundary_size
Pitch size of the hexagonal or cartesian background region; or diameter of the circular region...
void changeBoundaryId(const boundary_id_type old_id, const boundary_id_type new_id, bool delete_prev)
const SubdomainName _background_subdomain_name
std::unique_ptr< MeshBase > generate() override
const std::vector< Real > _hex_rotations
List of rotation angles of the hexagonal patterns.
virtual const std::string & name() const
const ExtraElementIDName _cell_id_name
Name of the extra element id to be assigned to distinguish component unit cell meshes.
const boundary_id_type _external_boundary_id
Boundary ID of the external boundary.
void nodeCoordRotate(Real &x, Real &y, const Real theta) const
Calculates x and y coordinates after rotating by theta angle.
void declareMeshForSub(const std::string ¶m_name)
const SubdomainID INVALID_BLOCK_ID
const std::vector< Real > _rect_pitches_y
List of pitches of the rectangular patterns in y direction.
static InputParameters validParams()
const std::vector< std::vector< unsigned int > > _circ_patterns
Circular patterns.
const std::vector< Real > _rect_rotations
List of rotation angles of the rectangular patterns.
const std::vector< Real > _hex_pitches
List of pitches of the hexagonal patterns.
std::unique_ptr< MeshBase > * _build_mesh
The final mesh that is generated by the subgenerators; This mesh is generated by the subgenerators wi...
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
const unsigned int _boundary_sectors
Number of sectors on each side of the hexagonal or cartesian background region or on the circular bou...
FlexiblePatternGenerator(const InputParameters ¶meters)
const T & getParam(const std::string &name) const
void paramError(const std::string ¶m, Args... args) const
const std::vector< Real > _circ_radii
List of radii of the circular patterns.
const std::vector< Real > _circ_rotations
List of rotation angles of the circular patterns.
bool isParamSetByUser(const std::string &nm) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::pair< Point, unsigned int > > _positions
Positions of all the unit meshes after patterning.
A base class that contains common members for Reactor module mesh generators.
const dof_id_type _cell_id_shift
Shift value to be added to the extra element id to distinguish component unit cell meshes...
T & declareMeshProperty(const std::string &data_name, Args &&... args)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const std::vector< Point > _hex_origins
List of origins of the hexagonal patterns.
MeshGeneratorName _boundary_mesh_name
Name of the input mesh that defines the external boundary of the background region.
const std::vector< Real > _rect_pitches_x
List of pitches of the rectangular patterns in x direction.
void declareMeshesForSub(const std::string ¶m_name)
const dof_id_type _pattern_id_shift
Shift value to be added to the extra element id to distinguish input unit meshes. ...
const std::vector< Point > _rect_origins
List of origins of the rectangular patterns.
void ErrorVector unsigned int
enum FlexiblePatternGenerator::BdryType _boundary_type