23 "Print out RGMB-related metadata to console output",
24 "This parameter is deprecated. Please use MeshMetaDataReporter "
25 "system to print out mesh metadata to JSON output file instead");
26 params.
addClassDescription(
"A base class that contains common members and methods for Reactor "
27 "Geometry Mesh Builder mesh generators.");
38 "generate_depletion_id",
false,
"Determine wheter the depletion ID is assigned.");
39 MooseEnum depletion_id_option(
"assembly assembly_type pin pin_type");
42 "Determine level of details in depletion ID assignment.");
43 params.
addParamNamesToGroup(
"generate_depletion_id depletion_id_type",
"Depletion ID assignment");
59 mooseError(
"The reactor_params mesh is not of the correct type");
61 if (!hasMeshProperty<unsigned int>(
"mesh_dimensions",
_reactor_params) ||
63 mooseError(
"The reactor_params input must be a ReactorMeshParams type MeshGenerator\n Please "
64 "check that a valid definition and name of ReactorMeshParams has been provided.");
88 std::string extra_int_name,
91 if (input_mesh.has_elem_integer(extra_int_name))
92 return input_mesh.get_elem_integer_index(extra_int_name);
96 mooseError(
"Expected extruded mesh to have " + extra_int_name +
" extra integers");
98 return input_mesh.add_elem_integer(extra_int_name);
104 MeshBase & input_mesh,
106 std::map<std::string, SubdomainID> & name_id_map,
107 std::string elem_block_name,
111 if (name_id_map.find(elem_block_name) == name_id_map.end())
114 elem_block_id = next_free_id++;
115 elem->subdomain_id() = elem_block_id;
116 input_mesh.set_subdomain_name(elem_block_id, elem_block_name);
117 name_id_map[elem_block_name] = elem_block_id;
122 elem_block_id = name_id_map[elem_block_name];
123 elem->subdomain_id() = elem_block_id;
126 input_mesh.unset_has_cached_elem_data();
136 std::vector<ExtraElementIDName> id_names = {};
138 id_names.push_back(
"plane_id");
142 id_names.insert(id_names.end(), {
"assembly_id",
"pin_id"});
143 else if (option ==
"pin_type")
144 id_names.insert(id_names.end(), {
"assembly_id",
"pin_type_id"});
145 else if (option ==
"assembly")
146 id_names.push_back(
"assembly_id");
147 else if (option ==
"assembly_type")
148 id_names.push_back(
"assembly_type_id");
153 id_names.push_back(
"pin_id");
154 else if (option ==
"pin_type")
155 id_names.push_back(
"pin_type_id");
158 "'assembly_id' or 'assembly_type_id' is not allowed in depletion ID generation at "
163 if (option ==
"pin_type")
164 id_names.push_back(
"pin_type_id");
167 "Only 'pin_type' is allowed in depletion ID generation at "
171 mooseError(
"Depletion ID generation is not supported at pin level yet in RGMB");
172 id_names.push_back(
"region_id");
174 std::set<SubdomainID> block_ids = {};
178 std::unordered_map<dof_id_type, dof_id_type> depl_ids =
181 const auto depl_id_index = input_mesh.add_elem_integer(
"depletion_id");
182 for (Elem *
const elem : input_mesh.active_element_ptr_range())
183 elem->set_extra_integer(depl_id_index, depl_ids.at(elem->id()));
188 const MeshGeneratorName input_mesh_name)
197 params.
set<MeshGeneratorName>(
"input") = input_mesh_name;
198 params.set<Point>(
"direction") = Point(0, 0, 1);
199 params.set<std::vector<unsigned int>>(
"num_layers") =
201 params.set<std::vector<Real>>(
"heights") = axial_boundaries;
202 params.set<BoundaryName>(
"bottom_boundary") = std::to_string(bottom_boundary);
203 params.set<BoundaryName>(
"top_boundary") = std::to_string(top_boundary);
210 params.
set<MeshGeneratorName>(
"input") =
name() +
"_extruded";
211 params.set<std::vector<BoundaryName>>(
"old_boundary") = {
212 std::to_string(top_boundary),
213 std::to_string(bottom_boundary)};
214 params.set<std::vector<BoundaryName>>(
"new_boundary") = {
"top",
"bottom"};
218 const MeshGeneratorName output_mesh_name =
name() +
"_extrudedIDs";
222 params.
set<MeshGeneratorName>(
"input") =
name() +
"_change_plane_name";
224 std::vector<Real> plane_heights{0};
225 for (Real z : axial_boundaries)
226 plane_heights.push_back(z + plane_heights.back());
228 params.set<std::vector<Real>>(
"plane_coordinates") = plane_heights;
230 std::string plane_id_name =
"plane_id";
231 params.set<std::string>(
"id_name") =
"plane_id";
236 return output_mesh_name;
239std::vector<std::reference_wrapper<const CSG::CSGSurface>>
244 std::vector<std::reference_wrapper<const CSG::CSGSurface>> duct_surfaces;
246 const auto n_azim_surfaces = mesh_geometry ==
"Square" ? 4 : 6;
249 const Real angle_offset_degrees = mesh_geometry ==
"Square" ? 45. : 30.;
250 const Real angle_offset_radians = angle_offset_degrees * (M_PI / 180.);
251 const auto radius = halfpitch / std::cos(angle_offset_radians);
253 Real angle_increment_radians = 360. / n_azim_surfaces * (M_PI / 180.);
255 for (
const auto i : make_range(n_azim_surfaces))
257 const auto surf_name =
258 name() +
"_radial_duct_" + std::to_string(radial_index) +
"_surf_" + std::to_string(i);
261 const auto current_angle = i * angle_increment_radians + angle_offset_radians;
262 const auto next_angle = (i + 1) * angle_increment_radians + angle_offset_radians;
267 p2(2) = angle_offset_degrees;
269 std::unique_ptr<CSG::CSGSurface> duct_surf_ptr =
270 std::make_unique<CSG::CSGPlane>(surf_name, p0, p1, p2);
271 const auto & duct_surf = csg_obj.
addSurface(std::move(duct_surf_ptr));
272 duct_surfaces.push_back(duct_surf);
275 return duct_surfaces;
278std::vector<std::reference_wrapper<const CSG::CSGSurface>>
281 std::vector<std::reference_wrapper<const CSG::CSGSurface>> surfaces_by_axial_region;
283 Real axial_level = 0.;
288 const auto has_axial_surfaces = csg_obj.
hasSurface(axial_surf_name);
290 for (
const auto i : make_range(axial_boundaries.size() + 1))
293 if (has_axial_surfaces)
295 surfaces_by_axial_region.push_back(csg_obj.
getSurfaceByName(axial_surf_name));
299 axial_level += (i != 0) ? axial_boundaries[i - 1] : 0.;
300 std::unique_ptr<CSG::CSGSurface> plane_surf_ptr =
301 std::make_unique<CSG::CSGPlane>(axial_surf_name, 0, 0, 1, axial_level);
302 const auto & plane_surf = csg_obj.
addSurface(std::move(plane_surf_ptr));
303 surfaces_by_axial_region.push_back(plane_surf);
307 return surfaces_by_axial_region;
313 const std::vector<std::vector<std::reference_wrapper<const CSG::CSGUniverse>>> pattern,
317 std::string lat_name =
name() +
"_lattice";
318 std::unique_ptr<CSG::CSGLattice> lat_ptr;
320 if (mesh_geometry ==
"Square")
321 lat_ptr = std::make_unique<CSG::CSGCartesianLattice>(lat_name, pitch, pattern);
323 lat_ptr = std::make_unique<CSG::CSGHexagonalLattice>(lat_name, pitch, pattern);
325 auto & assembly_lattice = csg_obj.
addLattice(std::move(lat_ptr));
326 return assembly_lattice;
const CSGSurface & getSurfaceByName(const std::string &name) const
const CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
const LatticeType & addLattice(std::unique_ptr< LatticeType > lattice)
bool hasSurface(const std::string &name) const
InputParameters getValidParams(const std::string &name) const
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
static InputParameters validParams()
std::unique_ptr< CSG::CSGBase > & getCSGBaseByName(const MeshGeneratorName &mesh_generator_name)
static void setHasGenerateData(InputParameters ¶ms)
T & declareMeshProperty(const std::string &data_name, Args &&... args)
MeshGeneratorSystem & getMeshGeneratorSystem()
const std::string & name() const
void paramError(const std::string ¶m, Args... args) const
void mooseError(Args &&... args) const
std::unique_ptr< MeshBase > * _reactor_params_mesh
The dummy param mesh that we need to clear once we've generated (in freeReactorMeshParams)
const T & getReactorParam(const std::string ¶m_name)
Returns reference of parameter in ReactorMeshParams object.
MeshGeneratorName _reactor_params
The ReactorMeshParams object that is storing the reactor global information for this reactor geometry...
void initializeReactorMeshParams(const std::string reactor_param_name)
Initializes and checks validity of ReactorMeshParams mesh generator object.
std::vector< std::reference_wrapper< const CSG::CSGSurface > > getAxialPlaneSurfaces(CSG::CSGBase &csg_obj)
Get CSGSurfaces corresponding to axial planes of the extruded RGMB mesh.
static void addDepletionIDParams(InputParameters ¶meters)
MeshGeneratorName callExtrusionMeshSubgenerators(const MeshGeneratorName input_mesh_name)
Calls mesh subgenerators related to extrusion, renaming of top / bottom boundaries,...
void freeReactorParamsMesh()
Releases the mesh obtained in _reactor_params_mesh.
std::vector< std::reference_wrapper< const CSG::CSGSurface > > getOuterRadialSurfacesForUnitCell(unsigned int radial_index, Real halfpitch, CSG::CSGBase &csg_obj)
Get CSGSurfaces corresponding to hexagonal or square region with given halfpitch and centered around ...
static InputParameters validParams()
DepletionIDGenerationLevel
specify the depletion id is generated at which reactor generation level
std::unique_ptr< CSG::CSGBase > * _reactor_params_csg
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...
void addDepletionId(MeshBase &input_mesh, const MooseEnum &option, const DepletionIDGenerationLevel generation_level, const bool extrude)
add depletion IDs
const CSG::CSGLattice & createRGMBLattice(const Real pitch, const std::vector< std::vector< std::reference_wrapper< const CSG::CSGUniverse > > > pattern, CSG::CSGBase &csg_obj)
Create CSG lattice for assembly and core lattices.
void freeReactorParamsCSG()
Releases the CSG base object obtained in _reactor_params_csg.
ReactorGeometryMeshBuilderBase(const InputParameters ¶meters)
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...
std::unordered_map< dof_id_type, dof_id_type > getExtraIDUniqueCombinationMap(const MeshBase &mesh, const std::set< SubdomainID > &block_ids, std::vector< ExtraElementIDName > extra_ids)
static const std::string bottom_boundary_id
static const std::string top_boundary_id
static const std::string axial_mesh_sizes
static const std::string CSG_AXIAL_PLANE_PREFIX
static const std::string axial_mesh_intervals
static const std::string mesh_geometry