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 : #ifdef ENABLE_OPENMC_COUPLING 20 : 21 : #include "AzimuthalAngleFilter.h" 22 : 23 : #include "OpenMCCellAverageProblem.h" 24 : 25 : #include "openmc/tallies/filter_azimuthal.h" 26 : 27 : registerMooseObject("CardinalApp", AzimuthalAngleFilter); 28 : 29 : InputParameters 30 88 : AzimuthalAngleFilter::validParams() 31 : { 32 88 : auto params = FilterBase::validParams(); 33 88 : params.addClassDescription( 34 : "A class which provides a thin wrapper around an OpenMC AzimuthalFilter. " 35 : "Bins can either be equally spaced by setting 'num_equal_divisions', or a set of azimuthal " 36 : "angles can " 37 : "be provided by setting 'azimuthal_angle_boundaries'."); 38 176 : params.addRangeCheckedParam<unsigned int>( 39 : "num_equal_divisions", 40 : "num_equal_divisions > 0", 41 : "The number of equally spaces subdivisions of " 42 : "$[-\\pi, \\pi)$ to use if equal subdivisions are desired."); 43 176 : params.addParam<std::vector<Real>>("azimuthal_angle_boundaries", 44 : "The azimuthal angle boundaries in $[-\\pi, \\pi)$ which must " 45 : "be provided in increasing order. If $-\\pi$ and " 46 : "$\\pi$ are not included this filter may result in some " 47 : "missed particles during normalization."); 48 : 49 88 : return params; 50 0 : } 51 : 52 48 : AzimuthalAngleFilter::AzimuthalAngleFilter(const InputParameters & parameters) 53 48 : : FilterBase(parameters) 54 : { 55 48 : if (_openmc_problem.runRandomRay()) 56 2 : mooseError( 57 : "AzimuthalAngleFilter is presently not supported when running the random ray solver!"); 58 : 59 138 : if (isParamValid("num_equal_divisions") == isParamValid("azimuthal_angle_boundaries")) 60 4 : mooseError( 61 : "You have either set 'num_equal_divisions' and 'azimuthal_angle_boundaries' or have not " 62 : "specified a bin option! Please specify either 'num_equal_divisions' or " 63 : "'azimuthal_angle_boundaries'."); 64 : 65 84 : if (isParamValid("num_equal_divisions")) 66 : { 67 48 : auto num_angles = getParam<unsigned int>("num_equal_divisions"); 68 96 : for (unsigned int i = 0; i < num_angles + 1; ++i) 69 72 : _azimuthal_angle_bnds.push_back((-libMesh::pi) + i * (2.0 * libMesh::pi / num_angles)); 70 : } 71 : 72 84 : if (isParamValid("azimuthal_angle_boundaries")) 73 : { 74 54 : _azimuthal_angle_bnds = getParam<std::vector<Real>>("azimuthal_angle_boundaries"); 75 : 76 : // Make sure we have at least two boundaries to form bins. 77 18 : if (_azimuthal_angle_bnds.size() < 2) 78 2 : paramError("azimuthal_angle_boundaries", 79 : "At least two azimuthal angles are required to create bins!"); 80 : 81 : // Sort the boundaries so they're monotonically decreasing. 82 16 : std::sort(_azimuthal_angle_bnds.begin(), 83 : _azimuthal_angle_bnds.end(), 84 48 : [](const Real & a, const Real & b) { return a < b; }); 85 : 86 : // Warn the user if there is the possibility of missed particles. 87 16 : if (_azimuthal_angle_bnds.front() > (-1.0 * libMesh::pi) || 88 16 : _azimuthal_angle_bnds.back() < libMesh::pi) 89 0 : mooseWarning( 90 : "The bin boundaries don't contain one of the following: -pi or pi. Some particles may be " 91 : "missed during normalization."); 92 : } 93 : 94 : // Initialize the OpenMC AzimuthalFilter. 95 40 : _filter_index = openmc::model::tally_filters.size(); 96 : 97 : auto azimuthal_filter = 98 80 : dynamic_cast<openmc::AzimuthalFilter *>(openmc::Filter::create("azimuthal")); 99 40 : azimuthal_filter->set_bins(_azimuthal_angle_bnds); 100 40 : _filter = azimuthal_filter; 101 40 : } 102 : 103 : std::string 104 144 : AzimuthalAngleFilter::binName(unsigned int bin_index) const 105 : { 106 288 : return "omega" + Moose::stringify(bin_index + 1); 107 : } 108 : #endif