From 90d07c4b90ee9d6603e7ca2012b4ceb0400676e1 Mon Sep 17 00:00:00 2001 From: Nuno Nobre Date: Thu, 22 Aug 2024 13:41:03 +0100 Subject: [PATCH 1/3] Remove redundant checks for nodal vars (#28459) --- framework/src/postprocessors/ElementExtremeFunctorValue.C | 2 -- framework/src/postprocessors/ElementExtremeValue.C | 2 -- 2 files changed, 4 deletions(-) diff --git a/framework/src/postprocessors/ElementExtremeFunctorValue.C b/framework/src/postprocessors/ElementExtremeFunctorValue.C index 4bf0321cb294..83cf3b170434 100644 --- a/framework/src/postprocessors/ElementExtremeFunctorValue.C +++ b/framework/src/postprocessors/ElementExtremeFunctorValue.C @@ -37,8 +37,6 @@ ElementExtremeFunctorValueTempl::ElementExtremeFunctorValueTempl( _proxy_functor(isParamValid("proxy_functor") ? getFunctor>("proxy_functor") : getFunctor>("functor")) { - if (this->isNodal()) - this->paramError("variable", "This AuxKernel only supports Elemental fields"); _use_proxy = isParamValid("proxy_functor"); } diff --git a/framework/src/postprocessors/ElementExtremeValue.C b/framework/src/postprocessors/ElementExtremeValue.C index 4e5bc677db57..3a317acf418c 100644 --- a/framework/src/postprocessors/ElementExtremeValue.C +++ b/framework/src/postprocessors/ElementExtremeValue.C @@ -28,8 +28,6 @@ ElementExtremeValue::ElementExtremeValue(const InputParameters & parameters) : ExtremeValueBase(parameters), _proxy_variable(isParamValid("proxy_variable") ? coupledValue("proxy_variable") : _u) { - if (this->isNodal()) - this->paramError("variable", "This AuxKernel only supports Elemental fields"); _use_proxy = isParamValid("proxy_variable"); } From b55d462ca2dea52a3944958965e2a1ff30ad3218 Mon Sep 17 00:00:00 2001 From: Nuno Nobre Date: Thu, 22 Aug 2024 22:30:59 +0100 Subject: [PATCH 2/3] Improve the docs for ElementExtreme(Functor)Value (#28459) --- .../postprocessors/ElementExtremeFunctorValue.md | 7 +++++-- .../source/postprocessors/ElementExtremeValue.md | 12 ++++++++++-- .../src/postprocessors/ElementExtremeFunctorValue.C | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/framework/doc/content/source/postprocessors/ElementExtremeFunctorValue.md b/framework/doc/content/source/postprocessors/ElementExtremeFunctorValue.md index ba450f0b414c..d821d49253f1 100644 --- a/framework/doc/content/source/postprocessors/ElementExtremeFunctorValue.md +++ b/framework/doc/content/source/postprocessors/ElementExtremeFunctorValue.md @@ -8,8 +8,11 @@ find the element at which the proxy functor reaches the max/min value, and then return the value of the specified functor at that element. !alert note -Unlike the [ElementExtremeValue.md] postprocessor, this postprocessor does not examine the quadrature -point values, but instead passes the element argument to the functor. +Like the [ElementExtremeValue.md] postprocessor, this postprocessor can also +operate on both elemental and nodal variables. +However, unlike the [ElementExtremeValue.md] postprocessor, this postprocessor +does not examine the quadrature point values, but instead passes the element +argument to the functor. ## Example Input File Syntax diff --git a/framework/doc/content/source/postprocessors/ElementExtremeValue.md b/framework/doc/content/source/postprocessors/ElementExtremeValue.md index 7f8b290cf79e..05da9182983e 100644 --- a/framework/doc/content/source/postprocessors/ElementExtremeValue.md +++ b/framework/doc/content/source/postprocessors/ElementExtremeValue.md @@ -7,8 +7,16 @@ which will change the behavior of this postprocessor to find the quadrature point at which the proxy variable reaches the max/min value, and then return the value of the specified variable at that point. -The corresponding postprocessor that finds extreme values of nodal variables -evaluated at nodes is [NodalExtremeValue](NodalExtremeValue.md) +This postprocessor can operate on both elemental and nodal variables. Note, +however, that since it works by sampling the variable at quadrature points, +its returned value won't exactly match the variable's extreme value on the +domain (or blocks) the postprocessor is defined over. This is the case, unless +that extremum happens to be at a quadrature point, e.g., if the variable is +constant over any given element. +An alternative scheme is provided by [ElementExtremeFunctorValue.md], which +instead of comparing values at quadrature points, compares element averages. +The corresponding postprocessor that finds (exact) extreme values of nodal +variables evaluated at nodes is [NodalExtremeValue.md]. ## Example Input File Syntax diff --git a/framework/src/postprocessors/ElementExtremeFunctorValue.C b/framework/src/postprocessors/ElementExtremeFunctorValue.C index 83cf3b170434..208c8d824da5 100644 --- a/framework/src/postprocessors/ElementExtremeFunctorValue.C +++ b/framework/src/postprocessors/ElementExtremeFunctorValue.C @@ -25,7 +25,7 @@ ElementExtremeFunctorValueTempl::validParams() "the functor value should be taken; if not provided, this defaults " "to the 'functor' parameter."); params.addClassDescription( - "Finds either the min or max elemental value of a variable over the domain."); + "Finds either the min or max elemental value of a functor over the domain."); return params; } From d5c1651e4bf46d2ec0ebb0769faf0586bb7eea51 Mon Sep 17 00:00:00 2001 From: Nuno Nobre Date: Thu, 22 Aug 2024 17:32:07 +0100 Subject: [PATCH 3/3] Slightly simplify ExtremeValueBase (#28459) --- .../src/postprocessors/ExtremeValueBase.C | 77 ++++++------------- 1 file changed, 24 insertions(+), 53 deletions(-) diff --git a/framework/src/postprocessors/ExtremeValueBase.C b/framework/src/postprocessors/ExtremeValueBase.C index 07920be9a9cd..39d230f4a852 100644 --- a/framework/src/postprocessors/ExtremeValueBase.C +++ b/framework/src/postprocessors/ExtremeValueBase.C @@ -41,18 +41,12 @@ template void ExtremeValueBase::initialize() { - switch (_type) - { - case ExtremeType::MAX: - _proxy_value = - std::make_pair(-std::numeric_limits::max(), -std::numeric_limits::max()); - break; - - case ExtremeType::MIN: - _proxy_value = - std::make_pair(std::numeric_limits::max(), std::numeric_limits::max()); - break; - } + if (_type == ExtremeType::MAX) + _proxy_value = + std::make_pair(-std::numeric_limits::max(), -std::numeric_limits::max()); + else if (_type == ExtremeType::MIN) + _proxy_value = + std::make_pair(std::numeric_limits::max(), std::numeric_limits::max()); } template @@ -60,18 +54,10 @@ void ExtremeValueBase::computeExtremeValue() { const auto pv = getProxyValuePair(); - switch (_type) - { - case ExtremeType::MAX: - if (pv > _proxy_value) - _proxy_value = pv; - break; - case ExtremeType::MIN: - if (pv < _proxy_value) - _proxy_value = pv; - break; - } + if ((_type == ExtremeType::MAX && pv > _proxy_value) || + (_type == ExtremeType::MIN && pv < _proxy_value)) + _proxy_value = pv; } template @@ -85,26 +71,19 @@ template void ExtremeValueBase::finalize() { - switch (_type) + if (_type == ExtremeType::MAX) { - case ExtremeType::MAX: - if (_use_proxy) - this->gatherProxyValueMax(_proxy_value.first, _proxy_value.second); - else - { - this->gatherMax(_proxy_value.first); - _proxy_value.second = _proxy_value.first; - } - break; - case ExtremeType::MIN: - if (_use_proxy) - this->gatherProxyValueMin(_proxy_value.first, _proxy_value.second); - else - { - this->gatherMin(_proxy_value.first); - _proxy_value.second = _proxy_value.first; - } - break; + if (_use_proxy) + this->gatherProxyValueMax(_proxy_value.first, _proxy_value.second); + else + this->gatherMax(_proxy_value.second); + } + else if (_type == ExtremeType::MIN) + { + if (_use_proxy) + this->gatherProxyValueMin(_proxy_value.first, _proxy_value.second); + else + this->gatherMin(_proxy_value.second); } } @@ -114,17 +93,9 @@ ExtremeValueBase::threadJoin(const UserObject & y) { const auto & pps = static_cast &>(y); - switch (_type) - { - case ExtremeType::MAX: - if (pps._proxy_value > _proxy_value) - _proxy_value = pps._proxy_value; - break; - case ExtremeType::MIN: - if (pps._proxy_value < _proxy_value) - _proxy_value = pps._proxy_value; - break; - } + if ((_type == ExtremeType::MAX && pps._proxy_value > _proxy_value) || + (_type == ExtremeType::MIN && pps._proxy_value < _proxy_value)) + _proxy_value = pps._proxy_value; } template class ExtremeValueBase;