LCOV - code coverage report
Current view: top level - src/meshgenerators - ReactorMeshParams.C (source / functions) Hit Total Coverage
Test: idaholab/moose reactor: #31782 (60f35e) with base ee0740 Lines: 64 69 92.8 %
Date: 2025-10-31 18:31:38 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          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             : #include "ReactorMeshParams.h"
      11             : #include "CastUniquePointer.h"
      12             : #include "ReactorGeometryMeshBuilderBase.h"
      13             : 
      14             : // libMesh includes
      15             : #include "libmesh/mesh_generation.h"
      16             : #include "libmesh/unstructured_mesh.h"
      17             : #include "libmesh/replicated_mesh.h"
      18             : #include "libmesh/point.h"
      19             : #include "libmesh/elem.h"
      20             : #include "libmesh/node.h"
      21             : 
      22             : registerMooseObject("ReactorApp", ReactorMeshParams);
      23             : 
      24             : InputParameters
      25        1186 : ReactorMeshParams::validParams()
      26             : {
      27        1186 :   InputParameters params = MeshGenerator::validParams();
      28        2372 :   MooseEnum dims("2=2 3", "2");
      29        2372 :   params.addRequiredParam<MooseEnum>("dim", dims, "The dimension of the mesh to be generated");
      30             : 
      31        2372 :   MooseEnum geoms("Square Hex", "Square");
      32        2372 :   params.addRequiredParam<MooseEnum>("geom", geoms, "The geometry type of the reactor mesh");
      33             : 
      34        2372 :   params.addRequiredParam<Real>("assembly_pitch", "Center to center distance of assemblies");
      35        2372 :   params.addParam<boundary_id_type>("top_boundary_id",
      36             :                                     "The boundary ID to set on top boundary of the extruded mesh");
      37        2372 :   params.addParam<boundary_id_type>(
      38             :       "bottom_boundary_id", "The boundary ID to set on bottom boundary of the extruded mesh");
      39        2372 :   params.addParam<boundary_id_type>(
      40             :       "radial_boundary_id",
      41             :       "The boundary ID to set on the outer radial boundary of a CoreMeshGenerator object");
      42        2372 :   params.addParam<std::vector<Real>>("axial_regions", "Length of each axial region");
      43        2372 :   params.addParam<std::vector<unsigned int>>(
      44             :       "axial_mesh_intervals",
      45             :       "Number of elements in the Z direction for each axial region");
      46        2372 :   params.addParam<bool>("region_id_as_block_name", false, "Set block names based on region id");
      47        2372 :   params.addParam<bool>(
      48             :       "flexible_assembly_stitching",
      49        2372 :       false,
      50             :       "Use FlexiblePatternGenerator for stitching dissimilar assemblies together");
      51        3558 :   params.addRangeCheckedParam<unsigned int>(
      52             :       "num_sectors_at_flexible_boundary",
      53        2372 :       6,
      54             :       "num_sectors_at_flexible_boundary>2",
      55             :       "Number of sectors to use at assembly boundary interface when flexible patterning is used "
      56             :       "(Defaults to 6)");
      57        1186 :   params.addClassDescription("This ReactorMeshParams object acts as storage for persistent "
      58             :                              "information about the reactor geometry.");
      59             : 
      60             :   // Declare that this generator has a generateData method
      61        1186 :   MeshGenerator::setHasGenerateData(params);
      62             :   // Declare that this generator has a generateCSG method
      63        1186 :   MeshGenerator::setHasGenerateCSG(params);
      64        1186 :   return params;
      65        1186 : }
      66             : 
      67         593 : ReactorMeshParams::ReactorMeshParams(const InputParameters & parameters)
      68             :   : MeshGenerator(parameters),
      69         593 :     _dim(getParam<MooseEnum>("dim")),
      70        1186 :     _geom(getParam<MooseEnum>("geom")),
      71        1779 :     _assembly_pitch(getParam<Real>("assembly_pitch"))
      72             : {
      73         593 :   if ((unsigned int)(_dim) == 2)
      74             :   {
      75             :     std::vector<std::string> invalid_params = {
      76         258 :         "axial_regions", "axial_mesh_intervals", "top_boundary_id", "bottom_boundary_id"};
      77        1284 :     for (const auto & param : invalid_params)
      78        1028 :       if (isParamValid(param))
      79           2 :         paramError(param, param + " should not be defined for 2-D meshes");
      80         256 :   }
      81             :   else
      82             :   {
      83         670 :     _axial_regions = getParam<std::vector<Real>>("axial_regions");
      84        1005 :     _axial_mesh_intervals = getParam<std::vector<unsigned int>>("axial_mesh_intervals");
      85             : 
      86         335 :     if (_axial_regions.size() != _axial_mesh_intervals.size())
      87           0 :       mooseError(
      88             :           "The number of axial regions is not consistent with the number of axial intervals.");
      89             :     this->declareMeshProperty(RGMB::axial_mesh_sizes, _axial_regions);
      90             :     this->declareMeshProperty(RGMB::axial_mesh_intervals, _axial_mesh_intervals);
      91             :   }
      92             : 
      93        1182 :   this->declareMeshProperty(RGMB::mesh_dimensions, (unsigned int)std::stoul(_dim));
      94         591 :   this->declareMeshProperty(RGMB::mesh_geometry, std::string(_geom));
      95         591 :   this->declareMeshProperty(RGMB::assembly_pitch, _assembly_pitch);
      96             :   this->declareMeshProperty(RGMB::region_id_as_block_name,
      97             :                             getParam<bool>(RGMB::region_id_as_block_name));
      98             : 
      99         591 :   const bool flexible_assembly_stitching = getParam<bool>(RGMB::flexible_assembly_stitching);
     100             :   this->declareMeshProperty(RGMB::flexible_assembly_stitching, flexible_assembly_stitching);
     101         591 :   if (flexible_assembly_stitching)
     102         250 :     this->declareMeshProperty(RGMB::num_sectors_flexible_stitching,
     103             :                               getParam<unsigned int>("num_sectors_at_flexible_boundary"));
     104        1182 :   if (parameters.isParamSetByUser("num_sectors_at_flexible_boundary") &&
     105             :       !flexible_assembly_stitching)
     106           0 :     paramWarning(
     107             :         "num_sectors_at_flexible_boundary",
     108             :         "This parameter is only relevant when ReactorMeshParams/flexible_assembly_stitching is set "
     109             :         "to true. This value will be ignored");
     110             : 
     111             :   // Option to bypass mesh generation depends on whether the current generator is in data only mode
     112         591 :   bool bypass_meshgen = isDataOnly();
     113             :   this->declareMeshProperty(RGMB::bypass_meshgen, bypass_meshgen);
     114             : 
     115        1182 :   if (isParamValid("top_boundary_id"))
     116             :   {
     117         666 :     _top_boundary = getParam<boundary_id_type>("top_boundary_id");
     118         333 :     this->declareMeshProperty(RGMB::top_boundary_id, _top_boundary);
     119             :   }
     120        1182 :   if (isParamValid("bottom_boundary_id"))
     121             :   {
     122         666 :     _bottom_boundary = getParam<boundary_id_type>("bottom_boundary_id");
     123         333 :     this->declareMeshProperty(RGMB::bottom_boundary_id, _bottom_boundary);
     124             :   }
     125        1182 :   if (isParamValid("radial_boundary_id"))
     126             :   {
     127         692 :     _radial_boundary = getParam<boundary_id_type>("radial_boundary_id");
     128         346 :     this->declareMeshProperty(RGMB::radial_boundary_id, _radial_boundary);
     129        1038 :     if (isParamValid("top_boundary_id") && _radial_boundary == _top_boundary)
     130           0 :       mooseError("top_boundary_id and radial_boundary_id must be unique values");
     131        1038 :     if (isParamValid("bottom_boundary_id") && _radial_boundary == _bottom_boundary)
     132           0 :       mooseError("bottom_boundary_id and radial_boundary_id must be unique values");
     133             :   }
     134        2181 :   if (isParamValid("top_boundary_id") && isParamValid("bottom_boundary_id") &&
     135         333 :       (_bottom_boundary == _top_boundary))
     136           0 :     mooseError("top_boundary_id and bottom_boundary_id must be unique values");
     137         591 : }
     138             : 
     139             : std::unique_ptr<MeshBase>
     140         451 : ReactorMeshParams::generate()
     141             : {
     142             :   // If mesh generation is requested and bypass_mesh is true, return a null mesh. generate()
     143             :   // mesh should not be called with this option specified
     144         451 :   if (getMeshProperty<bool>(RGMB::bypass_meshgen))
     145             :   {
     146             :     auto null_mesh = nullptr;
     147             :     return null_mesh;
     148             :   }
     149         451 :   auto mesh = buildMeshBaseObject();
     150         451 :   return dynamic_pointer_cast<MeshBase>(mesh);
     151         451 : }
     152             : 
     153             : std::unique_ptr<CSG::CSGBase>
     154          45 : ReactorMeshParams::generateCSG()
     155             : {
     156             :   // This MeshGenerator does not produce a mesh, therefore return an empty CSGBase object
     157          45 :   return std::make_unique<CSG::CSGBase>();
     158             : }

Generated by: LCOV version 1.14