https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
30void
32{
33 _max = std::numeric_limits<Real>::min();
34 _min = std::numeric_limits<Real>::max();
35 _average = 0;
36 _number_nodes = 0;
37}
38
39void
41{
42 // Get value to to update statistics
43 Real value = computeValue();
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;
54}
55
56void
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;
64}
65
66void
void ErrorVector unsigned int
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.
static InputParameters validParams()
virtual Real computeValue()=0
virtual void finalize() override
Finalize.
virtual void threadJoin(const UserObject &) override
Must override.
virtual void execute() override
Execute method.
static InputParameters validParams()
NodalStatistics(const InputParameters &parameters)
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
void max(const T &r, T &o, Request &req) const
void min(const T &r, T &o, Request &req) const
Base class for user-specific data.
Definition UserObject.h:20
const Parallel::Communicator & _communicator