LCOV - code coverage report
Current view: top level - src/vectorpostprocessors - MyTRIMPKAEnergyHistogram.C (source / functions) Hit Total Coverage
Test: idaholab/magpie: 5710af Lines: 31 32 96.9 %
Date: 2025-07-21 23:34:39 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /**********************************************************************/
       2             : /*                     DO NOT MODIFY THIS HEADER                      */
       3             : /* MAGPIE - Mesoscale Atomistic Glue Program for Integrated Execution */
       4             : /*                                                                    */
       5             : /*            Copyright 2017 Battelle Energy Alliance, LLC            */
       6             : /*                        ALL RIGHTS RESERVED                         */
       7             : /**********************************************************************/
       8             : 
       9             : #include "MyTRIMPKAEnergyHistogram.h"
      10             : #include "MyTRIMRasterizer.h"
      11             : #include "mytrim/ion.h"
      12             : 
      13             : registerMooseObject("MagpieApp", MyTRIMPKAEnergyHistogram);
      14             : 
      15             : InputParameters
      16           8 : MyTRIMPKAEnergyHistogram::validParams()
      17             : {
      18           8 :   InputParameters params = GeneralVectorPostprocessor::validParams();
      19           8 :   params.addClassDescription(
      20             :       "Generate an energy histogram for the primary knock-on atom (PKA) list");
      21          16 :   params.addRequiredParam<UserObjectName>(
      22             :       "rasterizer", "Name of the MyTRIMRasterizer userobject to pull data from");
      23          16 :   params.addParam<unsigned int>("channel_number", 50, "Number of energy channels");
      24          24 :   params.addRangeCheckedParam<Real>(
      25          16 :       "channel_width", 5.0e6, "channel_width > 0", "Energy channel width in eV");
      26           8 :   return params;
      27           0 : }
      28             : 
      29           4 : MyTRIMPKAEnergyHistogram::MyTRIMPKAEnergyHistogram(const InputParameters & params)
      30             :   : GeneralVectorPostprocessor(params),
      31           4 :     _rasterizer(getUserObject<MyTRIMRasterizer>("rasterizer")),
      32           8 :     _nchannels(getParam<unsigned int>("channel_number")),
      33           8 :     _deltaE(getParam<Real>("channel_width")),
      34           4 :     _channel_center(declareVector("E")),
      35           8 :     _count(declareVector("n"))
      36             : {
      37             :   // initialize the channel energy vector
      38           4 :   _channel_center.resize(_nchannels);
      39         324 :   for (std::size_t i = 0; i < _nchannels; ++i)
      40         320 :     _channel_center[i] = (i + 0.5) * _deltaE;
      41           4 : }
      42             : 
      43             : void
      44           4 : MyTRIMPKAEnergyHistogram::initialize()
      45             : {
      46             :   // reset the statistics
      47           4 :   _count.assign(_nchannels, 0.0);
      48           4 : }
      49             : 
      50             : void
      51           4 : MyTRIMPKAEnergyHistogram::execute()
      52             : {
      53           4 :   const std::vector<MyTRIM_NS::IonBase> & pka_list = _rasterizer.getPKAList();
      54      600004 :   for (auto & pka : pka_list)
      55             :   {
      56      600000 :     int channel = pka._E / _deltaE;
      57             : 
      58      600000 :     if (channel >= 0 && static_cast<unsigned int>(channel) < _nchannels)
      59      600000 :       _count[channel]++;
      60             :   }
      61           4 : }
      62             : 
      63             : void
      64           4 : MyTRIMPKAEnergyHistogram::finalize()
      65             : {
      66           4 :   gatherSum(_count);
      67           4 : }

Generated by: LCOV version 1.14