Line data Source code
1 : /********************************************************************/ 2 : /* SOFTWARE COPYRIGHT NOTIFICATION */ 3 : /* Cardinal */ 4 : /* */ 5 : /* (c) 2021 UChicago Argonne, LLC */ 6 : /* ALL RIGHTS RESERVED */ 7 : /* */ 8 : /* Prepared by UChicago Argonne, LLC */ 9 : /* Under Contract No. DE-AC02-06CH11357 */ 10 : /* With the U. S. Department of Energy */ 11 : /* */ 12 : /* Prepared by Battelle Energy Alliance, LLC */ 13 : /* Under Contract No. DE-AC07-05ID14517 */ 14 : /* With the U. S. Department of Energy */ 15 : /* */ 16 : /* See LICENSE for full restrictions */ 17 : /********************************************************************/ 18 : 19 : #include "RadialBin.h" 20 : 21 : registerMooseObject("CardinalApp", RadialBin); 22 : 23 : InputParameters 24 104 : RadialBin::validParams() 25 : { 26 104 : InputParameters params = SpatialBinUserObject::validParams(); 27 208 : MooseEnum directions("x y z"); 28 : 29 208 : params.addRequiredParam<MooseEnum>( 30 : "vertical_axis", 31 : directions, 32 : "The vertical axis about which to compute the radial coordinate (x, y, or z)"); 33 312 : params.addRangeCheckedParam<Real>( 34 : "rmin", 35 208 : 0.0, 36 : "rmin >= 0.0", 37 : "Inner radius. Setting 'rmin = 0' corresponds to a cross-section of a circle"); 38 208 : params.addRequiredRangeCheckedParam<Real>("rmax", "rmax > 0.0", "Outer radius"); 39 : 40 208 : params.addRequiredRangeCheckedParam<unsigned int>( 41 : "nr", "nr > 0", "The number of layers in the radial direction"); 42 312 : params.addRangeCheckedParam<Real>("growth_r", 43 208 : 1.0, 44 : "growth_r > 0.0", 45 : "The ratio of radial sizes of successive rings of elements"); 46 : 47 104 : params.addClassDescription("Creates spatial bins for layers in the radial direction"); 48 104 : return params; 49 104 : } 50 : 51 52 : RadialBin::RadialBin(const InputParameters & parameters) 52 : : SpatialBinUserObject(parameters), 53 52 : _vertical_axis(parameters.get<MooseEnum>("vertical_axis")), 54 104 : _rmin(getParam<Real>("rmin")), 55 104 : _rmax(getParam<Real>("rmax")), 56 104 : _nr(getParam<unsigned int>("nr")), 57 156 : _growth_r(getParam<Real>("growth_r")) 58 : { 59 52 : if (_rmax <= _rmin) 60 0 : paramError("rmax", 61 : "Maximum radial coordinate 'rmax' must be greater than the minimum radial " 62 : "coordinate 'rmin'!"); 63 : 64 52 : Real first_width = _growth_r == 1.0 ? (_rmax - _rmin) / _nr 65 32 : : (_rmax - _rmin) * (1.0 - std::abs(_growth_r)) / 66 32 : (1.0 - std::pow(std::abs(_growth_r), _nr)); 67 : 68 52 : _radial_pts.resize(_nr + 1); 69 52 : _radial_pts[0] = _rmin; 70 52 : _radial_pts[1] = _radial_pts[0] + first_width; 71 : 72 496 : for (unsigned int i = 2; i < _nr + 1; ++i) 73 : { 74 444 : Real dr = _growth_r * (_radial_pts[i - 1] - _radial_pts[i - 2]); 75 444 : _radial_pts[i] = _radial_pts[i - 1] + dr; 76 : } 77 : 78 52 : if (_vertical_axis == 0) // x vertical axis 79 0 : _directions = {1, 2}; 80 52 : else if (_vertical_axis == 1) // y vertical axis 81 0 : _directions = {0, 2}; 82 : else // z vertical axis 83 52 : _directions = {0, 1}; 84 : 85 52 : _bin_centers.resize(_nr); 86 548 : for (unsigned int i = 0; i < _nr; ++i) 87 : { 88 496 : _bin_centers[i] = Point(0.0, 0.0, 0.0); 89 496 : _bin_centers[i](_directions[0]) = 0.5 * (_radial_pts[i + 1] + _radial_pts[i]); 90 : } 91 52 : } 92 : 93 : unsigned int 94 97744920 : RadialBin::bin(const Point & p) const 95 : { 96 97744920 : Real r = std::sqrt(p.norm_sq() - p(_vertical_axis) * p(_vertical_axis)); 97 97744920 : return binFromBounds(r, _radial_pts); 98 : } 99 : 100 : unsigned int 101 19448 : RadialBin::num_bins() const 102 : { 103 19448 : return _nr; 104 : }