LCOV - code coverage report
Current view: top level - src/kokkos/reporters - KokkosElementStatistics.K (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 33 34 97.1 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "KokkosElementStatistics.h"
      11             : 
      12             : InputParameters
      13        2132 : KokkosElementStatistics::validParams()
      14             : {
      15        2132 :   InputParameters params = ElementReporter::validParams();
      16        6396 :   params.addParam<std::string>("base_name", "Name to append to reporters.");
      17        2132 :   return params;
      18           0 : }
      19             : 
      20          49 : KokkosElementStatistics::KokkosElementStatistics(const InputParameters & parameters)
      21             :   : ElementReporter(parameters),
      22          27 :     _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
      23           9 :     _max(declareValueByName<Real>(_base_name + "max")),
      24           9 :     _min(declareValueByName<Real>(_base_name + "min")),
      25           9 :     _average(declareValueByName<Real>(_base_name + "average")),
      26           9 :     _integral(declareValueByName<Real>(_base_name + "integral")),
      27          18 :     _number_elements(declareValueByName<unsigned int>(_base_name + "number_elements"))
      28             : {
      29          17 : }
      30             : 
      31             : void
      32          15 : KokkosElementStatistics::initialize()
      33             : {
      34          15 :   _max = std::numeric_limits<Real>::min();
      35          15 :   _min = std::numeric_limits<Real>::max();
      36          15 :   _average = 0;
      37          15 :   _integral = 0;
      38          15 :   _number_elements = 0;
      39             : 
      40          15 :   allocateReductionBuffer(5);
      41          15 : }
      42             : 
      43             : void
      44          15 : KokkosElementStatistics::finalize()
      45             : {
      46          15 :   _max = _reduction_buffer[0];
      47          15 :   _min = _reduction_buffer[1];
      48          15 :   _integral = _reduction_buffer[2];
      49          15 :   _average = _reduction_buffer[3];
      50          15 :   _number_elements = _reduction_buffer[4];
      51             : 
      52          15 :   _communicator.max(_max);
      53          15 :   _communicator.min(_min);
      54          15 :   _communicator.sum(_integral);
      55          15 :   _communicator.sum(_average);
      56          15 :   _communicator.sum(_number_elements);
      57             : 
      58             :   // Compute the average;
      59          15 :   _average /= _number_elements;
      60          15 : }

Generated by: LCOV version 1.14