www.mooseframework.org
AverageNodalVariableValue.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
16 #include "MooseMesh.h"
17 #include "SubProblem.h"
18 
19 template <>
22 {
24  return params;
25 }
26 
28  : NodalVariablePostprocessor(parameters), _avg(0), _n(0)
29 {
30 }
31 
32 void
34 {
35  _avg = 0;
36  _n = 0;
37 }
38 
39 void
41 {
42  _avg += _u[_qp];
43  _n++;
44 }
45 
46 Real
48 {
49  gatherSum(_avg);
50  gatherSum(_n);
51 
52  return _avg / _n;
53 }
54 
55 void
57 {
58  const AverageNodalVariableValue & pps = static_cast<const AverageNodalVariableValue &>(y);
59  _avg += pps._avg;
60  _n += pps._n;
61 }
virtual void execute() override
Execute method.
This is a base class for other classes which compute post-processed values based on nodal solution va...
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
InputParameters validParams< AverageNodalVariableValue >()
const VariableValue & _u
Holds the solution at current quadrature points.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Definition: UserObject.h:119
const unsigned int _qp
Quadrature point index.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
InputParameters validParams< NodalVariablePostprocessor >()
virtual void threadJoin(const UserObject &y) override
Must override.
Base class for user-specific data.
Definition: UserObject.h:42
AverageNodalVariableValue(const InputParameters &parameters)