https://mooseframework.inl.gov
NodalStatistics.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "NodalStatistics.h"
11 
14 {
16  params.addParam<std::string>("base_name", "Name to append to reporters.");
17  return params;
18 }
19 
21  : NodalReporter(parameters),
22  _base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
23  _max(declareValueByName<Real>(_base_name + "max")),
24  _min(declareValueByName<Real>(_base_name + "min")),
25  _average(declareValueByName<Real>(_base_name + "average")),
26  _number_nodes(declareValueByName<int>(_base_name + "number_nodes"))
27 {
28 }
29 
30 void
32 {
35  _average = 0;
36  _number_nodes = 0;
37 }
38 
39 void
41 {
42  // Get value to to update statistics
44 
45  if (_max < value)
46  _max = value;
47 
48  if (_min > value)
49  _min = value;
50 
51  // Update the total and the number to get the average when "finalizing"
52  _average += value;
53  _number_nodes++;
54 }
55 
56 void
58 {
59  const NodalStatistics & node_uo = static_cast<const NodalStatistics &>(uo);
60  _max = std::max(_max, node_uo._max);
61  _min = std::min(_min, node_uo._min);
62  _average += node_uo._average;
63  _number_nodes += node_uo._number_nodes;
64 }
65 
66 void
68 {
73 
74  // Compute the average;
76 }
static InputParameters validParams()
Definition: NodalReporter.C:14
static InputParameters validParams()
virtual void execute() override
Execute method.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & _communicator
auto max(const L &left, const R &right)
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void min(const T &r, T &o, Request &req) const
NodalStatistics(const InputParameters &parameters)
virtual void threadJoin(const UserObject &) override
Must override.
virtual Real computeValue()=0
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
auto min(const L &left, const R &right)
void ErrorVector unsigned int
Base class for user-specific data.
Definition: UserObject.h:40
virtual void finalize() override
Finalize.