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 284 : CartesianMeshTrimmer::validParams() 21 : { 22 284 : InputParameters params = PolygonMeshTrimmerBase::validParams(); 23 852 : params.addRangeCheckedParam<std::vector<unsigned short>>( 24 : "trim_peripheral_region", 25 568 : 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 568 : params.addParamNamesToGroup("trim_peripheral_region", "Peripheral Trimming"); 30 284 : 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 284 : return params; 35 0 : } 36 : 37 146 : CartesianMeshTrimmer::CartesianMeshTrimmer(const InputParameters & parameters) 38 146 : : PolygonMeshTrimmerBase(parameters) 39 : { 40 144 : _num_sides = SQUARE_NUM_SIDES; 41 203 : _trimming_start_sector = 42 144 : isParamValid("center_trim_starting_index") 43 262 : ? MathUtils::euclideanMod(getParam<short>("center_trim_starting_index") - 2, 8) 44 : : 8; 45 201 : _trimming_end_sector = 46 144 : isParamValid("center_trim_ending_index") 47 258 : ? MathUtils::euclideanMod(getParam<short>("center_trim_ending_index") - 2, 8) 48 : : 8; 49 144 : if ((_trimming_start_sector == 8 && _trimming_end_sector != 8) || 50 59 : (_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 142 : if (_trimming_start_sector == 8 && _trimming_end_sector == 8) 54 85 : _center_trim_sector_number = 8; 55 : else 56 57 : _center_trim_sector_number = 57 57 : MathUtils::euclideanMod(_trimming_end_sector - _trimming_start_sector, 8); 58 142 : 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 140 : 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 138 : } 67 : 68 : std::unique_ptr<MeshBase> 69 138 : CartesianMeshTrimmer::generate() 70 : { 71 : // Check if input mesh is trimmable 72 276 : if (hasMeshProperty<bool>("square_peripheral_trimmability", _input_name) && 73 274 : hasMeshProperty<bool>("square_center_trimmability", _input_name)) 74 : { 75 315 : 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 268 : 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 132 : return PolygonMeshTrimmerBase::generate(); 88 : }