LCOV - code coverage report
Current view: top level - src/postprocessors - MyTRIMPKAInfo.C (source / functions) Hit Total Coverage
Test: idaholab/magpie: 5710af Lines: 39 41 95.1 %
Date: 2025-07-21 23:34:39 Functions: 6 6 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 "MyTRIMPKAInfo.h"
      10             : #include "MyTRIMRasterizer.h"
      11             : 
      12             : registerMooseObject("MagpieApp", MyTRIMPKAInfo);
      13             : 
      14             : InputParameters
      15          88 : MyTRIMPKAInfo::validParams()
      16             : {
      17          88 :   InputParameters params = GeneralPostprocessor::validParams();
      18          88 :   params.addClassDescription("Aggregate a global property of the primary knock-on atom (PKA) list "
      19             :                              "(e.g. total energy or number of PKA)");
      20         176 :   params.addRequiredParam<UserObjectName>(
      21             :       "rasterizer", "Name of the MyTRIMRasterizer userobject to pull data from");
      22         176 :   MooseEnum value_type_options("TOTAL_MASS=0 TOTAL_ENERGY TOTAL_CHARGE TOTAL_NUMBER");
      23         176 :   params.addParam<MooseEnum>(
      24             :       "value_type",
      25             :       value_type_options,
      26             :       "The property of the PKA set which is aggregated by this postprocessor");
      27          88 :   return params;
      28          88 : }
      29             : 
      30          44 : MyTRIMPKAInfo::MyTRIMPKAInfo(const InputParameters & params)
      31             :   : GeneralPostprocessor(params),
      32          44 :     _rasterizer(getUserObject<MyTRIMRasterizer>("rasterizer")),
      33         132 :     _value_type(getParam<MooseEnum>("value_type").getEnum<ValueType>())
      34             : {
      35          44 : }
      36             : 
      37             : void
      38         140 : MyTRIMPKAInfo::initialize()
      39             : {
      40         140 :   _value = 0.0;
      41         140 : }
      42             : 
      43             : void
      44         140 : MyTRIMPKAInfo::execute()
      45             : {
      46         140 :   const std::vector<MyTRIM_NS::IonBase> & pka_list = _rasterizer.getPKAList();
      47       30971 :   for (auto & pka : pka_list)
      48             :   {
      49       30831 :     if (skipPKA(pka))
      50         120 :       continue;
      51             : 
      52       30711 :     switch (_value_type)
      53             :     {
      54        7140 :       case TOTAL_MASS:
      55        7140 :         _value += pka._m;
      56        7140 :         break;
      57             : 
      58        7290 :       case TOTAL_ENERGY:
      59        7290 :         _value += pka._E;
      60        7290 :         break;
      61             : 
      62        7140 :       case TOTAL_CHARGE:
      63        7140 :         _value += pka._Z;
      64        7140 :         break;
      65             : 
      66        9141 :       case TOTAL_NUMBER:
      67        9141 :         _value += 1.0;
      68        9141 :         break;
      69             : 
      70           0 :       default:
      71           0 :         mooseError("Internal error");
      72             :     }
      73             :   }
      74         140 : }
      75             : 
      76             : void
      77         140 : MyTRIMPKAInfo::finalize()
      78             : {
      79         140 :   gatherSum(_value);
      80         140 : }
      81             : 
      82             : Real
      83         140 : MyTRIMPKAInfo::getValue() const
      84             : {
      85         140 :   return _value;
      86             : }

Generated by: LCOV version 1.14