Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #pragma once 11 : 12 : #include "MeshGenerator.h" 13 : #include "libmesh/elem.h" 14 : 15 : namespace RGMB 16 : { 17 : 18 : // General global quantities for mesh building 19 : static const std::string mesh_dimensions = "mesh_dimensions"; 20 : static const std::string mesh_geometry = "mesh_geometry"; 21 : static const std::string top_boundary_id = "top_boundary_id"; 22 : static const std::string bottom_boundary_id = "bottom_boundary_id"; 23 : static const std::string radial_boundary_id = "radial_boundary_id"; 24 : static const std::string axial_mesh_intervals = "axial_mesh_intervals"; 25 : static const std::string axial_mesh_sizes = "axial_mesh_sizes"; 26 : static const std::string reactor_params_name = "reactor_params_name"; 27 : static const std::string is_single_pin = "is_single_pin"; 28 : static const std::string is_homogenized = "is_homogenized"; 29 : static const std::string extruded = "extruded"; 30 : static const std::string pin_region_ids = "pin_region_ids"; 31 : static const std::string pin_block_names = "pin_block_names"; 32 : static const std::string pin_region_id_map = "pin_region_id_map"; 33 : static const std::string pin_block_name_map = "pin_block_name_map"; 34 : static const std::string flexible_assembly_stitching = "flexible_assembly_stitching"; 35 : static const std::string num_sectors_flexible_stitching = "num_sectors_flexible_stitching"; 36 : static const std::string is_control_drum = "is_control_drum"; 37 : static const std::string drum_region_ids = "drum_region_ids"; 38 : static const std::string drum_block_names = "drum_block_names"; 39 : 40 : // Geometrical quantities 41 : static const std::string pitch = "pitch"; 42 : static const std::string assembly_pitch = "assembly_pitch"; 43 : static const std::string ring_radii = "ring_radii"; 44 : static const std::string duct_halfpitches = "duct_halfpitches"; 45 : static const std::string peripheral_ring_radius = "peripheral_ring_radius"; 46 : static const std::string pin_lattice = "pin_lattice"; 47 : static const std::string assembly_lattice = "assembly_lattice"; 48 : static const std::string drum_pad_angles = "drum_pad_angles"; 49 : static const std::string drum_radii = "drum_radii"; 50 : 51 : // Quantities related to region ids, type ids, and block names 52 : static const std::string pin_type = "pin_type"; 53 : static const std::string pin_names = "pin_names"; 54 : static const std::string assembly_type = "assembly_type"; 55 : static const std::string assembly_names = "assembly_names"; 56 : static const std::string ring_region_ids = "ring_region_ids"; 57 : static const std::string background_region_id = "background_region_id"; 58 : static const std::string background_block_name = "background_block_name"; 59 : static const std::string duct_region_ids = "duct_region_ids"; 60 : static const std::string duct_block_names = "duct_block_names"; 61 : static const std::string peripheral_ring_region_id = "peripheral_ring_region_id"; 62 : static const std::string region_id_as_block_name = "region_id_as_block_name"; 63 : 64 : // Name of a boolean metadata that indicates whether or not we skipped mesh generation in favor of 65 : // only generating the mesh metadata 66 : static const std::string bypass_meshgen = "bypass_meshgen"; 67 : 68 : // Default values for setting block IDs and region IDs of RGMB regions 69 : const subdomain_id_type PIN_BLOCK_ID_TRI_FLEXIBLE = 9998; 70 : const subdomain_id_type PIN_BLOCK_ID_TRI = 9999; 71 : const subdomain_id_type PIN_BLOCK_ID_START = 10000; 72 : 73 : const subdomain_id_type CONTROL_DRUM_BLOCK_ID_INNER_TRI = 19995; 74 : const subdomain_id_type CONTROL_DRUM_BLOCK_ID_INNER = 19996; 75 : const subdomain_id_type CONTROL_DRUM_BLOCK_ID_PAD = 19997; 76 : const subdomain_id_type CONTROL_DRUM_BLOCK_ID_OUTER = 19998; 77 : 78 : const subdomain_id_type ASSEMBLY_BLOCK_ID_TRI_FLEXIBLE = 19999; 79 : const subdomain_id_type ASSEMBLY_BLOCK_ID_START = 20000; 80 : 81 : const subdomain_id_type DUMMY_ASSEMBLY_BLOCK_ID = (UINT16_MAX / 2) - 1; 82 : const subdomain_id_type PERIPHERAL_RING_BLOCK_ID = 25000; 83 : 84 : const subdomain_id_type MAX_PIN_TYPE_ID = (UINT16_MAX / 2) - 1; 85 : 86 : // Default values for setting block names of RGMB regions 87 : const SubdomainName PIN_BLOCK_NAME_PREFIX = "RGMB_PIN"; 88 : const SubdomainName ASSEMBLY_BLOCK_NAME_PREFIX = "RGMB_ASSEMBLY"; 89 : const SubdomainName DRUM_BLOCK_NAME_PREFIX = "RGMB_DRUM"; 90 : const SubdomainName CORE_BLOCK_NAME_PREFIX = "RGMB_CORE"; 91 : const SubdomainName TRI_BLOCK_NAME_SUFFIX = "_TRI"; 92 : const SubdomainName PERIPHERAL_RING_BLOCK_NAME = "PERIPHERY_GENERATED"; 93 : 94 : // Default values for setting boundary ids of RGMB regions 95 : static constexpr boundary_id_type PIN_BOUNDARY_ID_START = 20000; 96 : static constexpr boundary_id_type ASSEMBLY_BOUNDARY_ID_START = 2000; 97 : 98 : // Default values for setting boundary names of RGMB regions 99 : const BoundaryName PIN_BOUNDARY_NAME_PREFIX = "outer_pin_"; 100 : const BoundaryName ASSEMBLY_BOUNDARY_NAME_PREFIX = "outer_assembly_"; 101 : const BoundaryName CORE_BOUNDARY_NAME = "outer_core"; 102 : 103 : // Default values for setting names of CSG surfaces 104 : static const std::string CSG_AXIAL_PLANE_PREFIX = "rgmb_axial_plane_"; 105 : } 106 : 107 : /** 108 : * A base class that contains common members for Reactor Geometry Mesh Builder mesh generators. 109 : */ 110 : class ReactorGeometryMeshBuilderBase : public MeshGenerator 111 : { 112 : public: 113 : static InputParameters validParams(); 114 : 115 : static void addDepletionIDParams(InputParameters & parameters); 116 : 117 : ReactorGeometryMeshBuilderBase(const InputParameters & parameters); 118 : 119 1574 : void generateData() override{}; 120 : 121 : protected: 122 : /** 123 : * Initializes extra element integer from id name for a given mesh and throws an error 124 : * if it should exist but cannot be found within the mesh 125 : * @param input_mesh input mesh 126 : * @param extra_int_name extra element id name 127 : * @param should_exist whether extra element integer should already exist in mesh 128 : * @return extra element integer 129 : */ 130 : unsigned int getElemIntegerFromMesh(MeshBase & input_mesh, 131 : std::string extra_int_name, 132 : bool should_exist = false); 133 : 134 : /** 135 : * Initializes and checks validity of ReactorMeshParams mesh generator object 136 : * @param reactor_param_name name of ReactorMeshParams mesh generator 137 : */ 138 : void initializeReactorMeshParams(const std::string reactor_param_name); 139 : 140 : /** 141 : * Print metadata associated with ReactorGeometryMeshBuilder object 142 : * @param geometry_type type of geometry (pin / assembly / core) under consideration 143 : * @param mg_name name of mesh generator associated with this object 144 : * @param first_function_call whether this is the original function call, which will trigger 145 : * additional output messages 146 : */ 147 : void printReactorMetadata(const std::string geometry_type, 148 : const std::string mg_name, 149 : const bool first_function_call = true); 150 : 151 : /** 152 : * Print core-level metadata associated with ReactorGeometryMeshBuilder object 153 : * @param mg_name name of mesh generator associated with core 154 : * @param first_function_call whether this is the original function call, which will trigger 155 : * additional output messages 156 : */ 157 : void printCoreMetadata(const std::string mg_name, const bool first_function_call); 158 : 159 : /** 160 : * Print assembly-level metadata associated with ReactorGeometryMeshBuilder object 161 : * @param mg_name name of mesh generator associated with assembly 162 : * @param whether this is the original function call, which will trigger additional output 163 : * messages 164 : */ 165 : void printAssemblyMetadata(const std::string mg_name, const bool first_function_call); 166 : 167 : /** 168 : * Print pin-level metadata associated with ReactorGeometryMeshBuilder object 169 : * @param mg_name name of mesh generator associated with assembly 170 : */ 171 : void printPinMetadata(const std::string mg_name); 172 : 173 : /** 174 : * Print global ReactorMeshParams metadata associated with ReactorGeometryMeshBuilder object 175 : */ 176 : void printGlobalReactorMetadata(); 177 : 178 : /** 179 : * Print metadata with provided name that can be found with given mesh generator name 180 : * @tparam T datatype of metadata value to output 181 : * @param metadata_name Name of metadata to output 182 : * @param mg_name Name of mesh generator that stores metadata 183 : */ 184 : template <typename T> 185 : void printMetadataToConsole(const std::string metadata_name, const std::string mg_name); 186 : 187 : /** 188 : * Print metadata with data type std::vector<std::vector<T>> and provided name that can be found 189 : * with given mesh generator name 190 : * @tparam T datatype of elements in 2-D vector to output 191 : * @param metadata_name Name of metadata to output 192 : * @param mg_name Name of mesh generator that stores metadata 193 : */ 194 : template <typename T> 195 : void print2dMetadataToConsole(const std::string metadata_name, const std::string mg_name); 196 : 197 : /** 198 : * Releases the mesh obtained in _reactor_params_mesh. 199 : * 200 : * This _must_ be called in any object that derives from this one, because 201 : * the MeshGenerator system requires that all meshes that are requested from 202 : * the system are moved out of the MeshGenerator system and into the MeshGenerator 203 : * that requests them. In our case, we move it into this MeshGenerator and then 204 : * release (delete) it. 205 : */ 206 : void freeReactorParamsMesh(); 207 : 208 : /** 209 : * Releases the CSG base object obtained in _reactor_params_csg. 210 : * 211 : * This _must_ be called in any object that derives from this one, because 212 : * the MeshGenerator system requires that all meshes that are requested from 213 : * the system are moved out of the MeshGenerator system and into the MeshGenerator 214 : * that requests them. In our case, we move it into this MeshGenerator and then 215 : * release (delete) it. 216 : */ 217 : void freeReactorParamsCSG(); 218 : 219 : /** 220 : * Checks whether parameter is defined in ReactorMeshParams metadata 221 : * @tparam T datatype of metadata value associated with metadata name 222 : * @param param_name name of ReactorMeshParams parameter 223 : * @return whether parameter is defined in ReactorMeshParams metadata 224 : */ 225 : template <typename T> 226 : bool hasReactorParam(const std::string param_name); 227 : 228 : /** 229 : * Returns reference of parameter in ReactorMeshParams object 230 : * @tparam T datatype of metadata value associated with metadata name 231 : * @param param_name name of ReactorMeshParams parameter 232 : * @return reference to parameter defined in ReactorMeshParams metadata 233 : */ 234 : template <typename T> 235 : const T & getReactorParam(const std::string & param_name); 236 : 237 : /** 238 : * Updates the block names and ids of the element in an input mesh according 239 : * to a map of block name to block ids. Updates the map if the block name is not in the map 240 : * @param input_name input mesh 241 : * @param elem iterator to mesh element 242 : * @param name_id_map map of name-id pairs used in mesh 243 : * @param elem_block_name block name to set for element 244 : * @param next_free_id next free block id to use if block name does not exist in map 245 : */ 246 : void updateElementBlockNameId(MeshBase & input_mesh, 247 : Elem * elem, 248 : std::map<std::string, SubdomainID> & name_id_map, 249 : std::string elem_block_name, 250 : SubdomainID & next_free_id); 251 : 252 : /** 253 : * Calls mesh subgenerators related to extrusion, renaming of top / bottom boundaries, and 254 : * defining plane IDs 255 : * @param input_mesh_name name of input 2D mesh generator to extrude 256 : * @return name of final output 3D mesh generator 257 : */ 258 : MeshGeneratorName callExtrusionMeshSubgenerators(const MeshGeneratorName input_mesh_name); 259 : 260 : ///The ReactorMeshParams object that is storing the reactor global information for this reactor geometry mesh 261 : MeshGeneratorName _reactor_params; 262 : /// specify the depletion id is generated at which reactor generation level 263 : enum class DepletionIDGenerationLevel 264 : { 265 : Pin, 266 : Assembly, 267 : Drum, 268 : Core 269 : }; 270 : 271 : /** 272 : * add depletion IDs 273 : * @param input_mesh input mesh 274 : * @param option option for specifying level of details 275 : * @param generation_level depletion id is generated at which reactor generator level 276 : * @param extrude whether input mesh is extruded, if false, assume that input mesh is defined in 277 : * 2D and do not use 'plane_id` in depletion id generation 278 : */ 279 : void addDepletionId(MeshBase & input_mesh, 280 : const MooseEnum & option, 281 : const DepletionIDGenerationLevel generation_level, 282 : const bool extrude); 283 : 284 : /** 285 : * Get CSGSurfaces corresponding to hexagonal or square region with given halfpitch and centered 286 : * around (0, 0, 0) 287 : * @param radial_index Radial index of hex / square region, for surface naming 288 : * @param halfpitch Halfpitch of square or hexagon 289 : * @param csg_obj Reference to CSGBase object for adding defined surfaces to 290 : * @return vector of surfaces that correspond to hexagonal or square region 291 : */ 292 : std::vector<std::reference_wrapper<const CSG::CSGSurface>> getOuterRadialSurfacesForUnitCell( 293 : unsigned int radial_index, Real halfpitch, CSG::CSGBase & csg_obj); 294 : 295 : /** 296 : * Get CSGSurfaces corresponding to axial planes of the extruded RGMB mesh 297 : * @param csg_obj Reference to CSGBase object for adding defined surfaces to 298 : * @return vector of surfaces that correspond to axial planes of extruded RGMB mesh 299 : */ 300 : std::vector<std::reference_wrapper<const CSG::CSGSurface>> 301 : getAxialPlaneSurfaces(CSG::CSGBase & csg_obj); 302 : 303 : private: 304 : /// The dummy param mesh that we need to clear once we've generated (in freeReactorMeshParams) 305 : std::unique_ptr<MeshBase> * _reactor_params_mesh; 306 : std::unique_ptr<CSG::CSGBase> * _reactor_params_csg; 307 : }; 308 : 309 : template <typename T> 310 : bool 311 : ReactorGeometryMeshBuilderBase::hasReactorParam(const std::string param_name) 312 : { 313 726 : return hasMeshProperty<T>(param_name, _reactor_params); 314 : } 315 : 316 : template <typename T> 317 : const T & 318 : ReactorGeometryMeshBuilderBase::getReactorParam(const std::string & param_name) 319 : { 320 500400 : return getMeshProperty<T>(param_name, _reactor_params); 321 : }