https://mooseframework.inl.gov
ElementStatistics.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 "ElementStatistics.h"
11 
14 {
16  params.addParam<std::string>("base_name", "Name to append to reporters.");
17  return params;
18 }
19 
21  : ElementReporter(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  _integral(declareValueByName<Real>(_base_name + "integral")),
27  _number_elements(declareValueByName<int>(_base_name + "number_elements"))
28 {
29 }
30 
31 void
33 {
36  _average = 0;
37  _integral = 0;
38  _number_elements = 0;
39 }
40 
41 void
43 {
44  // Get value to to update statistics
46 
47  if (_max < value)
48  _max = value;
49 
50  if (_min > value)
51  _min = value;
52 
54 
55  // Update the total and the number to get the average when "finalizing"
56  _average += value;
58 }
59 
60 void
62 {
63  const ElementStatistics & ele_uo = static_cast<const ElementStatistics &>(uo);
64  _max = std::max(_max, ele_uo._max);
65  _min = std::min(_min, ele_uo._min);
66  _integral += ele_uo._integral;
67  _average += ele_uo._average;
69 }
70 
71 void
73 {
79 
80  // Compute the average;
82 }
static InputParameters validParams()
ElementStatistics(const InputParameters &parameters)
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & _communicator
const Real & _current_elem_volume
The current element volume (available during execute())
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
auto max(const L &left, const R &right)
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void min(const T &r, T &o, Request &req) const
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
virtual void finalize() override
Finalize.
virtual void execute() override
Execute method.
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...
virtual void threadJoin(const UserObject &) override
Must override.
auto min(const L &left, const R &right)
void ErrorVector unsigned int
Base class for user-specific data.
Definition: UserObject.h:40