15 #include "libmesh/elem.h" 25 params.addRequiredParam<std::vector<MeshGeneratorName>>(
26 "inputs",
"The PinMeshGenerators that form the components of the assembly.");
29 "The integer ID for this assembly type definition");
31 params.addRequiredParam<std::vector<std::vector<unsigned int>>>(
33 "A double-indexed array starting with the upper-left corner where the index" 34 "represents the layout of input pins in the assembly lattice.");
36 params.addRangeCheckedParam<std::vector<Real>>(
39 "Distance(s) from center to duct(s) inner boundaries.");
41 params.addRangeCheckedParam<
unsigned int>(
"background_intervals",
42 "background_intervals>0",
43 "Radial intervals in the assembly peripheral region.");
45 params.addRangeCheckedParam<std::vector<unsigned int>>(
46 "duct_intervals",
"duct_intervals>0",
"Number of meshing intervals in each enclosing duct.");
48 params.addParam<std::vector<subdomain_id_type>>(
49 "background_region_id",
50 "The region id for the background area between the pins and the ducts to set region_id " 51 "extra-element integer");
53 params.addParam<std::vector<std::vector<subdomain_id_type>>>(
55 "The region id for the ducts from innermost to outermost, to set region_id " 56 "extra-element integer.");
58 params.addParam<std::vector<std::string>>(
"background_block_name",
59 "The block names for the assembly background regions");
61 params.addParam<std::vector<std::vector<std::string>>>(
63 "The block names for the assembly duct regions from innermost to outermost");
65 params.addParam<
bool>(
"extrude",
67 "Determines if this is the final step in the geometry construction" 68 " and extrudes the 2D geometry to 3D. If this is true then this mesh " 69 "cannot be used in further mesh building in the Reactor workflow");
70 params.addParamNamesToGroup(
"background_region_id duct_region_ids assembly_type",
"ID assigment");
71 params.addParamNamesToGroup(
"background_intervals background_region_id",
72 "Background specifications");
73 params.addParamNamesToGroup(
"duct_intervals duct_region_ids duct_halfpitch",
74 "Duct specifications");
76 params.addClassDescription(
"This AssemblyMeshGenerator object is designed to generate " 77 "assembly-like structures, with IDs, from a reactor geometry. " 78 "The assembly-like structures must consist of a full pattern of equal " 79 "sized pins from PinMeshGenerator. " 80 "A hexagonal assembly will be placed inside of a bounding hexagon " 81 "consisting of a background region and, optionally," 91 _inputs(getParam<
std::vector<MeshGeneratorName>>(
"inputs")),
93 _pattern(getParam<
std::vector<
std::vector<unsigned
int>>>(
"pattern")),
94 _duct_sizes(isParamValid(
"duct_halfpitch") ? getParam<
std::vector<
Real>>(
"duct_halfpitch")
96 _background_intervals(
97 isParamValid(
"background_intervals") ? getParam<unsigned
int>(
"background_intervals") : 0),
98 _duct_intervals(isParamValid(
"duct_intervals")
99 ? getParam<
std::vector<unsigned
int>>(
"duct_intervals")
100 :
std::vector<unsigned
int>()),
101 _background_region_id(isParamValid(
"background_region_id")
104 _duct_region_ids(isParamValid(
"duct_region_ids")
107 _extrude(getParam<bool>(
"extrude"))
109 MeshGeneratorName reactor_params =
112 for (
unsigned int i = 1; i <
_inputs.size(); i++)
114 mooseError(
"The name of all reactor_params objects should be identical across all input pins " 115 "in the assembly.\n");
125 "In order to extrude this mesh, ReactorMeshParams/dim needs to be set to 3\n");
128 mooseError(
"Both top_boundary_id and bottom_boundary_id must be provided in ReactorMeshParams " 129 "if using extruded geometry");
131 Real base_pitch = 0.0;
134 std::map<subdomain_id_type, std::string> pin_map_type_to_name;
139 base_pitch = getMeshProperty<Real>(
RGMB::pitch, pin);
144 mooseError(
"All pins within an assembly must have the same pitch");
147 mooseError(
"Pins that have already been extruded cannot be used in AssemblyMeshGenerator " 150 if (pin_map_type_to_name.find(
pin_type) != pin_map_type_to_name.end() &&
151 pin_map_type_to_name[
pin_type] != pin)
152 mooseError(
"Constituent pins have shared pin_type ids but different names. Each uniquely " 153 "defined pin in PinMeshGenerator must have its own pin_type id.");
154 pin_map_type_to_name[
pin_type] = pin;
158 unsigned int n_axial_levels =
171 "Assembly pitch must be equal to lattice dimension times pin pitch for Cartesian " 172 "assemblies with no background region");
174 mooseError(
"\"background_region_id\" must be defined if \"background_intervals\" is " 181 "Assembly pitch must be larger than lattice dimension times pin pitch for Cartesian " 182 "assemblies with background region");
184 mooseError(
"\"background_intervals\" must be greater than 0 if \"background_region_id\" is " 188 "The size of background_region_id must be equal to the number of axial levels as " 189 "defined in the ReactorMeshParams object");
195 mooseError(
"Hexagonal assemblies must have a background region defined");
197 mooseError(
"Hexagonal diameter of assembly must be larger than the number of assembly rows " 198 "times the pin pitch");
201 mooseError(
"The size of background_region_id must be equal to the number of axial levels as " 202 "defined in the ReactorMeshParams object");
206 mooseError(
"If ducts are defined then \"duct_intervals\" and \"duct_region_ids\" must also be " 207 "defined and of equal size.");
213 mooseError(
"The size of duct_region_id must be equal to the number of axial levels as " 214 "defined in the ReactorMeshParams object");
217 "If ducts are defined, then \"duct_intervals\" and \"duct_region_ids\" " 218 "must also be defined and of equal size.");
226 "If ReactorMeshParams/region_id_as_block_name is set, background_block_name " 227 "should not be specified in AssemblyMeshGenerator");
231 mooseError(
"The size of background_block_name must match the size of background_region_id");
240 "If ReactorMeshParams/region_id_as_block_name is set, duct_block_names should not " 241 "be specified in AssemblyMeshGenerator");
243 _duct_block_names = getParam<std::vector<std::vector<std::string>>>(
"duct_block_names");
245 mooseError(
"The size of duct_block_names must match the size of duct_region_ids");
248 mooseError(
"The size of duct_block_names must match the size of duct_region_ids");
264 const auto patterned_mg_name =
265 _geom_type ==
"Hex" ?
"PatternedHexMeshGenerator" :
"PatternedCartesianMeshGenerator";
271 params.set<
MooseEnum>(
"hexagon_size_style") =
"apothem";
276 params.set<
MooseEnum>(
"pattern_boundary") =
"none";
279 params.set<
MooseEnum>(
"pattern_boundary") =
"expanded";
281 params.set<
bool>(
"uniform_mesh_on_sides") =
true;
285 params.set<std::vector<std::string>>(
"id_name") = {
"pin_id"};
286 params.set<std::vector<MooseEnum>>(
"assign_type") = {
288 params.set<std::vector<MeshGeneratorName>>(
"inputs") =
_inputs;
289 params.set<std::vector<std::vector<unsigned int>>>(
"pattern") =
_pattern;
290 params.set<
bool>(
"create_outward_interface_boundaries") =
false;
306 std::vector<subdomain_id_type> duct_block_ids;
312 std::to_string(duct_it + 1);
314 duct_block_ids.push_back(duct_block_id);
318 params.set<std::vector<Real>>(
"duct_sizes") =
_duct_sizes;
319 params.set<std::vector<subdomain_id_type>>(
"duct_block_ids") = duct_block_ids;
320 params.set<std::vector<SubdomainName>>(
"duct_block_names") =
duct_block_names;
321 params.set<std::vector<unsigned int>>(
"duct_intervals") =
_duct_intervals;
330 copyMeshProperty<bool>(
"is_control_drum_meta",
name() +
"_pattern");
331 copyMeshProperty<std::vector<Point>>(
"control_drum_positions",
name() +
"_pattern");
332 copyMeshProperty<std::vector<Real>>(
"control_drum_angles",
name() +
"_pattern");
333 copyMeshProperty<std::vector<std::vector<Real>>>(
"control_drums_azimuthal_meta",
334 name() +
"_pattern");
335 copyMeshProperty<std::string>(
"position_file_name",
name() +
"_pattern");
336 copyMeshProperty<Real>(
"pattern_pitch_meta",
name() +
"_pattern");
339 std::string build_mesh_name =
name() +
"_delbds";
344 std::vector<BoundaryName> boundaries_to_delete = {};
345 for (
const auto & pattern_x :
_pattern)
347 for (
const auto & pattern_idx : pattern_x)
349 const auto pin_name =
_inputs[pattern_idx];
350 const auto pin_id = getMeshProperty<subdomain_id_type>(
RGMB::pin_type, pin_name);
351 const BoundaryName boundary_name =
353 if (!std::count(boundaries_to_delete.begin(), boundaries_to_delete.end(), boundary_name))
354 boundaries_to_delete.push_back(boundary_name);
359 params.
set<MeshGeneratorName>(
"input") =
name() +
"_pattern";
360 params.set<std::vector<BoundaryName>>(
"boundary_names") = boundaries_to_delete;
367 if (use_flexible_stitching)
370 build_mesh_name =
name() +
"_fpg_delbds";
375 std::map<subdomain_id_type, std::vector<std::vector<subdomain_id_type>>> region_id_map =
376 getMeshProperty<std::map<subdomain_id_type, std::vector<std::vector<subdomain_id_type>>>>(
380 region_id_map.begin()->first, region_id_map.begin()->second));
426 std::vector<std::vector<int>> pin_name_lattice;
427 std::vector<std::string> input_pin_names;
430 std::vector<int> pin_name_idx(
_pattern[i].size());
434 const auto it = std::find(input_pin_names.begin(), input_pin_names.end(), input_pin_name);
435 if (it == input_pin_names.end())
437 pin_name_idx[
j] = input_pin_names.size();
438 input_pin_names.push_back(input_pin_name);
441 pin_name_idx[
j] = it - input_pin_names.begin();
443 pin_name_lattice.push_back(pin_name_idx);
454 SubdomainName block_to_delete =
"";
456 mooseError(
"Attempting to use flexible stitching on assembly " +
name() +
457 " that does not have a background region. This is not yet supported.");
460 std::to_string(radial_index);
466 params.
set<std::vector<SubdomainName>>(
"block") = {block_to_delete};
467 params.set<MeshGeneratorName>(
"input") =
name() +
"_delbds";
475 params.
set<std::vector<MeshGeneratorName>>(
"inputs") = {
name() +
"_del_outer"};
476 params.set<std::vector<libMesh::Point>>(
"extra_positions") = {
libMesh::Point(0, 0, 0)};
477 params.set<std::vector<unsigned int>>(
"extra_positions_mg_indices") = {0};
478 params.set<
bool>(
"use_auto_area_func") =
true;
480 params.set<
unsigned int>(
"boundary_sectors") =
485 params.set<SubdomainName>(
"background_subdomain_name") =
487 params.set<
bool>(
"verify_holes") =
false;
496 params.
set<MeshGeneratorName>(
"input") =
name() +
"_fpg";
497 params.set<std::vector<BoundaryName>>(
"boundary_names") = {std::to_string(1)};
503 std::unique_ptr<MeshBase>
514 auto null_mesh =
nullptr;
520 if (hasMeshProperty<Real>(
"pattern_pitch_meta",
name() +
"_pattern"))
522 const auto pattern_pitch_meta =
523 getMeshProperty<Real>(
"pattern_pitch_meta",
name() +
"_pattern");
533 std::string plane_id_name =
"plane_id";
534 std::string region_id_name =
"region_id";
535 std::string pin_type_id_name =
"pin_type_id";
536 std::string assembly_type_id_name =
"assembly_type_id";
537 std::string radial_id_name =
"radial_id";
538 const std::string default_block_name =
547 unsigned int plane_id_int = 0;
553 std::map<std::string, SubdomainID> rgmb_name_id_map;
557 for (
auto & elem : (*_build_mesh)->active_element_ptr_range())
560 const dof_id_type pin_type_id = elem->get_extra_integer(pin_type_id_int);
567 const dof_id_type radial_idx = elem->get_extra_integer(radial_id_int);
569 elem->set_extra_integer(region_id_int, elem_rid);
573 auto elem_block_name = default_block_name;
577 elem_block_name +=
"_REG" + std::to_string(elem_rid);
578 if (elem->type() ==
TRI3 || elem->type() ==
PRISM6)
581 *(*
_build_mesh), elem, rgmb_name_id_map, elem_block_name, next_block_id);
588 const auto base_block_id = elem->subdomain_id();
589 const auto base_block_name = (*_build_mesh)->subdomain_name(base_block_id);
593 if (!(base_block_name.find(prefix, 0) == 0))
596 const unsigned int peripheral_idx = std::stoi(base_block_name.substr(prefix.length()));
598 bool is_background_region = peripheral_idx == 0;
601 elem->set_extra_integer(pin_type_id_int,
pin_type);
605 elem->set_extra_integer(region_id_int, elem_rid);
608 auto elem_block_name = default_block_name;
610 elem_block_name +=
"_REG" + std::to_string(elem_rid);
615 if (elem->type() ==
TRI3 || elem->type() ==
PRISM6)
618 *(*
_build_mesh), elem, rgmb_name_id_map, elem_block_name, next_block_id);
622 if (getParam<bool>(
"generate_depletion_id"))
624 const MooseEnum option = getParam<MooseEnum>(
"depletion_id_type");
629 (*_build_mesh)->set_isnt_prepared();
registerMooseObject("ReactorApp", AssemblyMeshGenerator)
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
static void addDepletionIDParams(InputParameters ¶meters)
const SubdomainName ASSEMBLY_BLOCK_NAME_PREFIX
void generateFlexibleAssemblyBoundaries()
void updateElementBlockNameId(MeshBase &input_mesh, Elem *elem, std::map< std::string, SubdomainID > &name_id_map, std::string elem_block_name, SubdomainID &next_free_id)
Updates the block names and ids of the element in an input mesh according to a map of block name to b...
bool _has_duct_block_names
Whether block names for assembly duct elements have been provided by user.
static const std::string duct_block_names
static const std::string background_region_id
T & setMeshProperty(const std::string &data_name, Args &&... args)
static const std::string assembly_type
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
const subdomain_id_type ASSEMBLY_BLOCK_ID_START
static const std::string region_id_as_block_name
const unsigned int _background_intervals
The number of divisions in the mesh outside of the pins and inside of the ducts.
static const std::string is_single_pin
const subdomain_id_type _assembly_type
The id number for the type of the assembly.
std::unique_ptr< MeshBase > generate() override
const std::vector< Real > _duct_sizes
The inner apothem of any ducts around the assembly.
unsigned int getElemIntegerFromMesh(MeshBase &input_mesh, std::string extra_int_name, bool should_exist=false)
Initializes extra element integer from id name for a given mesh and throws an error if it should exis...
bool _has_background_block_name
Whether block names for assembly background elements have been provided by user.
static const std::string reactor_params_name
static constexpr boundary_id_type ASSEMBLY_BOUNDARY_ID_START
static const std::string mesh_geometry
void initializeReactorMeshParams(const std::string reactor_param_name)
Initializes and checks validity of ReactorMeshParams mesh generator object.
InputParameters getValidParams(const std::string &name) const
std::vector< std::vector< subdomain_id_type > > _duct_region_ids
2-D vector (axial outer indexing, radial inner indexing) used to set the "region_id" extra-element in...
static const std::string background_block_name
std::unique_ptr< MeshBase > * _build_mesh
The final mesh that is generated by the subgenerators; This mesh is generated by the subgenerators wi...
void addDepletionId(MeshBase &input_mesh, const MooseEnum &option, const DepletionIDGenerationLevel generation_level, const bool extrude)
add depletion IDs
static const std::string assembly_pitch
static const std::string pin_type
std::map< subdomain_id_type, std::vector< std::vector< subdomain_id_type > > > _pin_region_id_map
A mapping from pin-type IDs to region IDs used when assigning region IDs during the pin stitching sta...
static InputParameters validParams()
const SubdomainName TRI_BLOCK_NAME_SUFFIX
virtual const std::string & name() const
static InputParameters validParams()
static const std::string pin_region_id_map
const BoundaryName PIN_BOUNDARY_NAME_PREFIX
bool isParamValid(const std::string &name) const
std::vector< subdomain_id_type > _background_region_id
Vector used to set the "region_id" extra-element integer of the assembly background elements...
static const std::string extruded
const T & getReactorParam(const std::string ¶m_name)
Returns reference of parameter in ReactorMeshParams object.
static const std::string duct_halfpitches
static const std::string mesh_dimensions
const subdomain_id_type ASSEMBLY_BLOCK_ID_TRI_FLEXIBLE
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
MeshGeneratorName callExtrusionMeshSubgenerators(const MeshGeneratorName input_mesh_name)
Calls mesh subgenerators related to extrusion, renaming of top / bottom boundaries, and defining plane IDs.
static const std::string pitch
const std::vector< unsigned int > _duct_intervals
The number of divisions in the meshes of the ducts.
static const std::string top_boundary_id
std::vector< std::unique_ptr< MeshBase > *> getMeshes(const std::string ¶m_name)
void paramError(const std::string ¶m, Args... args) const
std::vector< std::vector< std::string > > _duct_block_names
Optional 2-D vector (axial outer indexing, radial inner indexing) used to set the block names of the ...
static const std::string is_homogenized
static const std::string is_control_drum
unsigned int _mesh_dimensions
The number of dimensions the mesh is ultimately going to have (2 or 3, declared in the ReactorMeshPar...
static const std::string pin_region_ids
static const std::string flexible_assembly_stitching
static const std::string pin_lattice
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< std::vector< unsigned int > > _pattern
The 2D pin-by-pin layout of the assembly mapping indices into _inputs.
std::string _geom_type
The type of geometry that is being described (Square or Hex, declared in the ReactorMeshParams object...
static const std::string pin_block_names
AssemblyMeshGenerator(const InputParameters ¶meters)
boundary_id_type _assembly_boundary_id
The ID of the assembly outer boundary, equal to the assembly type ID + 2000.
static const std::string axial_mesh_intervals
const std::vector< MeshGeneratorName > _inputs
The names of the pins that compose the Assembly.
A base class that contains common members for Reactor Geometry Mesh Builder mesh generators.
const BoundaryName ASSEMBLY_BOUNDARY_NAME_PREFIX
void mooseError(Args &&... args) const
void freeReactorMeshParams()
Releases the mesh obtained in _reactor_params_mesh.
T & declareMeshProperty(const std::string &data_name, Args &&... args)
std::vector< std::string > _background_block_name
Optional vector used to set the block names of the assembly background elements.
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
static const std::string bypass_meshgen
static const std::string pin_names
std::map< subdomain_id_type, std::vector< std::vector< std::string > > > _pin_block_name_map
A mapping from pin-type IDs to block names used when assigning block names during the pin stitching s...
void declareMeshesForSub(const std::string ¶m_name)
SubdomainID getNextFreeSubdomainID(MeshBase &input_mesh)
const bool _extrude
Whether this mesh should be extruded to 3-D, making it the final structure in the reactor mesh...
static const std::string num_sectors_flexible_stitching
static const std::string duct_region_ids
BoundaryName _assembly_boundary_name
The name of the assembly outer boundary, equal to the concatenation of "outer_assembly_" and the asse...
void ErrorVector unsigned int
const subdomain_id_type MAX_PIN_TYPE_ID
auto index_range(const T &sizable)
static const std::string bottom_boundary_id
static const std::string pin_block_name_map
Mesh generator for defining a reactor assembly using a Cartesian or hexagonal lattice with the option...