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 74065 : ExtremeValueBase<T>::validParams() 22 : { 23 74065 : InputParameters params = T::validParams(); 24 222195 : params.addParam<MooseEnum>( 25 : "value_type", 26 148130 : 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 74065 : return params; 31 0 : } 32 : 33 : template <class T> 34 1410 : ExtremeValueBase<T>::ExtremeValueBase(const InputParameters & parameters) 35 1410 : : T(parameters), _type(parameters.get<MooseEnum>("value_type").getEnum<ExtremeType>()) 36 : { 37 1406 : } 38 : 39 : template <class T> 40 : void 41 2619 : ExtremeValueBase<T>::initialize() 42 : { 43 2619 : if (_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS) 44 1785 : _proxy_value = 45 3570 : std::make_pair(-std::numeric_limits<Real>::max(), -std::numeric_limits<Real>::max()); 46 834 : else if (_type == ExtremeType::MIN) 47 834 : _proxy_value = 48 1668 : std::make_pair(std::numeric_limits<Real>::max(), std::numeric_limits<Real>::max()); 49 2619 : } 50 : 51 : template <class T> 52 : void 53 856531 : ExtremeValueBase<T>::computeExtremeValue() 54 : { 55 856531 : const auto pv = getProxyValuePair(); 56 : 57 1681804 : if ((_type == ExtremeType::MAX && pv > _proxy_value) || 58 825273 : (_type == ExtremeType::MIN && pv < _proxy_value)) 59 53725 : _proxy_value = pv; 60 802806 : 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 856531 : } 63 : 64 : template <class T> 65 : Real 66 2406 : ExtremeValueBase<T>::getValue() const 67 : { 68 2406 : return _proxy_value.second; 69 : } 70 : 71 : template <class T> 72 : void 73 2406 : ExtremeValueBase<T>::finalize() 74 : { 75 2406 : if (_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS) 76 1642 : this->gatherProxyValueMax(_proxy_value.first, _proxy_value.second); 77 764 : else if (_type == ExtremeType::MIN) 78 764 : this->gatherProxyValueMin(_proxy_value.first, _proxy_value.second); 79 2406 : } 80 : 81 : template <class T> 82 : void 83 213 : ExtremeValueBase<T>::threadJoin(const UserObject & y) 84 : { 85 213 : const auto & pps = static_cast<const ExtremeValueBase<T> &>(y); 86 : 87 74 : if (((_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS) && 88 362 : pps._proxy_value > _proxy_value) || 89 145 : (_type == ExtremeType::MIN && pps._proxy_value < _proxy_value)) 90 79 : _proxy_value = pps._proxy_value; 91 213 : } 92 : 93 : template class ExtremeValueBase<ElementPostprocessor>; 94 : template class ExtremeValueBase<ElementVariablePostprocessor>; 95 : template class ExtremeValueBase<NodalVariablePostprocessor>; 96 : template class ExtremeValueBase<SideVariablePostprocessor>;