From a3fc889d72613672a1ab46711bd5bd4327b330d4 Mon Sep 17 00:00:00 2001 From: Max Nezdyur Date: Thu, 15 Jun 2023 12:04:13 -0600 Subject: [PATCH] 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.' + [] +[]