Skip to content

Commit

Permalink
Add support for maximum absolute value in ExtremeValue PPs
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Jan 25, 2025
1 parent 356c68f commit fb559a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion framework/include/postprocessors/ExtremeValueBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class ExtremeValueBase : public T
enum class ExtremeType
{
MAX,
MIN
MIN,
MAX_ABS
} _type;

/// Extreme value and proxy value at the same point
Expand Down
11 changes: 7 additions & 4 deletions framework/src/postprocessors/ExtremeValueBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ExtremeValueBase<T>::validParams()
{
InputParameters params = T::validParams();
params.addParam<MooseEnum>("value_type",
MooseEnum("max=0 min=1", "max"),
MooseEnum("max=0 min=1 max_abs=2", "max"),
"Type of extreme value to return. 'max' "
"returns the maximum value. 'min' returns "
"the minimum value.");
Expand All @@ -41,7 +41,7 @@ template <class T>
void
ExtremeValueBase<T>::initialize()
{
if (_type == ExtremeType::MAX)
if (_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS)
_proxy_value =
std::make_pair(-std::numeric_limits<Real>::max(), -std::numeric_limits<Real>::max());
else if (_type == ExtremeType::MIN)
Expand All @@ -58,6 +58,8 @@ ExtremeValueBase<T>::computeExtremeValue()
if ((_type == ExtremeType::MAX && pv > _proxy_value) ||
(_type == ExtremeType::MIN && pv < _proxy_value))
_proxy_value = pv;
else if (_type == ExtremeType::MAX_ABS && std::abs(pv.first) > _proxy_value.first)
_proxy_value = std::make_pair(std::abs(pv.first), pv.second);
}

template <class T>
Expand All @@ -71,7 +73,7 @@ template <class T>
void
ExtremeValueBase<T>::finalize()
{
if (_type == ExtremeType::MAX)
if (_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS)
{
if (_use_proxy)
this->gatherProxyValueMax(_proxy_value.first, _proxy_value.second);
Expand All @@ -93,7 +95,8 @@ ExtremeValueBase<T>::threadJoin(const UserObject & y)
{
const auto & pps = static_cast<const ExtremeValueBase<T> &>(y);

if ((_type == ExtremeType::MAX && pps._proxy_value > _proxy_value) ||
if (((_type == ExtremeType::MAX || _type == ExtremeType::MAX_ABS) &&
pps._proxy_value > _proxy_value) ||
(_type == ExtremeType::MIN && pps._proxy_value < _proxy_value))
_proxy_value = pps._proxy_value;
}
Expand Down

0 comments on commit fb559a1

Please sign in to comment.