LCOV - code coverage report
Current view: top level - src/filters - SphericalHarmonicsFilter.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: be601f Lines: 23 28 82.1 %
Date: 2025-07-15 20:50:38 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14