LCOV - code coverage report
Current view: top level - src/meshgenerators - HexagonMeshTrimmer.C (source / functions) Hit Total Coverage
Test: idaholab/moose reactor: #31405 (292dce) with base fef103 Lines: 38 39 97.4 %
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 "HexagonMeshTrimmer.h"
      11             : #include "MathUtils.h"
      12             : #include "MooseMeshUtils.h"
      13             : 
      14             : // C++ includes
      15             : #include <cmath> // provides round, not std::round (see http://www.cplusplus.com/reference/cmath/round/)
      16             : 
      17             : registerMooseObject("ReactorApp", HexagonMeshTrimmer);
      18             : 
      19             : InputParameters
      20         320 : HexagonMeshTrimmer::validParams()
      21             : {
      22         320 :   InputParameters params = PolygonMeshTrimmerBase::validParams();
      23         960 :   params.addRangeCheckedParam<std::vector<unsigned short>>(
      24             :       "trim_peripheral_region",
      25         640 :       std::vector<unsigned short>(6, 0),
      26             :       "trim_peripheral_region<=1",
      27             :       "Whether the peripheral region on each of the six sides will be trimmed "
      28             :       "in an assembly "
      29             :       "mesh. See documentation for numbering convention.");
      30         640 :   params.addParamNamesToGroup("trim_peripheral_region", "Peripheral Trimming");
      31         320 :   params.addClassDescription("This HexagonMeshTrimmer object performs peripheral and/or "
      32             :                              "across-center (0, 0, 0) trimming for "
      33             :                              "assembly or core 2D meshes generated by PatternedHexMG.");
      34             : 
      35         320 :   return params;
      36           0 : }
      37             : 
      38         164 : HexagonMeshTrimmer::HexagonMeshTrimmer(const InputParameters & parameters)
      39         164 :   : PolygonMeshTrimmerBase(parameters)
      40             : {
      41         162 :   _num_sides = HEXAGON_NUM_SIDES;
      42         233 :   _trimming_start_sector =
      43         162 :       isParamValid("center_trim_starting_index")
      44         304 :           ? MathUtils::euclideanMod(getParam<short>("center_trim_starting_index") - 3, 12)
      45             :           : 12;
      46         231 :   _trimming_end_sector =
      47         162 :       isParamValid("center_trim_ending_index")
      48         300 :           ? MathUtils::euclideanMod(getParam<short>("center_trim_ending_index") - 3, 12)
      49             :           : 12;
      50         162 :   if ((_trimming_start_sector == 12 && _trimming_end_sector != 12) ||
      51          71 :       (_trimming_start_sector != 12 && _trimming_end_sector == 12))
      52           2 :     paramError("center_trim_starting_index",
      53             :                "this parameter must be provided along with center_trim_ending_index.");
      54         160 :   if (_trimming_start_sector == 12 && _trimming_end_sector == 12)
      55          91 :     _center_trim_sector_number = 12;
      56             :   else
      57          69 :     _center_trim_sector_number =
      58          69 :         MathUtils::euclideanMod(_trimming_end_sector - _trimming_start_sector, 12);
      59         160 :   if (_center_trim_sector_number > 6 && _center_trim_sector_number < 12)
      60           2 :     paramError("center_trim_starting_index",
      61             :                "the remaining mesh after center trimming defined by this parameter and "
      62             :                "center_trim_ending_index must be equal or smaller than half of the input mesh.");
      63         158 :   if (_center_trim_sector_number == 12 && !_center_trimming_section_boundary.empty())
      64           2 :     paramError("center_trimming_section_boundary",
      65             :                "this input parameter is not used if center trimming is not "
      66             :                "performed.");
      67         156 : }
      68             : 
      69             : std::unique_ptr<MeshBase>
      70         156 : HexagonMeshTrimmer::generate()
      71             : {
      72             :   // Check if input mesh is trimmable
      73         312 :   if (hasMeshProperty<bool>("hexagon_peripheral_trimmability", _input_name) &&
      74         310 :       hasMeshProperty<bool>("hexagon_center_trimmability", _input_name))
      75             :   {
      76         359 :     if (!getMeshProperty<bool>("hexagon_peripheral_trimmability", _input_name) &&
      77             :         std::accumulate(_trim_peripheral_region.begin(), _trim_peripheral_region.end(), 0) > 0)
      78           2 :       paramError("input", "The input mesh does not have a trimmable peripheral region.");
      79         304 :     if (!getMeshProperty<bool>("hexagon_center_trimmability", _input_name) &&
      80           2 :         _center_trim_sector_number < 12)
      81           2 :       paramError("input", "The input mesh cannot be trimmed through its center.");
      82             :   }
      83             :   else
      84           2 :     paramError("input",
      85             :                "The input mesh is not compatible with HexagonMeshTrimmer because "
      86             :                "the trimmability mesh meta data are absent.");
      87             : 
      88         150 :   return PolygonMeshTrimmerBase::generate();
      89             : }

Generated by: LCOV version 1.14