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 "LayeredBin.h" 20 : #include "libmesh/mesh_tools.h" 21 : 22 : registerMooseObject("CardinalApp", LayeredBin); 23 : 24 : InputParameters 25 339 : LayeredBin::validParams() 26 : { 27 339 : InputParameters params = SpatialBinUserObject::validParams(); 28 678 : MooseEnum directions("x y z"); 29 : 30 678 : params.addRequiredParam<MooseEnum>( 31 : "direction", directions, "The direction of the layers (x, y, or z)"); 32 678 : params.addRequiredRangeCheckedParam<unsigned int>( 33 : "num_layers", 34 : "num_layers > 0", 35 : "The number of layers between the bounding box of the domain"); 36 339 : params.addClassDescription("Creates a unique spatial bin for layers in a specified direction"); 37 339 : return params; 38 339 : } 39 : 40 169 : LayeredBin::LayeredBin(const InputParameters & parameters) 41 : : SpatialBinUserObject(parameters), 42 169 : _direction(parameters.get<MooseEnum>("direction")), 43 338 : _num_layers(getParam<unsigned int>("num_layers")), 44 338 : _layered_subproblem(parameters.getCheckedPointerParam<SubProblem *>("_subproblem")) 45 : { 46 169 : BoundingBox bounding_box = MeshTools::create_bounding_box(_layered_subproblem->mesh()); 47 169 : _direction_min = bounding_box.min()(_direction); 48 169 : _direction_max = bounding_box.max()(_direction); 49 : 50 169 : _directions = {_direction}; 51 : 52 169 : _layer_pts.resize(_num_layers + 1); 53 169 : _layer_pts[0] = _direction_min; 54 169 : Real dx = (_direction_max - _direction_min) / _num_layers; 55 3044 : for (unsigned int i = 1; i < _num_layers + 1; ++i) 56 2875 : _layer_pts[i] = _layer_pts[i - 1] + dx; 57 : 58 169 : _bin_centers.resize(_num_layers); 59 3044 : for (unsigned int i = 0; i < _num_layers; ++i) 60 : { 61 2875 : _bin_centers[i] = Point(0.0, 0.0, 0.0); 62 2875 : _bin_centers[i](_direction) = 0.5 * (_layer_pts[i + 1] + _layer_pts[i]); 63 : } 64 169 : } 65 : 66 : unsigned int 67 128916328 : LayeredBin::bin(const Point & p) const 68 : { 69 128916328 : Real direction_x = p(_direction); 70 128916328 : return binFromBounds(direction_x, _layer_pts); 71 : } 72 : 73 : unsigned int 74 121338789 : LayeredBin::num_bins() const 75 : { 76 121338789 : return _num_layers; 77 : }