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 "KokkosNodalStatistics.h" 11 : 12 : InputParameters 13 2132 : KokkosNodalStatistics::validParams() 14 : { 15 2132 : InputParameters params = NodalReporter::validParams(); 16 6396 : params.addParam<std::string>("base_name", "Name to append to reporters."); 17 2132 : return params; 18 0 : } 19 : 20 49 : KokkosNodalStatistics::KokkosNodalStatistics(const InputParameters & parameters) 21 : : NodalReporter(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 18 : _number_nodes(declareValueByName<unsigned int>(_base_name + "number_nodes")) 27 : { 28 17 : } 29 : 30 : void 31 15 : KokkosNodalStatistics::initialize() 32 : { 33 15 : _max = std::numeric_limits<Real>::min(); 34 15 : _min = std::numeric_limits<Real>::max(); 35 15 : _average = 0; 36 15 : _number_nodes = 0; 37 : 38 15 : allocateReductionBuffer(4); 39 15 : } 40 : 41 : void 42 15 : KokkosNodalStatistics::finalize() 43 : { 44 15 : _max = _reduction_buffer[0]; 45 15 : _min = _reduction_buffer[1]; 46 15 : _average = _reduction_buffer[2]; 47 15 : _number_nodes = _reduction_buffer[3]; 48 : 49 15 : _communicator.max(_max); 50 15 : _communicator.min(_min); 51 15 : _communicator.sum(_average); 52 15 : _communicator.sum(_number_nodes); 53 : 54 : // Compute the average; 55 15 : _average /= _number_nodes; 56 15 : }