https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
31void
33{
34 _max = std::numeric_limits<Real>::min();
35 _min = std::numeric_limits<Real>::max();
36 _average = 0;
37 _integral = 0;
39}
40
41void
43{
44 // Get value to to update statistics
45 Real value = computeValue();
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
60void
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
71void
void ErrorVector unsigned int
static InputParameters validParams()
virtual void finalize() override
Finalize.
virtual void execute() override
Execute method.
ElementStatistics(const InputParameters &parameters)
virtual void threadJoin(const UserObject &) override
Must override.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual Real computeValue()=0
static InputParameters validParams()
const Real & _current_elem_volume
The current element volume (available during execute())
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.
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