LCOV - code coverage report
Current view: top level - src/meshgenerators - ReactorMeshParams.C (source / functions) Hit Total Coverage
Test: idaholab/moose reactor: #31405 (292dce) with base fef103 Lines: 63 68 92.6 %
Date: 2025-09-04 07:56:24 Functions: 3 3 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        1096 : ReactorMeshParams::validParams()
      26             : {
      27        1096 :   InputParameters params = MeshGenerator::validParams();
      28        2192 :   MooseEnum dims("2=2 3", "2");
      29        2192 :   params.addRequiredParam<MooseEnum>("dim", dims, "The dimension of the mesh to be generated");
      30             : 
      31        2192 :   MooseEnum geoms("Square Hex", "Square");
      32        2192 :   params.addRequiredParam<MooseEnum>("geom", geoms, "The geometry type of the reactor mesh");
      33             : 
      34        2192 :   params.addRequiredParam<Real>("assembly_pitch", "Center to center distance of assemblies");
      35        2192 :   params.addParam<boundary_id_type>("top_boundary_id",
      36             :                                     "The boundary ID to set on top boundary of the extruded mesh");
      37        2192 :   params.addParam<boundary_id_type>(
      38             :       "bottom_boundary_id", "The boundary ID to set on bottom boundary of the extruded mesh");
      39        2192 :   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        2192 :   params.addParam<std::vector<Real>>("axial_regions", "Length of each axial region");
      43        2192 :   params.addParam<std::vector<unsigned int>>(
      44             :       "axial_mesh_intervals",
      45             :       "Number of elements in the Z direction for each axial region");
      46        2192 :   params.addParam<bool>("region_id_as_block_name", false, "Set block names based on region id");
      47        2192 :   params.addParam<bool>(
      48             :       "flexible_assembly_stitching",
      49        2192 :       false,
      50             :       "Use FlexiblePatternGenerator for stitching dissimilar assemblies together");
      51        3288 :   params.addRangeCheckedParam<unsigned int>(
      52             :       "num_sectors_at_flexible_boundary",
      53        2192 :       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        1096 :   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        1096 :   MeshGenerator::setHasGenerateData(params);
      62        1096 :   return params;
      63        1096 : }
      64             : 
      65         548 : ReactorMeshParams::ReactorMeshParams(const InputParameters & parameters)
      66             :   : MeshGenerator(parameters),
      67         548 :     _dim(getParam<MooseEnum>("dim")),
      68        1096 :     _geom(getParam<MooseEnum>("geom")),
      69        1644 :     _assembly_pitch(getParam<Real>("assembly_pitch"))
      70             : {
      71         548 :   if ((unsigned int)(_dim) == 2)
      72             :   {
      73             :     std::vector<std::string> invalid_params = {
      74         233 :         "axial_regions", "axial_mesh_intervals", "top_boundary_id", "bottom_boundary_id"};
      75        1159 :     for (const auto & param : invalid_params)
      76         928 :       if (isParamValid(param))
      77           2 :         paramError(param, param + " should not be defined for 2-D meshes");
      78         231 :   }
      79             :   else
      80             :   {
      81         630 :     _axial_regions = getParam<std::vector<Real>>("axial_regions");
      82         945 :     _axial_mesh_intervals = getParam<std::vector<unsigned int>>("axial_mesh_intervals");
      83             : 
      84         315 :     if (_axial_regions.size() != _axial_mesh_intervals.size())
      85           0 :       mooseError(
      86             :           "The number of axial regions is not consistent with the number of axial intervals.");
      87             :     this->declareMeshProperty(RGMB::axial_mesh_sizes, _axial_regions);
      88             :     this->declareMeshProperty(RGMB::axial_mesh_intervals, _axial_mesh_intervals);
      89             :   }
      90             : 
      91        1092 :   this->declareMeshProperty(RGMB::mesh_dimensions, (unsigned int)std::stoul(_dim));
      92         546 :   this->declareMeshProperty(RGMB::mesh_geometry, std::string(_geom));
      93         546 :   this->declareMeshProperty(RGMB::assembly_pitch, _assembly_pitch);
      94             :   this->declareMeshProperty(RGMB::region_id_as_block_name,
      95             :                             getParam<bool>(RGMB::region_id_as_block_name));
      96             : 
      97         546 :   const bool flexible_assembly_stitching = getParam<bool>(RGMB::flexible_assembly_stitching);
      98             :   this->declareMeshProperty(RGMB::flexible_assembly_stitching, flexible_assembly_stitching);
      99         546 :   if (flexible_assembly_stitching)
     100         250 :     this->declareMeshProperty(RGMB::num_sectors_flexible_stitching,
     101             :                               getParam<unsigned int>("num_sectors_at_flexible_boundary"));
     102        1092 :   if (parameters.isParamSetByUser("num_sectors_at_flexible_boundary") &&
     103             :       !flexible_assembly_stitching)
     104           0 :     paramWarning(
     105             :         "num_sectors_at_flexible_boundary",
     106             :         "This parameter is only relevant when ReactorMeshParams/flexible_assembly_stitching is set "
     107             :         "to true. This value will be ignored");
     108             : 
     109             :   // Option to bypass mesh generation is controlled by presence of Mesh/data_driven_generator
     110             :   // and whether the current generator is in data only mode
     111         546 :   const auto & moose_mesh = _app.actionWarehouse().getMesh();
     112             :   const auto data_driven_generator =
     113         546 :       moose_mesh->parameters().get<std::string>("data_driven_generator");
     114         593 :   bool bypass_meshgen = (data_driven_generator != "") && isDataOnly();
     115             :   this->declareMeshProperty(RGMB::bypass_meshgen, bypass_meshgen);
     116             : 
     117        1092 :   if (isParamValid("top_boundary_id"))
     118             :   {
     119         626 :     _top_boundary = getParam<boundary_id_type>("top_boundary_id");
     120         313 :     this->declareMeshProperty(RGMB::top_boundary_id, _top_boundary);
     121             :   }
     122        1092 :   if (isParamValid("bottom_boundary_id"))
     123             :   {
     124         626 :     _bottom_boundary = getParam<boundary_id_type>("bottom_boundary_id");
     125         313 :     this->declareMeshProperty(RGMB::bottom_boundary_id, _bottom_boundary);
     126             :   }
     127        1092 :   if (isParamValid("radial_boundary_id"))
     128             :   {
     129         692 :     _radial_boundary = getParam<boundary_id_type>("radial_boundary_id");
     130         346 :     this->declareMeshProperty(RGMB::radial_boundary_id, _radial_boundary);
     131        1038 :     if (isParamValid("top_boundary_id") && _radial_boundary == _top_boundary)
     132           0 :       mooseError("top_boundary_id and radial_boundary_id must be unique values");
     133        1038 :     if (isParamValid("bottom_boundary_id") && _radial_boundary == _bottom_boundary)
     134           0 :       mooseError("bottom_boundary_id and radial_boundary_id must be unique values");
     135             :   }
     136        2031 :   if (isParamValid("top_boundary_id") && isParamValid("bottom_boundary_id") &&
     137         313 :       (_bottom_boundary == _top_boundary))
     138           0 :     mooseError("top_boundary_id and bottom_boundary_id must be unique values");
     139         546 : }
     140             : 
     141             : std::unique_ptr<MeshBase>
     142         451 : ReactorMeshParams::generate()
     143             : {
     144             :   // If mesh generation is requested and bypass_mesh is true, return a null mesh. generate()
     145             :   // mesh should not be called with this option specified
     146         451 :   if (getMeshProperty<bool>(RGMB::bypass_meshgen))
     147             :   {
     148             :     auto null_mesh = nullptr;
     149             :     return null_mesh;
     150             :   }
     151         451 :   auto mesh = buildMeshBaseObject();
     152         451 :   return dynamic_pointer_cast<MeshBase>(mesh);
     153         451 : }

Generated by: LCOV version 1.14