LCOV - code coverage report
Current view: top level - src/meshgenerators - CartesianMeshTrimmer.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 "CartesianMeshTrimmer.h"
      11             : #include "MooseMeshUtils.h"
      12             : #include "MathUtils.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", CartesianMeshTrimmer);
      18             : 
      19             : InputParameters
      20         356 : CartesianMeshTrimmer::validParams()
      21             : {
      22         356 :   InputParameters params = PolygonMeshTrimmerBase::validParams();
      23        1068 :   params.addRangeCheckedParam<std::vector<unsigned short>>(
      24             :       "trim_peripheral_region",
      25         712 :       std::vector<unsigned short>(4, 0),
      26             :       "trim_peripheral_region<=1",
      27             :       "Whether the peripheral region on each of the four sides will be trimmed in an assembly "
      28             :       "mesh. See documentation for numbering convention.");
      29         712 :   params.addParamNamesToGroup("trim_peripheral_region", "Peripheral Trimming");
      30         356 :   params.addClassDescription("This CartesianMeshTrimmer object performs peripheral and/or "
      31             :                              "across-center (0, 0, 0) trimming for "
      32             :                              "assembly or core 2D meshes generated by PatternedCartesianMG.");
      33             : 
      34         356 :   return params;
      35           0 : }
      36             : 
      37         182 : CartesianMeshTrimmer::CartesianMeshTrimmer(const InputParameters & parameters)
      38         182 :   : PolygonMeshTrimmerBase(parameters)
      39             : {
      40         180 :   _num_sides = SQUARE_NUM_SIDES;
      41         253 :   _trimming_start_sector =
      42         180 :       isParamValid("center_trim_starting_index")
      43         326 :           ? MathUtils::euclideanMod(getParam<short>("center_trim_starting_index") - 2, 8)
      44             :           : 8;
      45         251 :   _trimming_end_sector =
      46         180 :       isParamValid("center_trim_ending_index")
      47         322 :           ? MathUtils::euclideanMod(getParam<short>("center_trim_ending_index") - 2, 8)
      48             :           : 8;
      49         180 :   if ((_trimming_start_sector == 8 && _trimming_end_sector != 8) ||
      50          73 :       (_trimming_start_sector != 8 && _trimming_end_sector == 8))
      51           2 :     paramError("center_trim_starting_index",
      52             :                "this parameter must be provided along with center_trim_ending_index.");
      53         178 :   if (_trimming_start_sector == 8 && _trimming_end_sector == 8)
      54         107 :     _center_trim_sector_number = 8;
      55             :   else
      56          71 :     _center_trim_sector_number =
      57          71 :         MathUtils::euclideanMod(_trimming_end_sector - _trimming_start_sector, 8);
      58         178 :   if (_center_trim_sector_number > 4 && _center_trim_sector_number < 8)
      59           2 :     paramError("center_trim_starting_index",
      60             :                "the remaining mesh after center trimming defined by this parameter and "
      61             :                "center_trim_ending_index must be equal or smaller than half of the "
      62             :                "input mesh.");
      63         176 :   if (_center_trim_sector_number == 8 && !_center_trimming_section_boundary.empty())
      64           2 :     paramError("center_trimming_section_boundary",
      65             :                "this input parameter is not used if center trimming is not performed.");
      66         174 : }
      67             : 
      68             : std::unique_ptr<MeshBase>
      69         174 : CartesianMeshTrimmer::generate()
      70             : {
      71             :   // Check if input mesh is trimmable
      72         348 :   if (hasMeshProperty<bool>("square_peripheral_trimmability", _input_name) &&
      73         346 :       hasMeshProperty<bool>("square_center_trimmability", _input_name))
      74             :   {
      75         397 :     if (!getMeshProperty<bool>("square_peripheral_trimmability", _input_name) &&
      76             :         std::accumulate(_trim_peripheral_region.begin(), _trim_peripheral_region.end(), 0) > 0)
      77           2 :       paramError("input", "The input mesh does not have a trimmable peripheral region.");
      78         340 :     if (!getMeshProperty<bool>("square_center_trimmability", _input_name) &&
      79           2 :         _center_trim_sector_number < 8)
      80           2 :       paramError("input", "The input mesh cannot be trimmed through its center.");
      81             :   }
      82             :   else
      83           2 :     paramError("input",
      84             :                "The input mesh's meta data is not compatible with the CartesianMeshTrimmer because "
      85             :                "the trimmability mesh meta data are absent.");
      86             : 
      87         168 :   return PolygonMeshTrimmerBase::generate();
      88             : }

Generated by: LCOV version 1.14