LCOV - code coverage report
Current view: top level - src/filters - ParticleFilter.C (source / functions) Hit Total Coverage
Test: neams-th-coe/cardinal: 93e9c4 Lines: 21 22 95.5 %
Date: 2026-07-16 12:06:10 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 "ParticleFilter.h"
      22             : 
      23             : #include "CardinalEnums.h"
      24             : 
      25             : #include "openmc/tallies/filter_particle.h"
      26             : 
      27             : registerMooseObject("CardinalApp", ParticleFilter);
      28             : 
      29             : InputParameters
      30         134 : ParticleFilter::validParams()
      31             : {
      32         134 :   auto params = FilterBase::validParams();
      33         134 :   params.addClassDescription(
      34             :       "A class which provides a thin wrapper around an OpenMC ParticleFilter.");
      35         268 :   params.addRequiredParam<MultiMooseEnum>(
      36         268 :       "particles", getParticleFilterEnums(), "The particles to filter for.");
      37             : 
      38         134 :   return params;
      39           0 : }
      40             : 
      41          68 : ParticleFilter::ParticleFilter(const InputParameters & parameters) : FilterBase(parameters)
      42             : {
      43          68 :   if (_openmc_problem.runRandomRay())
      44           2 :     mooseError("ParticleFilter is presently not supported when running the random ray solver!");
      45             : 
      46         222 :   for (const auto & m_enum : getParam<MultiMooseEnum>("particles"))
      47             :   {
      48          90 :     _particles.emplace_back(m_enum);
      49             : 
      50             :     // Need to convert MultiMooseEnum values (all upper case characters) to lower case characters.
      51          90 :     std::transform(_particles.back().begin(),
      52             :                    _particles.back().end(),
      53             :                    _particles.back().begin(),
      54         630 :                    [](unsigned char c) { return std::tolower(c); });
      55             :   }
      56         132 :   auto particle_filter = dynamic_cast<openmc::ParticleFilter *>(openmc::Filter::create("particle"));
      57             : 
      58             :   std::vector<openmc::ParticleType> p;
      59         156 :   for (const auto & ps : _particles)
      60          90 :     p.emplace_back(ps);
      61             : 
      62          66 :   particle_filter->set_particles(p);
      63          66 :   _filter = particle_filter;
      64          66 : }
      65             : 
      66             : std::string
      67         668 : ParticleFilter::binName(unsigned int bin_index) const
      68             : {
      69         668 :   return _particles[bin_index];
      70             : }
      71             : 
      72             : #endif

Generated by: LCOV version 1.14