LCOV - code coverage report
Current view: top level - src/postprocessors - ExtremeValueBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 39 40 97.5 %
Date: 2026-05-29 20:35:17 Functions: 28 28 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 "ElementExtremeFunctorValue.h"
      11             : 
      12             : #include "ElementPostprocessor.h"
      13             : #include "ElementVariablePostprocessor.h"
      14             : #include "NodalVariablePostprocessor.h"
      15             : #include "SideVariablePostprocessor.h"
      16             : 
      17             : #include <limits>
      18             : 
      19             : template <class T>
      20             : InputParameters
      21       18178 : ExtremeValueBase<T>::validParams()
      22             : {
      23       18178 :   InputParameters params = T::validParams();
      24       36356 :   params.addParam<MooseEnum>(
      25             :       "value_type",
      26       90890 :       MooseEnum("max=0 min=1 max_abs=2", "max"),
      27             :       "Type of extreme value to return. 'max' "
      28             :       "returns the maximum value. 'min' returns "
      29             :       "the minimum value. 'max_abs' returns the maximum of the absolute value.");
      30       18178 :   return params;
      31           0 : }
      32             : 
      33             : template <class T>
      34        1485 : ExtremeValueBase<T>::ExtremeValueBase(const InputParameters & parameters)
      35        1485 :   : T(parameters), _type(parameters.get<MooseEnum>("value_type").getEnum<ExtremeType>())
      36             : {
      37        1482 : }
      38             : 
      39             : template <class T>
      40             : void
      41        3008 : ExtremeValueBase<T>::initialize()
      42             : {
      43        3008 :   if (_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS)
      44        2161 :     _proxy_value =
      45        4322 :         std::make_pair(-std::numeric_limits<Real>::max(), -std::numeric_limits<Real>::max());
      46         847 :   else if (_type == ExtremeType::MIN)
      47         847 :     _proxy_value =
      48        1694 :         std::make_pair(std::numeric_limits<Real>::max(), std::numeric_limits<Real>::max());
      49        3008 : }
      50             : 
      51             : template <class T>
      52             : void
      53      868329 : ExtremeValueBase<T>::computeExtremeValue()
      54             : {
      55      868329 :   const auto pv = getProxyValuePair();
      56             : 
      57     1704319 :   if ((_type == ExtremeType::MAX && pv > _proxy_value) ||
      58      835990 :       (_type == ExtremeType::MIN && pv < _proxy_value))
      59       54790 :     _proxy_value = pv;
      60      813539 :   else if (_type == ExtremeType::MAX_ABS && std::abs(pv.first) > _proxy_value.first)
      61         352 :     _proxy_value = std::make_pair(std::abs(pv.first), pv.second);
      62      868329 : }
      63             : 
      64             : template <class T>
      65             : Real
      66        2763 : ExtremeValueBase<T>::getValue() const
      67             : {
      68        2763 :   return _proxy_value.second;
      69             : }
      70             : 
      71             : template <class T>
      72             : void
      73        2763 : ExtremeValueBase<T>::finalize()
      74             : {
      75        2763 :   if (_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS)
      76        1987 :     this->gatherProxyValueMax(_proxy_value.first, _proxy_value.second);
      77         776 :   else if (_type == ExtremeType::MIN)
      78         776 :     this->gatherProxyValueMin(_proxy_value.first, _proxy_value.second);
      79        2763 : }
      80             : 
      81             : template <class T>
      82             : void
      83         245 : ExtremeValueBase<T>::threadJoin(const UserObject & y)
      84             : {
      85         245 :   const auto & pps = static_cast<const ExtremeValueBase<T> &>(y);
      86             : 
      87          75 :   if (((_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS) &&
      88         423 :        pps._proxy_value > _proxy_value) ||
      89         174 :       (_type == ExtremeType::MIN && pps._proxy_value < _proxy_value))
      90          82 :     _proxy_value = pps._proxy_value;
      91         245 : }
      92             : 
      93             : template class ExtremeValueBase<ElementPostprocessor>;
      94             : template class ExtremeValueBase<ElementVariablePostprocessor>;
      95             : template class ExtremeValueBase<NodalVariablePostprocessor>;
      96             : template class ExtremeValueBase<SideVariablePostprocessor>;

Generated by: LCOV version 1.14