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 "SphericalHarmonicsFilter.h" 22 : 23 : #include "OpenMCCellAverageProblem.h" 24 : 25 : #include "openmc/tallies/filter_sph_harm.h" 26 : 27 : registerMooseObject("CardinalApp", SphericalHarmonicsFilter); 28 : 29 : InputParameters 30 50 : SphericalHarmonicsFilter::validParams() 31 : { 32 50 : auto params = FilterBase::validParams(); 33 50 : params.addClassDescription( 34 : "A class which provides a thin wrapper around an OpenMC SphericalHarmonicsFilter."); 35 100 : params.addRequiredParam<unsigned int>("order", "The order of the spherical harmonics expansion."); 36 : 37 50 : return params; 38 0 : } 39 : 40 26 : SphericalHarmonicsFilter::SphericalHarmonicsFilter(const InputParameters & parameters) 41 52 : : FilterBase(parameters), _order(getParam<unsigned int>("order")) 42 : { 43 26 : if (_openmc_problem.runRandomRay()) 44 2 : mooseError( 45 : "SphericalHarmonicsFilter is presently not supported when running the random ray solver!"); 46 : 47 24 : auto sh_filter = dynamic_cast<openmc::SphericalHarmonicsFilter *>( 48 24 : openmc::Filter::create("sphericalharmonics")); 49 : try 50 : { 51 24 : sh_filter->set_order(_order); 52 : } 53 0 : catch (const std::exception & e) 54 : { 55 0 : paramError("order", e.what()); 56 0 : } 57 24 : sh_filter->set_cosine("particle"); 58 24 : _filter = sh_filter; 59 24 : } 60 : 61 : std::string 62 160 : SphericalHarmonicsFilter::binName(unsigned int bin_index) const 63 : { 64 : unsigned int num_mom = 0; 65 280 : for (unsigned int l = 0; l <= _order; ++l) 66 : { 67 360 : for (int m = -1 * static_cast<int>(l); m < 0; ++m) 68 : { 69 120 : if (num_mom == bin_index) 70 160 : return "l" + Moose::stringify(l) + "_mneg" + Moose::stringify(-1 * m); 71 80 : num_mom++; 72 : } 73 400 : for (unsigned int m = 0; m <= l; ++m) 74 : { 75 280 : if (num_mom == bin_index) 76 360 : return "l" + Moose::stringify(l) + "_mpos" + Moose::stringify(m); 77 160 : num_mom++; 78 : } 79 : } 80 : 81 0 : return ""; 82 : } 83 : #endif