From 4d3aee5a689ce1d846c51d34e2e00de17b7cdea9 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Thu, 15 Jun 2023 12:04:13 -0600 Subject: [PATCH 1/9] add element and nodal reporters (#24678) --- .../CoupledVarStatsElementReporter.md | 23 +++++ .../reporters/CoupledVarStatsNodalReporter.md | 23 +++++ .../CoupledVarStatsElementReporter.h | 25 ++++++ .../reporters/CoupledVarStatsNodalReporter.h | 25 ++++++ framework/include/reporters/ElementReporter.h | 43 +++++++++ .../include/reporters/ElementStatsReporter.h | 36 ++++++++ framework/include/reporters/NodalReporter.h | 43 +++++++++ .../include/reporters/NodalStatsReporter.h | 35 ++++++++ .../CoupledVarStatsElementReporter.C | 40 +++++++++ .../reporters/CoupledVarStatsNodalReporter.C | 34 +++++++ framework/src/reporters/ElementReporter.C | 36 ++++++++ .../src/reporters/ElementStatsReporter.C | 89 +++++++++++++++++++ framework/src/reporters/NodalReporter.C | 36 ++++++++ framework/src/reporters/NodalStatsReporter.C | 80 +++++++++++++++++ .../element_reporter/coupledvarstats.i | 57 ++++++++++++ .../gold/coupledvarstats_stats.json | 48 ++++++++++ .../element_reporter/tests | 11 +++ .../nodal_reporter/coupledvarstats.i | 57 ++++++++++++ .../gold/coupledvarstats_stats.json | 43 +++++++++ .../ele_nodal_reporters/nodal_reporter/tests | 11 +++ 20 files changed, 795 insertions(+) create mode 100644 framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md create mode 100644 framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md create mode 100644 framework/include/reporters/CoupledVarStatsElementReporter.h create mode 100644 framework/include/reporters/CoupledVarStatsNodalReporter.h create mode 100644 framework/include/reporters/ElementReporter.h create mode 100644 framework/include/reporters/ElementStatsReporter.h create mode 100644 framework/include/reporters/NodalReporter.h create mode 100644 framework/include/reporters/NodalStatsReporter.h create mode 100644 framework/src/reporters/CoupledVarStatsElementReporter.C create mode 100644 framework/src/reporters/CoupledVarStatsNodalReporter.C create mode 100644 framework/src/reporters/ElementReporter.C create mode 100644 framework/src/reporters/ElementStatsReporter.C create mode 100644 framework/src/reporters/NodalReporter.C create mode 100644 framework/src/reporters/NodalStatsReporter.C create mode 100644 test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i create mode 100644 test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json create mode 100644 test/tests/reporters/ele_nodal_reporters/element_reporter/tests create mode 100644 test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i create mode 100644 test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json create mode 100644 test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests diff --git a/framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md b/framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md new file mode 100644 index 000000000000..229e3fe6aa66 --- /dev/null +++ b/framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md @@ -0,0 +1,23 @@ +# CoupledVarStatsElementReporter + +!syntax description /Reporters/CoupledVarStatsElementReporter + +## Overview + +CoupledVarStatsElementReporter produces the following statistics for a +variable: Maximum, Minium, Average, Integral, Total Elements. The +[!param](/Reporters/CoupledVarStatsElementReporter/base_name) can be used to prepend a +name to each reporter. + + + +## Example Input File Syntax + +!listing ele_nodal_reporters/element_reporter/coupledvarstats.i block=elem_stats + indent=2 header=[Reporters] footer=[] + +!syntax parameters /Reporters/CoupledVarStatsElementReporter + +!syntax inputs /Reporters/CoupledVarStatsElementReporter + +!syntax children /Reporters/CoupledVarStatsElementReporter diff --git a/framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md b/framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md new file mode 100644 index 000000000000..d91705b762a8 --- /dev/null +++ b/framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md @@ -0,0 +1,23 @@ +# CoupledVarStatsNodalReporter + +!syntax description /Reporters/CoupledVarStatsNodalReporter + +## Overview + +CoupledVarStatsNodalReporter produces the following statistics for a +variable: Maximum, Minium, Average, Total Nodes. The +[!param](/Reporters/CoupledVarStatsNodalReporter/base_name) can be used to prepend a +name to each reporter. + + + +## Example Input File Syntax + +!listing ele_nodal_reporters/nodal_reporter/coupledvarstats.i block=elem_stats + indent=2 header=[Reporters] footer=[] + +!syntax parameters /Reporters/CoupledVarStatsNodalReporter + +!syntax inputs /Reporters/CoupledVarStatsNodalReporter + +!syntax children /Reporters/CoupledVarStatsNodalReporter diff --git a/framework/include/reporters/CoupledVarStatsElementReporter.h b/framework/include/reporters/CoupledVarStatsElementReporter.h new file mode 100644 index 000000000000..e02943de814c --- /dev/null +++ b/framework/include/reporters/CoupledVarStatsElementReporter.h @@ -0,0 +1,25 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ElementStatsReporter.h" + +class CoupledVarStatsElementReporter : public ElementStatsReporter +{ +public: + static InputParameters validParams(); + + CoupledVarStatsElementReporter(const InputParameters & parameters); + +private: + /// The coupled variable used. + const VariableValue & _v; + virtual Real computeValue(); +}; diff --git a/framework/include/reporters/CoupledVarStatsNodalReporter.h b/framework/include/reporters/CoupledVarStatsNodalReporter.h new file mode 100644 index 000000000000..e6c81d12ac80 --- /dev/null +++ b/framework/include/reporters/CoupledVarStatsNodalReporter.h @@ -0,0 +1,25 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "NodalStatsReporter.h" + +class CoupledVarStatsNodalReporter : public NodalStatsReporter +{ +public: + static InputParameters validParams(); + + CoupledVarStatsNodalReporter(const InputParameters & parameters); + +private: + /// The coupled variable used. + const VariableValue & _v; + virtual Real computeValue(); +}; diff --git a/framework/include/reporters/ElementReporter.h b/framework/include/reporters/ElementReporter.h new file mode 100644 index 000000000000..beae1168638e --- /dev/null +++ b/framework/include/reporters/ElementReporter.h @@ -0,0 +1,43 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +// MOOSE includes +#include "ElementUserObject.h" +#include "Reporter.h" + +/** + */ +class ElementReporter : public ElementUserObject, public Reporter +{ +public: + static InputParameters validParams(); + + ElementReporter(const InputParameters & parameters); + + /** + * @returns Whether or not this Reporter should store its value at this specific time. + * + * If the private parameter '_always_store' is true, this will always return true. + * Otherwise, it will return true if the current execute flag matches a flag + * that this ElementReporter has in its 'execute_on' parameter. Otherwise, it will + * return false. + * + * This enables ElementReporter objects that do not fill information ahead of time in + * execute() but instead fill their information in the to_json implementation. + * Without this, said ElementReporters would always output their information even though + * the user requested that they do not execute on a specific flag. + */ + bool shouldStore() const override final; + +private: + /// Whether or not this ElementReporter should always store its information; see shouldStore() + const bool _always_store; +}; diff --git a/framework/include/reporters/ElementStatsReporter.h b/framework/include/reporters/ElementStatsReporter.h new file mode 100644 index 000000000000..b118a525a524 --- /dev/null +++ b/framework/include/reporters/ElementStatsReporter.h @@ -0,0 +1,36 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ElementReporter.h" + +class ElementStatsReporter : public ElementReporter +{ +public: + static InputParameters validParams(); + + ElementStatsReporter(const InputParameters & parameters); + +protected: + virtual void initialize() override; + virtual void execute() override; + virtual void finalize() override; + virtual void threadJoin(const UserObject & uo) override; + + virtual Real computeValue() = 0; + +private: + const std::string _base_name; + Real & _max; + Real & _min; + Real & _average; + Real & _integral; + int & _number_elements; +}; diff --git a/framework/include/reporters/NodalReporter.h b/framework/include/reporters/NodalReporter.h new file mode 100644 index 000000000000..c1e481edba7f --- /dev/null +++ b/framework/include/reporters/NodalReporter.h @@ -0,0 +1,43 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +// MOOSE includes +#include "NodalUserObject.h" +#include "Reporter.h" + +/** + */ +class NodalReporter : public NodalUserObject, public Reporter +{ +public: + static InputParameters validParams(); + + NodalReporter(const InputParameters & parameters); + + /** + * @returns Whether or not this Reporter should store its value at this specific time. + * + * If the private parameter '_always_store' is true, this will always return true. + * Otherwise, it will return true if the current execute flag matches a flag + * that this NodalReporter has in its 'execute_on' parameter. Otherwise, it will + * return false. + * + * This enables NodalReporter objects that do not fill information ahead of time in + * execute() but instead fill their information in the to_json implementation. + * Without this, said NodalReporters would always output their information even though + * the user requested that they do not execute on a specific flag. + */ + bool shouldStore() const override final; + +private: + /// Whether or not this NodalReporter should always store its information; see shouldStore() + const bool _always_store; +}; diff --git a/framework/include/reporters/NodalStatsReporter.h b/framework/include/reporters/NodalStatsReporter.h new file mode 100644 index 000000000000..a15700e65e38 --- /dev/null +++ b/framework/include/reporters/NodalStatsReporter.h @@ -0,0 +1,35 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "NodalReporter.h" + +class NodalStatsReporter : public NodalReporter +{ +public: + static InputParameters validParams(); + + NodalStatsReporter(const InputParameters & parameters); + +protected: + virtual void initialize() override; + virtual void execute() override; + virtual void finalize() override; + virtual void threadJoin(const UserObject & uo) override; + + virtual Real computeValue() = 0; + +private: + const std::string _base_name; + Real & _max; + Real & _min; + Real & _average; + int & _number_nodes; +}; diff --git a/framework/src/reporters/CoupledVarStatsElementReporter.C b/framework/src/reporters/CoupledVarStatsElementReporter.C new file mode 100644 index 000000000000..eccd69bf95c0 --- /dev/null +++ b/framework/src/reporters/CoupledVarStatsElementReporter.C @@ -0,0 +1,40 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "CoupledVarStatsElementReporter.h" + +registerMooseObject("MooseApp", CoupledVarStatsElementReporter); + +InputParameters +CoupledVarStatsElementReporter::validParams() +{ + InputParameters params = ElementStatsReporter::validParams(); + + params.addRequiredCoupledVar("coupled_var", "Coupled variable whose value is used."); + + params.addClassDescription("Element reporter to get statistics for a coupled variable. This can " + "be transfered to other apps."); + return params; +} + +CoupledVarStatsElementReporter::CoupledVarStatsElementReporter(const InputParameters & parameters) + : ElementStatsReporter(parameters), _v(coupledValue("coupled_var")) +{ +} +Real +CoupledVarStatsElementReporter::computeValue() +{ + Real avg_val = 0; + + for (unsigned int qp = 0; qp < _qrule->n_points(); ++qp) + avg_val += _v[qp] * _JxW[qp] * _coord[qp]; + avg_val /= _current_elem_volume; + + return avg_val; +} diff --git a/framework/src/reporters/CoupledVarStatsNodalReporter.C b/framework/src/reporters/CoupledVarStatsNodalReporter.C new file mode 100644 index 000000000000..84755a8d58d6 --- /dev/null +++ b/framework/src/reporters/CoupledVarStatsNodalReporter.C @@ -0,0 +1,34 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "CoupledVarStatsNodalReporter.h" + +registerMooseObject("MooseApp", CoupledVarStatsNodalReporter); + +InputParameters +CoupledVarStatsNodalReporter::validParams() +{ + InputParameters params = NodalStatsReporter::validParams(); + + params.addRequiredCoupledVar("coupled_var", "Coupled variable whose value is used."); + + params.addClassDescription("Nodal reporter to get statistics for a coupled variable. This can " + "be transfered to other apps."); + return params; +} + +CoupledVarStatsNodalReporter::CoupledVarStatsNodalReporter(const InputParameters & parameters) + : NodalStatsReporter(parameters), _v(coupledValue("coupled_var")) +{ +} +Real +CoupledVarStatsNodalReporter::computeValue() +{ + return _v[_qp]; +} diff --git a/framework/src/reporters/ElementReporter.C b/framework/src/reporters/ElementReporter.C new file mode 100644 index 000000000000..47ad04d7e451 --- /dev/null +++ b/framework/src/reporters/ElementReporter.C @@ -0,0 +1,36 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +// MOOSE includes +#include "ElementReporter.h" + +InputParameters +ElementReporter::validParams() +{ + InputParameters params = ElementUserObject::validParams(); + params += Reporter::validParams(); + // Whether or not to always store this object's value + // See the override for shouldStore() for more information + params.addPrivateParam("_always_store", true); + + return params; +} + +ElementReporter::ElementReporter(const InputParameters & parameters) + : ElementUserObject(parameters), Reporter(this), _always_store(getParam("_always_store")) +{ +} + +bool +ElementReporter::shouldStore() const +{ + // Either we always store, or we store if the current execution flag matches + // a flag that is within this ElementReporter's 'execute_on' + return _always_store || getExecuteOnEnum().contains(_fe_problem.getCurrentExecuteOnFlag()); +} diff --git a/framework/src/reporters/ElementStatsReporter.C b/framework/src/reporters/ElementStatsReporter.C new file mode 100644 index 000000000000..25dbc5f05981 --- /dev/null +++ b/framework/src/reporters/ElementStatsReporter.C @@ -0,0 +1,89 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ElementStatsReporter.h" + +#include "ElementReporter.h" +#include "libmesh/enum_eigen_solver_type.h" +#include +#include + +InputParameters +ElementStatsReporter::validParams() +{ + InputParameters params = ElementReporter::validParams(); + params.addParam("base_name", "Name to append to reporters."); + return params; +} + +ElementStatsReporter::ElementStatsReporter(const InputParameters & parameters) + : ElementReporter(parameters), + _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), + _max(declareValueByName(_base_name + "max")), + _min(declareValueByName(_base_name + "min")), + _average(declareValueByName(_base_name + "average")), + _integral(declareValueByName(_base_name + "integral")), + _number_elements(declareValueByName(_base_name + "number_elements")) +{ +} +void +ElementStatsReporter::initialize() +{ + _max = std::numeric_limits::min(); + _min = std::numeric_limits::max(); + _average = 0; + _integral = 0; + _number_elements = 0; +} + +void +ElementStatsReporter::execute() +{ + // Get value to to update statistics + Real value = computeValue(); + + if (_max < value) + _max = value; + + if (_min > value) + _min = value; + + _integral += value * _current_elem_volume; + + // Update the total and the number to get the average finalize + _average += value; + _number_elements++; +} +void +ElementStatsReporter::threadJoin(const UserObject & uo) +{ + const ElementStatsReporter & es = static_cast(uo); + if (_max < es._max) + _max = es._max; + + if (_min > es._min) + _min = es._min; + + _integral += es._integral; + + _average += es._average; + _number_elements += es._number_elements; +} +void +ElementStatsReporter::finalize() +{ + _communicator.max(_max); + _communicator.min(_min); + _communicator.sum(_integral); + _communicator.sum(_average); + _communicator.sum(_number_elements); + + // Compute the average; + _average /= _number_elements; +} diff --git a/framework/src/reporters/NodalReporter.C b/framework/src/reporters/NodalReporter.C new file mode 100644 index 000000000000..73eaf257cc79 --- /dev/null +++ b/framework/src/reporters/NodalReporter.C @@ -0,0 +1,36 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +// MOOSE includes +#include "NodalReporter.h" + +InputParameters +NodalReporter::validParams() +{ + InputParameters params = NodalUserObject::validParams(); + params += Reporter::validParams(); + // Whether or not to always store this object's value + // See the override for shouldStore() for more information + params.addPrivateParam("_always_store", true); + + return params; +} + +NodalReporter::NodalReporter(const InputParameters & parameters) + : NodalUserObject(parameters), Reporter(this), _always_store(getParam("_always_store")) +{ +} + +bool +NodalReporter::shouldStore() const +{ + // Either we always store, or we store if the current execution flag matches + // a flag that is within this NodalReporter's 'execute_on' + return _always_store || getExecuteOnEnum().contains(_fe_problem.getCurrentExecuteOnFlag()); +} diff --git a/framework/src/reporters/NodalStatsReporter.C b/framework/src/reporters/NodalStatsReporter.C new file mode 100644 index 000000000000..594958f176c8 --- /dev/null +++ b/framework/src/reporters/NodalStatsReporter.C @@ -0,0 +1,80 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "NodalStatsReporter.h" + +#include "NodalReporter.h" +#include + +InputParameters +NodalStatsReporter::validParams() +{ + InputParameters params = NodalReporter::validParams(); + params.addParam("base_name", "Name to append to reporters."); + return params; +} + +NodalStatsReporter::NodalStatsReporter(const InputParameters & parameters) + : NodalReporter(parameters), + _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), + _max(declareValueByName(_base_name + "max")), + _min(declareValueByName(_base_name + "min")), + _average(declareValueByName(_base_name + "average")), + _number_nodes(declareValueByName(_base_name + "number_nodes")) +{ +} +void +NodalStatsReporter::initialize() +{ + _max = std::numeric_limits::min(); + _min = std::numeric_limits::max(); + _average = 0; + _number_nodes = 0; +} + +void +NodalStatsReporter::execute() +{ + // Get value to to update statistics + Real value = computeValue(); + + if (_max < value) + _max = value; + + if (_min > value) + _min = value; + + // Update the total and the number to get the average finalize + _average += value; + _number_nodes++; +} +void +NodalStatsReporter::threadJoin(const UserObject & uo) +{ + const NodalStatsReporter & es = static_cast(uo); + if (_max < es._max) + _max = es._max; + + if (_min > es._min) + _min = es._min; + + _average += es._average; + _number_nodes += es._number_nodes; +} +void +NodalStatsReporter::finalize() +{ + _communicator.max(_max); + _communicator.min(_min); + _communicator.sum(_average); + _communicator.sum(_number_nodes); + + // Compute the average; + _average /= _number_nodes; +} diff --git a/test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i b/test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i new file mode 100644 index 000000000000..e1a10133ad30 --- /dev/null +++ b/test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i @@ -0,0 +1,57 @@ +[Mesh] + type = GeneratedMesh + dim = 2 + xmax = 2 + ymax = 2 + nx = 10 + ny = 10 +[] + +[Variables] + [u] + [] +[] + +[Kernels] + [diff] + type = Diffusion + variable = u + [] +[] + +[BCs] + [left] + type = DirichletBC + variable = u + boundary = left + value = 0 + [] + [right] + type = DirichletBC + variable = u + boundary = right + value = 1 + [] +[] + +[Reporters] + [elem_stats] + type = CoupledVarStatsElementReporter + coupled_var = u + base_name = diffusion + [] +[] + +[Executioner] + type = Steady + solve_type = Newton + petsc_options_iname = '-pc_type' + petsc_options_value = 'lu' +[] + +[Outputs] + [stats] + type = JSON + execute_system_information_on = none + [] +[] diff --git a/test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json b/test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json new file mode 100644 index 000000000000..144535eef5b0 --- /dev/null +++ b/test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json @@ -0,0 +1,48 @@ +{ + "reporters": { + "elem_stats": { + "type": "CoupledVarStatsElementReporter", + "values": { + "diffusion_average": { + "type": "double" + }, + "diffusion_integral": { + "type": "double" + }, + "diffusion_max": { + "type": "double" + }, + "diffusion_min": { + "type": "double" + }, + "diffusion_number_elements": { + "type": "int" + } + } + } + }, + "time_steps": [ + { + "elem_stats": { + "diffusion_average": 0.0, + "diffusion_integral": 0.0, + "diffusion_max": 0.0, + "diffusion_min": 0.0, + "diffusion_number_elements": 0 + }, + "time": 0.0, + "time_step": 0 + }, + { + "elem_stats": { + "diffusion_average": 0.5000000000057504, + "diffusion_integral": 2.0000000000230007, + "diffusion_max": 0.9500000000019394, + "diffusion_min": 0.050000000001400854, + "diffusion_number_elements": 100 + }, + "time": 1.0, + "time_step": 1 + } + ] +} diff --git a/test/tests/reporters/ele_nodal_reporters/element_reporter/tests b/test/tests/reporters/ele_nodal_reporters/element_reporter/tests new file mode 100644 index 000000000000..c42a2457fc0e --- /dev/null +++ b/test/tests/reporters/ele_nodal_reporters/element_reporter/tests @@ -0,0 +1,11 @@ +[Tests] + design = 'CoupledVarStatsElementReporter.md' + issues = '#24678' + + [coupledvarstats] + type = 'JSONDiff' + input = 'coupledvarstats.i' + jsondiff = 'coupledvarstats_stats.json' + requirement = 'The system shall be able to produce elememental statistics of a variable for use in other calculations.' + [] +[] diff --git a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i b/test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i new file mode 100644 index 000000000000..5f55fa084133 --- /dev/null +++ b/test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i @@ -0,0 +1,57 @@ +[Mesh] + type = GeneratedMesh + dim = 2 + xmax = 2 + ymax = 2 + nx = 10 + ny = 10 +[] + +[Variables] + [u] + [] +[] + +[Kernels] + [diff] + type = Diffusion + variable = u + [] +[] + +[BCs] + [left] + type = DirichletBC + variable = u + boundary = left + value = 0 + [] + [right] + type = DirichletBC + variable = u + boundary = right + value = 1 + [] +[] + +[Reporters] + [elem_stats] + type = CoupledVarStatsNodalReporter + coupled_var = u + base_name = diffusion + [] +[] + +[Executioner] + type = Steady + solve_type = Newton + petsc_options_iname = '-pc_type' + petsc_options_value = 'lu' +[] + +[Outputs] + [stats] + type = JSON + execute_system_information_on = none + [] +[] diff --git a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json b/test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json new file mode 100644 index 000000000000..d10d1ee78c7e --- /dev/null +++ b/test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json @@ -0,0 +1,43 @@ +{ + "reporters": { + "elem_stats": { + "type": "CoupledVarStatsNodalReporter", + "values": { + "diffusion_average": { + "type": "double" + }, + "diffusion_max": { + "type": "double" + }, + "diffusion_min": { + "type": "double" + }, + "diffusion_number_nodes": { + "type": "int" + } + } + } + }, + "time_steps": [ + { + "elem_stats": { + "diffusion_average": 0.0, + "diffusion_max": 0.0, + "diffusion_min": 0.0, + "diffusion_number_nodes": 0 + }, + "time": 0.0, + "time_step": 0 + }, + { + "elem_stats": { + "diffusion_average": 0.5, + "diffusion_max": 1.0, + "diffusion_min": 0.0, + "diffusion_number_nodes": 121 + }, + "time": 1.0, + "time_step": 1 + } + ] +} diff --git a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests b/test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests new file mode 100644 index 000000000000..bccb8f2589d6 --- /dev/null +++ b/test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests @@ -0,0 +1,11 @@ +[Tests] + design = 'CoupledVarStatsNodalReporter.md' + issues = '#24678' + + [coupledvarstats] + type = 'JSONDiff' + input = 'coupledvarstats.i' + jsondiff = 'coupledvarstats_stats.json' + requirement = 'The system shall be able to produce nodal statistics of a variable for use in other calculations.' + [] +[] From 6248ac1413b6bab4fd096918446fc92d1af23faa Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Thu, 15 Jun 2023 13:34:57 -0600 Subject: [PATCH 2/9] fix naming order of reporters --- .../reporters/CoupledVarStatsElementReporter.h | 4 ++-- .../reporters/CoupledVarStatsNodalReporter.h | 4 ++-- ...tStatsReporter.h => StatsElementReporter.h} | 4 ++-- ...dalStatsReporter.h => StatsNodalReporter.h} | 4 ++-- .../reporters/CoupledVarStatsElementReporter.C | 4 ++-- .../reporters/CoupledVarStatsNodalReporter.C | 4 ++-- ...tStatsReporter.C => StatsElementReporter.C} | 18 +++++++++--------- ...dalStatsReporter.C => StatsNodalReporter.C} | 18 +++++++++--------- 8 files changed, 30 insertions(+), 30 deletions(-) rename framework/include/reporters/{ElementStatsReporter.h => StatsElementReporter.h} (87%) rename framework/include/reporters/{NodalStatsReporter.h => StatsNodalReporter.h} (87%) rename framework/src/reporters/{ElementStatsReporter.C => StatsElementReporter.C} (80%) rename framework/src/reporters/{NodalStatsReporter.C => StatsNodalReporter.C} (79%) diff --git a/framework/include/reporters/CoupledVarStatsElementReporter.h b/framework/include/reporters/CoupledVarStatsElementReporter.h index e02943de814c..8c90eb0bed33 100644 --- a/framework/include/reporters/CoupledVarStatsElementReporter.h +++ b/framework/include/reporters/CoupledVarStatsElementReporter.h @@ -9,9 +9,9 @@ #pragma once -#include "ElementStatsReporter.h" +#include "StatsElementReporter.h" -class CoupledVarStatsElementReporter : public ElementStatsReporter +class CoupledVarStatsElementReporter : public StatsElementReporter { public: static InputParameters validParams(); diff --git a/framework/include/reporters/CoupledVarStatsNodalReporter.h b/framework/include/reporters/CoupledVarStatsNodalReporter.h index e6c81d12ac80..c08fab4ee101 100644 --- a/framework/include/reporters/CoupledVarStatsNodalReporter.h +++ b/framework/include/reporters/CoupledVarStatsNodalReporter.h @@ -9,9 +9,9 @@ #pragma once -#include "NodalStatsReporter.h" +#include "StatsNodalReporter.h" -class CoupledVarStatsNodalReporter : public NodalStatsReporter +class CoupledVarStatsNodalReporter : public StatsNodalReporter { public: static InputParameters validParams(); diff --git a/framework/include/reporters/ElementStatsReporter.h b/framework/include/reporters/StatsElementReporter.h similarity index 87% rename from framework/include/reporters/ElementStatsReporter.h rename to framework/include/reporters/StatsElementReporter.h index b118a525a524..034a1ef90f97 100644 --- a/framework/include/reporters/ElementStatsReporter.h +++ b/framework/include/reporters/StatsElementReporter.h @@ -11,12 +11,12 @@ #include "ElementReporter.h" -class ElementStatsReporter : public ElementReporter +class StatsElementReporter : public ElementReporter { public: static InputParameters validParams(); - ElementStatsReporter(const InputParameters & parameters); + StatsElementReporter(const InputParameters & parameters); protected: virtual void initialize() override; diff --git a/framework/include/reporters/NodalStatsReporter.h b/framework/include/reporters/StatsNodalReporter.h similarity index 87% rename from framework/include/reporters/NodalStatsReporter.h rename to framework/include/reporters/StatsNodalReporter.h index a15700e65e38..be10844d3550 100644 --- a/framework/include/reporters/NodalStatsReporter.h +++ b/framework/include/reporters/StatsNodalReporter.h @@ -11,12 +11,12 @@ #include "NodalReporter.h" -class NodalStatsReporter : public NodalReporter +class StatsNodalReporter : public NodalReporter { public: static InputParameters validParams(); - NodalStatsReporter(const InputParameters & parameters); + StatsNodalReporter(const InputParameters & parameters); protected: virtual void initialize() override; diff --git a/framework/src/reporters/CoupledVarStatsElementReporter.C b/framework/src/reporters/CoupledVarStatsElementReporter.C index eccd69bf95c0..e0e158561948 100644 --- a/framework/src/reporters/CoupledVarStatsElementReporter.C +++ b/framework/src/reporters/CoupledVarStatsElementReporter.C @@ -14,7 +14,7 @@ registerMooseObject("MooseApp", CoupledVarStatsElementReporter); InputParameters CoupledVarStatsElementReporter::validParams() { - InputParameters params = ElementStatsReporter::validParams(); + InputParameters params = StatsElementReporter::validParams(); params.addRequiredCoupledVar("coupled_var", "Coupled variable whose value is used."); @@ -24,7 +24,7 @@ CoupledVarStatsElementReporter::validParams() } CoupledVarStatsElementReporter::CoupledVarStatsElementReporter(const InputParameters & parameters) - : ElementStatsReporter(parameters), _v(coupledValue("coupled_var")) + : StatsElementReporter(parameters), _v(coupledValue("coupled_var")) { } Real diff --git a/framework/src/reporters/CoupledVarStatsNodalReporter.C b/framework/src/reporters/CoupledVarStatsNodalReporter.C index 84755a8d58d6..fc50324e662a 100644 --- a/framework/src/reporters/CoupledVarStatsNodalReporter.C +++ b/framework/src/reporters/CoupledVarStatsNodalReporter.C @@ -14,7 +14,7 @@ registerMooseObject("MooseApp", CoupledVarStatsNodalReporter); InputParameters CoupledVarStatsNodalReporter::validParams() { - InputParameters params = NodalStatsReporter::validParams(); + InputParameters params = StatsNodalReporter::validParams(); params.addRequiredCoupledVar("coupled_var", "Coupled variable whose value is used."); @@ -24,7 +24,7 @@ CoupledVarStatsNodalReporter::validParams() } CoupledVarStatsNodalReporter::CoupledVarStatsNodalReporter(const InputParameters & parameters) - : NodalStatsReporter(parameters), _v(coupledValue("coupled_var")) + : StatsNodalReporter(parameters), _v(coupledValue("coupled_var")) { } Real diff --git a/framework/src/reporters/ElementStatsReporter.C b/framework/src/reporters/StatsElementReporter.C similarity index 80% rename from framework/src/reporters/ElementStatsReporter.C rename to framework/src/reporters/StatsElementReporter.C index 25dbc5f05981..422e084b108f 100644 --- a/framework/src/reporters/ElementStatsReporter.C +++ b/framework/src/reporters/StatsElementReporter.C @@ -7,7 +7,7 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "ElementStatsReporter.h" +#include "StatsElementReporter.h" #include "ElementReporter.h" #include "libmesh/enum_eigen_solver_type.h" @@ -15,14 +15,14 @@ #include InputParameters -ElementStatsReporter::validParams() +StatsElementReporter::validParams() { InputParameters params = ElementReporter::validParams(); params.addParam("base_name", "Name to append to reporters."); return params; } -ElementStatsReporter::ElementStatsReporter(const InputParameters & parameters) +StatsElementReporter::StatsElementReporter(const InputParameters & parameters) : ElementReporter(parameters), _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), _max(declareValueByName(_base_name + "max")), @@ -33,7 +33,7 @@ ElementStatsReporter::ElementStatsReporter(const InputParameters & parameters) { } void -ElementStatsReporter::initialize() +StatsElementReporter::initialize() { _max = std::numeric_limits::min(); _min = std::numeric_limits::max(); @@ -43,7 +43,7 @@ ElementStatsReporter::initialize() } void -ElementStatsReporter::execute() +StatsElementReporter::execute() { // Get value to to update statistics Real value = computeValue(); @@ -56,14 +56,14 @@ ElementStatsReporter::execute() _integral += value * _current_elem_volume; - // Update the total and the number to get the average finalize + // Update the total and the number to get the average when "finalizing" _average += value; _number_elements++; } void -ElementStatsReporter::threadJoin(const UserObject & uo) +StatsElementReporter::threadJoin(const UserObject & uo) { - const ElementStatsReporter & es = static_cast(uo); + const StatsElementReporter & es = static_cast(uo); if (_max < es._max) _max = es._max; @@ -76,7 +76,7 @@ ElementStatsReporter::threadJoin(const UserObject & uo) _number_elements += es._number_elements; } void -ElementStatsReporter::finalize() +StatsElementReporter::finalize() { _communicator.max(_max); _communicator.min(_min); diff --git a/framework/src/reporters/NodalStatsReporter.C b/framework/src/reporters/StatsNodalReporter.C similarity index 79% rename from framework/src/reporters/NodalStatsReporter.C rename to framework/src/reporters/StatsNodalReporter.C index 594958f176c8..b890a266b872 100644 --- a/framework/src/reporters/NodalStatsReporter.C +++ b/framework/src/reporters/StatsNodalReporter.C @@ -7,20 +7,20 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "NodalStatsReporter.h" +#include "StatsNodalReporter.h" #include "NodalReporter.h" #include InputParameters -NodalStatsReporter::validParams() +StatsNodalReporter::validParams() { InputParameters params = NodalReporter::validParams(); params.addParam("base_name", "Name to append to reporters."); return params; } -NodalStatsReporter::NodalStatsReporter(const InputParameters & parameters) +StatsNodalReporter::StatsNodalReporter(const InputParameters & parameters) : NodalReporter(parameters), _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), _max(declareValueByName(_base_name + "max")), @@ -30,7 +30,7 @@ NodalStatsReporter::NodalStatsReporter(const InputParameters & parameters) { } void -NodalStatsReporter::initialize() +StatsNodalReporter::initialize() { _max = std::numeric_limits::min(); _min = std::numeric_limits::max(); @@ -39,7 +39,7 @@ NodalStatsReporter::initialize() } void -NodalStatsReporter::execute() +StatsNodalReporter::execute() { // Get value to to update statistics Real value = computeValue(); @@ -50,14 +50,14 @@ NodalStatsReporter::execute() if (_min > value) _min = value; - // Update the total and the number to get the average finalize + // Update the total and the number to get the average when "finalizing" _average += value; _number_nodes++; } void -NodalStatsReporter::threadJoin(const UserObject & uo) +StatsNodalReporter::threadJoin(const UserObject & uo) { - const NodalStatsReporter & es = static_cast(uo); + const StatsNodalReporter & es = static_cast(uo); if (_max < es._max) _max = es._max; @@ -68,7 +68,7 @@ NodalStatsReporter::threadJoin(const UserObject & uo) _number_nodes += es._number_nodes; } void -NodalStatsReporter::finalize() +StatsNodalReporter::finalize() { _communicator.max(_max); _communicator.min(_min); From f089adbabc58a047d1bbfc4fbe34456b689db093 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Tue, 20 Jun 2023 10:30:59 -0600 Subject: [PATCH 3/9] adress review & no threading for reporters --- .../CoupledVarStatsElementReporter.md | 23 -------------- .../reporters/CoupledVarStatsNodalReporter.md | 23 -------------- .../reporters/ElementVariableStatistics.md | 23 ++++++++++++++ .../reporters/NodalVariableStatistics.md | 23 ++++++++++++++ ...sElementReporter.h => ElementStatistics.h} | 6 ++-- ...Reporter.h => ElementVariableStatistics.h} | 6 ++-- ...StatsNodalReporter.h => NodalStatistics.h} | 6 ++-- ...ntReporter.h => NodalVariableStatistics.h} | 6 ++-- ...sElementReporter.C => ElementStatistics.C} | 31 ++++--------------- ...Reporter.C => ElementVariableStatistics.C} | 14 ++++----- ...StatsNodalReporter.C => NodalStatistics.C} | 27 ++++------------ ...alReporter.C => NodalVariableStatistics.C} | 14 ++++----- .../elem_stats.i} | 2 +- .../gold/elem_stats_stats.json} | 10 +++--- .../element_reporter/tests | 8 ++--- .../gold/nodal_stats_stats.json} | 2 +- .../nodal_stats.i} | 2 +- .../nodal_reporter/tests | 8 ++--- 18 files changed, 100 insertions(+), 134 deletions(-) delete mode 100644 framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md delete mode 100644 framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md create mode 100644 framework/doc/content/source/reporters/ElementVariableStatistics.md create mode 100644 framework/doc/content/source/reporters/NodalVariableStatistics.md rename framework/include/reporters/{StatsElementReporter.h => ElementStatistics.h} (80%) rename framework/include/reporters/{CoupledVarStatsNodalReporter.h => ElementVariableStatistics.h} (74%) rename framework/include/reporters/{StatsNodalReporter.h => NodalStatistics.h} (80%) rename framework/include/reporters/{CoupledVarStatsElementReporter.h => NodalVariableStatistics.h} (74%) rename framework/src/reporters/{StatsElementReporter.C => ElementStatistics.C} (70%) rename framework/src/reporters/{CoupledVarStatsElementReporter.C => ElementVariableStatistics.C} (64%) rename framework/src/reporters/{StatsNodalReporter.C => NodalStatistics.C} (71%) rename framework/src/reporters/{CoupledVarStatsNodalReporter.C => NodalVariableStatistics.C} (60%) rename test/tests/reporters/{ele_nodal_reporters/nodal_reporter/coupledvarstats.i => element_reporter/elem_stats.i} (94%) rename test/tests/reporters/{ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json => element_reporter/gold/elem_stats_stats.json} (79%) rename test/tests/reporters/{ele_nodal_reporters => }/element_reporter/tests (56%) rename test/tests/reporters/{ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json => nodal_reporter/gold/nodal_stats_stats.json} (95%) rename test/tests/reporters/{ele_nodal_reporters/element_reporter/coupledvarstats.i => nodal_reporter/nodal_stats.i} (93%) rename test/tests/reporters/{ele_nodal_reporters => }/nodal_reporter/tests (55%) diff --git a/framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md b/framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md deleted file mode 100644 index 229e3fe6aa66..000000000000 --- a/framework/doc/content/source/reporters/CoupledVarStatsElementReporter.md +++ /dev/null @@ -1,23 +0,0 @@ -# CoupledVarStatsElementReporter - -!syntax description /Reporters/CoupledVarStatsElementReporter - -## Overview - -CoupledVarStatsElementReporter produces the following statistics for a -variable: Maximum, Minium, Average, Integral, Total Elements. The -[!param](/Reporters/CoupledVarStatsElementReporter/base_name) can be used to prepend a -name to each reporter. - - - -## Example Input File Syntax - -!listing ele_nodal_reporters/element_reporter/coupledvarstats.i block=elem_stats - indent=2 header=[Reporters] footer=[] - -!syntax parameters /Reporters/CoupledVarStatsElementReporter - -!syntax inputs /Reporters/CoupledVarStatsElementReporter - -!syntax children /Reporters/CoupledVarStatsElementReporter diff --git a/framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md b/framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md deleted file mode 100644 index d91705b762a8..000000000000 --- a/framework/doc/content/source/reporters/CoupledVarStatsNodalReporter.md +++ /dev/null @@ -1,23 +0,0 @@ -# CoupledVarStatsNodalReporter - -!syntax description /Reporters/CoupledVarStatsNodalReporter - -## Overview - -CoupledVarStatsNodalReporter produces the following statistics for a -variable: Maximum, Minium, Average, Total Nodes. The -[!param](/Reporters/CoupledVarStatsNodalReporter/base_name) can be used to prepend a -name to each reporter. - - - -## Example Input File Syntax - -!listing ele_nodal_reporters/nodal_reporter/coupledvarstats.i block=elem_stats - indent=2 header=[Reporters] footer=[] - -!syntax parameters /Reporters/CoupledVarStatsNodalReporter - -!syntax inputs /Reporters/CoupledVarStatsNodalReporter - -!syntax children /Reporters/CoupledVarStatsNodalReporter diff --git a/framework/doc/content/source/reporters/ElementVariableStatistics.md b/framework/doc/content/source/reporters/ElementVariableStatistics.md new file mode 100644 index 000000000000..0d8bc54f85b6 --- /dev/null +++ b/framework/doc/content/source/reporters/ElementVariableStatistics.md @@ -0,0 +1,23 @@ +# ElementVariableStatistics + +!syntax description /Reporters/ElementVariableStatistics + +## Overview + +ElementVariableStatistics produces the following statistics for a +variable: Maximum, Minium, Average, Integral, Total Elements. The +[!param](/Reporters/ElementVariableStatistics/base_name) can be used to prepend a +name to each reporter. + + + +## Example Input File Syntax + +!listing element_reporter/elem_stats.i block=elem_stats + indent=2 header=[Reporters] footer=[] + +!syntax parameters /Reporters/ElementVariableStatistics + +!syntax inputs /Reporters/ElementVariableStatistics + +!syntax children /Reporters/ElementVariableStatistics diff --git a/framework/doc/content/source/reporters/NodalVariableStatistics.md b/framework/doc/content/source/reporters/NodalVariableStatistics.md new file mode 100644 index 000000000000..8d9189ce7247 --- /dev/null +++ b/framework/doc/content/source/reporters/NodalVariableStatistics.md @@ -0,0 +1,23 @@ +# NodalVariableStatistics + +!syntax description /Reporters/NodalVariableStatistics + +## Overview + +NodalVariableStatistics produces the following statistics for a +variable: Maximum, Minium, Average, Total Nodes. The +[!param](/Reporters/NodalVariableStatistics/base_name) can be used to prepend a +name to each reporter. + + + +## Example Input File Syntax + +!listing nodal_reporter/nodal_stats.i block=elem_stats + indent=2 header=[Reporters] footer=[] + +!syntax parameters /Reporters/NodalVariableStatistics + +!syntax inputs /Reporters/NodalVariableStatistics + +!syntax children /Reporters/NodalVariableStatistics diff --git a/framework/include/reporters/StatsElementReporter.h b/framework/include/reporters/ElementStatistics.h similarity index 80% rename from framework/include/reporters/StatsElementReporter.h rename to framework/include/reporters/ElementStatistics.h index 034a1ef90f97..3e2b9a798752 100644 --- a/framework/include/reporters/StatsElementReporter.h +++ b/framework/include/reporters/ElementStatistics.h @@ -11,18 +11,18 @@ #include "ElementReporter.h" -class StatsElementReporter : public ElementReporter +class ElementStatistics : public ElementReporter { public: static InputParameters validParams(); - StatsElementReporter(const InputParameters & parameters); + ElementStatistics(const InputParameters & parameters); protected: virtual void initialize() override; virtual void execute() override; virtual void finalize() override; - virtual void threadJoin(const UserObject & uo) override; + virtual void threadJoin(const UserObject & /*uo*/) override final{}; virtual Real computeValue() = 0; diff --git a/framework/include/reporters/CoupledVarStatsNodalReporter.h b/framework/include/reporters/ElementVariableStatistics.h similarity index 74% rename from framework/include/reporters/CoupledVarStatsNodalReporter.h rename to framework/include/reporters/ElementVariableStatistics.h index c08fab4ee101..1a762b9afa5d 100644 --- a/framework/include/reporters/CoupledVarStatsNodalReporter.h +++ b/framework/include/reporters/ElementVariableStatistics.h @@ -9,14 +9,14 @@ #pragma once -#include "StatsNodalReporter.h" +#include "ElementStatistics.h" -class CoupledVarStatsNodalReporter : public StatsNodalReporter +class ElementVariableStatistics : public ElementStatistics { public: static InputParameters validParams(); - CoupledVarStatsNodalReporter(const InputParameters & parameters); + ElementVariableStatistics(const InputParameters & parameters); private: /// The coupled variable used. diff --git a/framework/include/reporters/StatsNodalReporter.h b/framework/include/reporters/NodalStatistics.h similarity index 80% rename from framework/include/reporters/StatsNodalReporter.h rename to framework/include/reporters/NodalStatistics.h index be10844d3550..66044a8f287b 100644 --- a/framework/include/reporters/StatsNodalReporter.h +++ b/framework/include/reporters/NodalStatistics.h @@ -11,18 +11,18 @@ #include "NodalReporter.h" -class StatsNodalReporter : public NodalReporter +class NodalStatistics : public NodalReporter { public: static InputParameters validParams(); - StatsNodalReporter(const InputParameters & parameters); + NodalStatistics(const InputParameters & parameters); protected: virtual void initialize() override; virtual void execute() override; virtual void finalize() override; - virtual void threadJoin(const UserObject & uo) override; + virtual void threadJoin(const UserObject & /*uo*/) override final{}; virtual Real computeValue() = 0; diff --git a/framework/include/reporters/CoupledVarStatsElementReporter.h b/framework/include/reporters/NodalVariableStatistics.h similarity index 74% rename from framework/include/reporters/CoupledVarStatsElementReporter.h rename to framework/include/reporters/NodalVariableStatistics.h index 8c90eb0bed33..3cea2020ba90 100644 --- a/framework/include/reporters/CoupledVarStatsElementReporter.h +++ b/framework/include/reporters/NodalVariableStatistics.h @@ -9,14 +9,14 @@ #pragma once -#include "StatsElementReporter.h" +#include "NodalStatistics.h" -class CoupledVarStatsElementReporter : public StatsElementReporter +class NodalVariableStatistics : public NodalStatistics { public: static InputParameters validParams(); - CoupledVarStatsElementReporter(const InputParameters & parameters); + NodalVariableStatistics(const InputParameters & parameters); private: /// The coupled variable used. diff --git a/framework/src/reporters/StatsElementReporter.C b/framework/src/reporters/ElementStatistics.C similarity index 70% rename from framework/src/reporters/StatsElementReporter.C rename to framework/src/reporters/ElementStatistics.C index 422e084b108f..48e60ad52328 100644 --- a/framework/src/reporters/StatsElementReporter.C +++ b/framework/src/reporters/ElementStatistics.C @@ -7,22 +7,17 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "StatsElementReporter.h" - -#include "ElementReporter.h" -#include "libmesh/enum_eigen_solver_type.h" -#include -#include +#include "ElementStatistics.h" InputParameters -StatsElementReporter::validParams() +ElementStatistics::validParams() { InputParameters params = ElementReporter::validParams(); params.addParam("base_name", "Name to append to reporters."); return params; } -StatsElementReporter::StatsElementReporter(const InputParameters & parameters) +ElementStatistics::ElementStatistics(const InputParameters & parameters) : ElementReporter(parameters), _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), _max(declareValueByName(_base_name + "max")), @@ -33,7 +28,7 @@ StatsElementReporter::StatsElementReporter(const InputParameters & parameters) { } void -StatsElementReporter::initialize() +ElementStatistics::initialize() { _max = std::numeric_limits::min(); _min = std::numeric_limits::max(); @@ -43,7 +38,7 @@ StatsElementReporter::initialize() } void -StatsElementReporter::execute() +ElementStatistics::execute() { // Get value to to update statistics Real value = computeValue(); @@ -60,23 +55,9 @@ StatsElementReporter::execute() _average += value; _number_elements++; } -void -StatsElementReporter::threadJoin(const UserObject & uo) -{ - const StatsElementReporter & es = static_cast(uo); - if (_max < es._max) - _max = es._max; - if (_min > es._min) - _min = es._min; - - _integral += es._integral; - - _average += es._average; - _number_elements += es._number_elements; -} void -StatsElementReporter::finalize() +ElementStatistics::finalize() { _communicator.max(_max); _communicator.min(_min); diff --git a/framework/src/reporters/CoupledVarStatsElementReporter.C b/framework/src/reporters/ElementVariableStatistics.C similarity index 64% rename from framework/src/reporters/CoupledVarStatsElementReporter.C rename to framework/src/reporters/ElementVariableStatistics.C index e0e158561948..a84e72d29797 100644 --- a/framework/src/reporters/CoupledVarStatsElementReporter.C +++ b/framework/src/reporters/ElementVariableStatistics.C @@ -7,14 +7,14 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "CoupledVarStatsElementReporter.h" +#include "ElementVariableStatistics.h" -registerMooseObject("MooseApp", CoupledVarStatsElementReporter); +registerMooseObject("MooseApp", ElementVariableStatistics); InputParameters -CoupledVarStatsElementReporter::validParams() +ElementVariableStatistics::validParams() { - InputParameters params = StatsElementReporter::validParams(); + InputParameters params = ElementStatistics::validParams(); params.addRequiredCoupledVar("coupled_var", "Coupled variable whose value is used."); @@ -23,12 +23,12 @@ CoupledVarStatsElementReporter::validParams() return params; } -CoupledVarStatsElementReporter::CoupledVarStatsElementReporter(const InputParameters & parameters) - : StatsElementReporter(parameters), _v(coupledValue("coupled_var")) +ElementVariableStatistics::ElementVariableStatistics(const InputParameters & parameters) + : ElementStatistics(parameters), _v(coupledValue("coupled_var")) { } Real -CoupledVarStatsElementReporter::computeValue() +ElementVariableStatistics::computeValue() { Real avg_val = 0; diff --git a/framework/src/reporters/StatsNodalReporter.C b/framework/src/reporters/NodalStatistics.C similarity index 71% rename from framework/src/reporters/StatsNodalReporter.C rename to framework/src/reporters/NodalStatistics.C index b890a266b872..cb4c0654b28a 100644 --- a/framework/src/reporters/StatsNodalReporter.C +++ b/framework/src/reporters/NodalStatistics.C @@ -7,20 +7,17 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "StatsNodalReporter.h" - -#include "NodalReporter.h" -#include +#include "NodalStatistics.h" InputParameters -StatsNodalReporter::validParams() +NodalStatistics::validParams() { InputParameters params = NodalReporter::validParams(); params.addParam("base_name", "Name to append to reporters."); return params; } -StatsNodalReporter::StatsNodalReporter(const InputParameters & parameters) +NodalStatistics::NodalStatistics(const InputParameters & parameters) : NodalReporter(parameters), _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), _max(declareValueByName(_base_name + "max")), @@ -30,7 +27,7 @@ StatsNodalReporter::StatsNodalReporter(const InputParameters & parameters) { } void -StatsNodalReporter::initialize() +NodalStatistics::initialize() { _max = std::numeric_limits::min(); _min = std::numeric_limits::max(); @@ -39,7 +36,7 @@ StatsNodalReporter::initialize() } void -StatsNodalReporter::execute() +NodalStatistics::execute() { // Get value to to update statistics Real value = computeValue(); @@ -54,21 +51,9 @@ StatsNodalReporter::execute() _average += value; _number_nodes++; } -void -StatsNodalReporter::threadJoin(const UserObject & uo) -{ - const StatsNodalReporter & es = static_cast(uo); - if (_max < es._max) - _max = es._max; - if (_min > es._min) - _min = es._min; - - _average += es._average; - _number_nodes += es._number_nodes; -} void -StatsNodalReporter::finalize() +NodalStatistics::finalize() { _communicator.max(_max); _communicator.min(_min); diff --git a/framework/src/reporters/CoupledVarStatsNodalReporter.C b/framework/src/reporters/NodalVariableStatistics.C similarity index 60% rename from framework/src/reporters/CoupledVarStatsNodalReporter.C rename to framework/src/reporters/NodalVariableStatistics.C index fc50324e662a..e7290559811b 100644 --- a/framework/src/reporters/CoupledVarStatsNodalReporter.C +++ b/framework/src/reporters/NodalVariableStatistics.C @@ -7,14 +7,14 @@ //* Licensed under LGPL 2.1, please see LICENSE for details //* https://www.gnu.org/licenses/lgpl-2.1.html -#include "CoupledVarStatsNodalReporter.h" +#include "NodalVariableStatistics.h" -registerMooseObject("MooseApp", CoupledVarStatsNodalReporter); +registerMooseObject("MooseApp", NodalVariableStatistics); InputParameters -CoupledVarStatsNodalReporter::validParams() +NodalVariableStatistics::validParams() { - InputParameters params = StatsNodalReporter::validParams(); + InputParameters params = NodalStatistics::validParams(); params.addRequiredCoupledVar("coupled_var", "Coupled variable whose value is used."); @@ -23,12 +23,12 @@ CoupledVarStatsNodalReporter::validParams() return params; } -CoupledVarStatsNodalReporter::CoupledVarStatsNodalReporter(const InputParameters & parameters) - : StatsNodalReporter(parameters), _v(coupledValue("coupled_var")) +NodalVariableStatistics::NodalVariableStatistics(const InputParameters & parameters) + : NodalStatistics(parameters), _v(coupledValue("coupled_var")) { } Real -CoupledVarStatsNodalReporter::computeValue() +NodalVariableStatistics::computeValue() { return _v[_qp]; } diff --git a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i b/test/tests/reporters/element_reporter/elem_stats.i similarity index 94% rename from test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i rename to test/tests/reporters/element_reporter/elem_stats.i index 5f55fa084133..9da37d906b40 100644 --- a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/coupledvarstats.i +++ b/test/tests/reporters/element_reporter/elem_stats.i @@ -36,7 +36,7 @@ [Reporters] [elem_stats] - type = CoupledVarStatsNodalReporter + type = ElementVariableStatistics coupled_var = u base_name = diffusion [] diff --git a/test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json b/test/tests/reporters/element_reporter/gold/elem_stats_stats.json similarity index 79% rename from test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json rename to test/tests/reporters/element_reporter/gold/elem_stats_stats.json index 144535eef5b0..d743cd705430 100644 --- a/test/tests/reporters/ele_nodal_reporters/element_reporter/gold/coupledvarstats_stats.json +++ b/test/tests/reporters/element_reporter/gold/elem_stats_stats.json @@ -1,7 +1,7 @@ { "reporters": { "elem_stats": { - "type": "CoupledVarStatsElementReporter", + "type": "ElementVariableStatistics", "values": { "diffusion_average": { "type": "double" @@ -35,10 +35,10 @@ }, { "elem_stats": { - "diffusion_average": 0.5000000000057504, - "diffusion_integral": 2.0000000000230007, - "diffusion_max": 0.9500000000019394, - "diffusion_min": 0.050000000001400854, + "diffusion_average": 0.5000000000000001, + "diffusion_integral": 2.0000000000000013, + "diffusion_max": 0.9500000000000004, + "diffusion_min": 0.049999999999999996, "diffusion_number_elements": 100 }, "time": 1.0, diff --git a/test/tests/reporters/ele_nodal_reporters/element_reporter/tests b/test/tests/reporters/element_reporter/tests similarity index 56% rename from test/tests/reporters/ele_nodal_reporters/element_reporter/tests rename to test/tests/reporters/element_reporter/tests index c42a2457fc0e..e92f6739eb73 100644 --- a/test/tests/reporters/ele_nodal_reporters/element_reporter/tests +++ b/test/tests/reporters/element_reporter/tests @@ -1,11 +1,11 @@ [Tests] - design = 'CoupledVarStatsElementReporter.md' + design = 'ElementVariableStatistics.md' issues = '#24678' - [coupledvarstats] + [elem_stats] type = 'JSONDiff' - input = 'coupledvarstats.i' - jsondiff = 'coupledvarstats_stats.json' + input = 'elem_stats.i' + jsondiff = 'elem_stats_stats.json' requirement = 'The system shall be able to produce elememental statistics of a variable for use in other calculations.' [] [] diff --git a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json b/test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json similarity index 95% rename from test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json rename to test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json index d10d1ee78c7e..8565e563afcd 100644 --- a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/gold/coupledvarstats_stats.json +++ b/test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json @@ -1,7 +1,7 @@ { "reporters": { "elem_stats": { - "type": "CoupledVarStatsNodalReporter", + "type": "NodalVariableStatistics", "values": { "diffusion_average": { "type": "double" diff --git a/test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i b/test/tests/reporters/nodal_reporter/nodal_stats.i similarity index 93% rename from test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i rename to test/tests/reporters/nodal_reporter/nodal_stats.i index e1a10133ad30..d1a9552eaea4 100644 --- a/test/tests/reporters/ele_nodal_reporters/element_reporter/coupledvarstats.i +++ b/test/tests/reporters/nodal_reporter/nodal_stats.i @@ -36,7 +36,7 @@ [Reporters] [elem_stats] - type = CoupledVarStatsElementReporter + type = NodalVariableStatistics coupled_var = u base_name = diffusion [] diff --git a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests b/test/tests/reporters/nodal_reporter/tests similarity index 55% rename from test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests rename to test/tests/reporters/nodal_reporter/tests index bccb8f2589d6..f4068e3e6b13 100644 --- a/test/tests/reporters/ele_nodal_reporters/nodal_reporter/tests +++ b/test/tests/reporters/nodal_reporter/tests @@ -1,11 +1,11 @@ [Tests] - design = 'CoupledVarStatsNodalReporter.md' + design = 'NodalVariableStatistics.md' issues = '#24678' - [coupledvarstats] + [nodal_stats] type = 'JSONDiff' - input = 'coupledvarstats.i' - jsondiff = 'coupledvarstats_stats.json' + input = 'nodal_stats.i' + jsondiff = 'nodal_stats_stats.json' requirement = 'The system shall be able to produce nodal statistics of a variable for use in other calculations.' [] [] From 0aa30e8041a39315c6b8755e8e7fa36707545ef9 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Mon, 26 Jun 2023 11:37:13 -0600 Subject: [PATCH 4/9] fix threading issue with reporters --- framework/include/reporters/ElementStatistics.h | 2 +- framework/include/reporters/NodalStatistics.h | 3 +-- framework/include/reporters/Reporter.h | 8 ++++++++ framework/src/outputs/JSONOutput.C | 4 ++-- framework/src/reporters/ElementStatistics.C | 11 +++++++++++ framework/src/reporters/NodalStatistics.C | 10 ++++++++++ .../nodal_reporter/gold/nodal_stats_stats.json | 6 +++--- test/tests/reporters/nodal_reporter/nodal_stats.i | 2 +- 8 files changed, 37 insertions(+), 9 deletions(-) diff --git a/framework/include/reporters/ElementStatistics.h b/framework/include/reporters/ElementStatistics.h index 3e2b9a798752..666a29f8e957 100644 --- a/framework/include/reporters/ElementStatistics.h +++ b/framework/include/reporters/ElementStatistics.h @@ -21,8 +21,8 @@ class ElementStatistics : public ElementReporter protected: virtual void initialize() override; virtual void execute() override; + virtual void threadJoin(const UserObject &) override; virtual void finalize() override; - virtual void threadJoin(const UserObject & /*uo*/) override final{}; virtual Real computeValue() = 0; diff --git a/framework/include/reporters/NodalStatistics.h b/framework/include/reporters/NodalStatistics.h index 66044a8f287b..68c92550276a 100644 --- a/framework/include/reporters/NodalStatistics.h +++ b/framework/include/reporters/NodalStatistics.h @@ -22,8 +22,7 @@ class NodalStatistics : public NodalReporter virtual void initialize() override; virtual void execute() override; virtual void finalize() override; - virtual void threadJoin(const UserObject & /*uo*/) override final{}; - + virtual void threadJoin(const UserObject &) override; virtual Real computeValue() = 0; private: diff --git a/framework/include/reporters/Reporter.h b/framework/include/reporters/Reporter.h index b1bb78d0b464..5126438ab321 100644 --- a/framework/include/reporters/Reporter.h +++ b/framework/include/reporters/Reporter.h @@ -10,6 +10,7 @@ #pragma once // Moose includes +#include "MooseTypes.h" #include "OutputInterface.h" #include "ReporterData.h" #include "InputParameters.h" @@ -243,6 +244,13 @@ Reporter::declareValueByName(const ReporterValueName & value_name, buildOutputHideVariableList({state_name.getCombinedName()}); + // Only thread 0 will declare the reporter value. The rest will get a reference + // to an UnusedValue + const THREAD_ID tid = _reporter_moose_object.parameters().isParamValid("_tid") + ? _reporter_moose_object.parameters().get("_tid") + : 0; + if (tid) + return declareUnusedValue(); return _reporter_data.declareReporterValue( state_name, mode, _reporter_moose_object, args...); } diff --git a/framework/src/outputs/JSONOutput.C b/framework/src/outputs/JSONOutput.C index c8b1aab0a417..6f834f929654 100644 --- a/framework/src/outputs/JSONOutput.C +++ b/framework/src/outputs/JSONOutput.C @@ -142,9 +142,9 @@ JSONOutput::outputReporters() .attributes(); auto qid = _problem_ptr->theWarehouse().queryID(attr); _problem_ptr->theWarehouse().queryInto(qid, objs, true); - mooseAssert(objs.size() <= 1, - "Multiple Reporter objects with the same name located, how did you do that?"); + // There can now be multiple reporter objects with the same name, but + // there will only be one reporter that stores all the data. if (!objs.empty()) { auto & reporter = *objs.front(); diff --git a/framework/src/reporters/ElementStatistics.C b/framework/src/reporters/ElementStatistics.C index 48e60ad52328..a44166cc52c4 100644 --- a/framework/src/reporters/ElementStatistics.C +++ b/framework/src/reporters/ElementStatistics.C @@ -56,6 +56,17 @@ ElementStatistics::execute() _number_elements++; } +void +ElementStatistics::threadJoin(const UserObject & uo) +{ + const ElementStatistics & ele_uo = static_cast(uo); + _max = std::max(_max, ele_uo._max); + _min = std::min(_min, ele_uo._min); + _integral += ele_uo._integral; + _average += ele_uo._average; + _number_elements += ele_uo._number_elements; +} + void ElementStatistics::finalize() { diff --git a/framework/src/reporters/NodalStatistics.C b/framework/src/reporters/NodalStatistics.C index cb4c0654b28a..ac8e126be98e 100644 --- a/framework/src/reporters/NodalStatistics.C +++ b/framework/src/reporters/NodalStatistics.C @@ -52,6 +52,16 @@ NodalStatistics::execute() _number_nodes++; } +void +NodalStatistics::threadJoin(const UserObject & uo) +{ + const NodalStatistics & node_uo = static_cast(uo); + _max = std::max(_max, node_uo._max); + _min = std::min(_min, node_uo._min); + _average += node_uo._average; + _number_nodes += node_uo._number_nodes; +} + void NodalStatistics::finalize() { diff --git a/test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json b/test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json index 8565e563afcd..7c3c153c9516 100644 --- a/test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json +++ b/test/tests/reporters/nodal_reporter/gold/nodal_stats_stats.json @@ -1,6 +1,6 @@ { "reporters": { - "elem_stats": { + "nodal_stats": { "type": "NodalVariableStatistics", "values": { "diffusion_average": { @@ -20,7 +20,7 @@ }, "time_steps": [ { - "elem_stats": { + "nodal_stats": { "diffusion_average": 0.0, "diffusion_max": 0.0, "diffusion_min": 0.0, @@ -30,7 +30,7 @@ "time_step": 0 }, { - "elem_stats": { + "nodal_stats": { "diffusion_average": 0.5, "diffusion_max": 1.0, "diffusion_min": 0.0, diff --git a/test/tests/reporters/nodal_reporter/nodal_stats.i b/test/tests/reporters/nodal_reporter/nodal_stats.i index d1a9552eaea4..0d12323ee386 100644 --- a/test/tests/reporters/nodal_reporter/nodal_stats.i +++ b/test/tests/reporters/nodal_reporter/nodal_stats.i @@ -35,7 +35,7 @@ [] [Reporters] - [elem_stats] + [nodal_stats] type = NodalVariableStatistics coupled_var = u base_name = diffusion From ff58872a2ccc044e8dc3d3f9e58db531f562f7bd Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Mon, 26 Jun 2023 12:37:58 -0600 Subject: [PATCH 5/9] update nodalvariablestatistics docs --- .../doc/content/source/reporters/NodalVariableStatistics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/doc/content/source/reporters/NodalVariableStatistics.md b/framework/doc/content/source/reporters/NodalVariableStatistics.md index 8d9189ce7247..f19bb373ff5a 100644 --- a/framework/doc/content/source/reporters/NodalVariableStatistics.md +++ b/framework/doc/content/source/reporters/NodalVariableStatistics.md @@ -13,7 +13,7 @@ name to each reporter. ## Example Input File Syntax -!listing nodal_reporter/nodal_stats.i block=elem_stats +!listing nodal_reporter/nodal_stats.i block=nodal_stats indent=2 header=[Reporters] footer=[] !syntax parameters /Reporters/NodalVariableStatistics From 2870fc369219b375945924235643fb3ef025a5fd Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Tue, 27 Jun 2023 12:55:12 -0600 Subject: [PATCH 6/9] Apply suggestions from code review and fix formatting Co-authored-by: Zachary Prince --- .../include/reporters/NodalVariableStatistics.h | 5 +++-- framework/src/reporters/ElementStatistics.C | 1 + .../src/reporters/ElementVariableStatistics.C | 1 + framework/src/reporters/NodalStatistics.C | 1 + framework/src/reporters/NodalVariableStatistics.C | 1 + test/tests/reporters/element_reporter/elem_stats.i | 14 ++++++++------ test/tests/reporters/nodal_reporter/nodal_stats.i | 14 ++++++++------ 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/framework/include/reporters/NodalVariableStatistics.h b/framework/include/reporters/NodalVariableStatistics.h index 3cea2020ba90..9930047b6c41 100644 --- a/framework/include/reporters/NodalVariableStatistics.h +++ b/framework/include/reporters/NodalVariableStatistics.h @@ -19,7 +19,8 @@ class NodalVariableStatistics : public NodalStatistics NodalVariableStatistics(const InputParameters & parameters); private: - /// The coupled variable used. + virtual Real computeValue() override; + + /// The coupled variable used. const VariableValue & _v; - virtual Real computeValue(); }; diff --git a/framework/src/reporters/ElementStatistics.C b/framework/src/reporters/ElementStatistics.C index a44166cc52c4..8303202831fc 100644 --- a/framework/src/reporters/ElementStatistics.C +++ b/framework/src/reporters/ElementStatistics.C @@ -27,6 +27,7 @@ ElementStatistics::ElementStatistics(const InputParameters & parameters) _number_elements(declareValueByName(_base_name + "number_elements")) { } + void ElementStatistics::initialize() { diff --git a/framework/src/reporters/ElementVariableStatistics.C b/framework/src/reporters/ElementVariableStatistics.C index a84e72d29797..7ce412ceacde 100644 --- a/framework/src/reporters/ElementVariableStatistics.C +++ b/framework/src/reporters/ElementVariableStatistics.C @@ -27,6 +27,7 @@ ElementVariableStatistics::ElementVariableStatistics(const InputParameters & par : ElementStatistics(parameters), _v(coupledValue("coupled_var")) { } + Real ElementVariableStatistics::computeValue() { diff --git a/framework/src/reporters/NodalStatistics.C b/framework/src/reporters/NodalStatistics.C index ac8e126be98e..9fd5d76f60f5 100644 --- a/framework/src/reporters/NodalStatistics.C +++ b/framework/src/reporters/NodalStatistics.C @@ -26,6 +26,7 @@ NodalStatistics::NodalStatistics(const InputParameters & parameters) _number_nodes(declareValueByName(_base_name + "number_nodes")) { } + void NodalStatistics::initialize() { diff --git a/framework/src/reporters/NodalVariableStatistics.C b/framework/src/reporters/NodalVariableStatistics.C index e7290559811b..090d50e346f2 100644 --- a/framework/src/reporters/NodalVariableStatistics.C +++ b/framework/src/reporters/NodalVariableStatistics.C @@ -27,6 +27,7 @@ NodalVariableStatistics::NodalVariableStatistics(const InputParameters & paramet : NodalStatistics(parameters), _v(coupledValue("coupled_var")) { } + Real NodalVariableStatistics::computeValue() { diff --git a/test/tests/reporters/element_reporter/elem_stats.i b/test/tests/reporters/element_reporter/elem_stats.i index 9da37d906b40..9b2141f8549b 100644 --- a/test/tests/reporters/element_reporter/elem_stats.i +++ b/test/tests/reporters/element_reporter/elem_stats.i @@ -1,10 +1,12 @@ [Mesh] - type = GeneratedMesh - dim = 2 - xmax = 2 - ymax = 2 - nx = 10 - ny = 10 + [gmg] + type = GeneratedMeshGenerator + dim = 2 + xmax = 2 + ymax = 2 + nx = 10 + ny = 10 + [] [] [Variables] diff --git a/test/tests/reporters/nodal_reporter/nodal_stats.i b/test/tests/reporters/nodal_reporter/nodal_stats.i index 0d12323ee386..2f0cc38e3e34 100644 --- a/test/tests/reporters/nodal_reporter/nodal_stats.i +++ b/test/tests/reporters/nodal_reporter/nodal_stats.i @@ -1,10 +1,12 @@ [Mesh] - type = GeneratedMesh - dim = 2 - xmax = 2 - ymax = 2 - nx = 10 - ny = 10 + [gmg] + type = GeneratedMeshGenerator + dim = 2 + xmax = 2 + ymax = 2 + nx = 10 + ny = 10 + [] [] [Variables] From aad4ad00a8e45387063f41f8d0f9edda18fd0ba9 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Tue, 27 Jun 2023 12:56:03 -0600 Subject: [PATCH 7/9] Fix formatting in elementvariablestatistics Co-authored-by: Zachary Prince --- framework/include/reporters/ElementVariableStatistics.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/include/reporters/ElementVariableStatistics.h b/framework/include/reporters/ElementVariableStatistics.h index 1a762b9afa5d..6a2bf204f1f1 100644 --- a/framework/include/reporters/ElementVariableStatistics.h +++ b/framework/include/reporters/ElementVariableStatistics.h @@ -19,7 +19,8 @@ class ElementVariableStatistics : public ElementStatistics ElementVariableStatistics(const InputParameters & parameters); private: - /// The coupled variable used. + virtual Real computeValue() override; + + /// The coupled variable used. const VariableValue & _v; - virtual Real computeValue(); }; From c0b88ecd787eec5941f3a2d00051d18f0fbf7bb6 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Tue, 27 Jun 2023 13:03:24 -0600 Subject: [PATCH 8/9] fix clang format precheck --- framework/include/reporters/ElementVariableStatistics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/include/reporters/ElementVariableStatistics.h b/framework/include/reporters/ElementVariableStatistics.h index 6a2bf204f1f1..a9fa084d070a 100644 --- a/framework/include/reporters/ElementVariableStatistics.h +++ b/framework/include/reporters/ElementVariableStatistics.h @@ -21,6 +21,6 @@ class ElementVariableStatistics : public ElementStatistics private: virtual Real computeValue() override; - /// The coupled variable used. + /// The coupled variable used. const VariableValue & _v; }; From 936b7e69c87ca9d795800dfa50dc834768a01206 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Tue, 27 Jun 2023 13:21:52 -0600 Subject: [PATCH 9/9] clang-format NVS --- framework/include/reporters/NodalVariableStatistics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/include/reporters/NodalVariableStatistics.h b/framework/include/reporters/NodalVariableStatistics.h index 9930047b6c41..f985616cc53d 100644 --- a/framework/include/reporters/NodalVariableStatistics.h +++ b/framework/include/reporters/NodalVariableStatistics.h @@ -21,6 +21,6 @@ class NodalVariableStatistics : public NodalStatistics private: virtual Real computeValue() override; - /// The coupled variable used. + /// The coupled variable used. const VariableValue & _v; };