www.mooseframework.org
AverageNodalVariableValue.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 
11 #include "MooseMesh.h"
12 #include "SubProblem.h"
13 
15 
16 template <>
19 {
21  return params;
22 }
23 
25  : NodalVariablePostprocessor(parameters), _sum(0), _n(0)
26 {
27 }
28 
29 // doco-init-start
30 void
32 {
33  _sum = 0;
34  _n = 0;
35 }
36 // doco-init-end
37 
38 // doco-execute-get-start
39 void
41 {
42  _sum += _u[_qp];
43  _n++;
44 }
45 
46 Real
48 {
49  return _sum / _n;
50 }
51 // doco-execute-get-end
52 
53 // doco-final-start
54 void
56 {
57  gatherSum(_sum);
58  gatherSum(_n);
59 
60 }
61 // doco-final-end
62 
63 // doco-thread-start
64 void
66 {
67  const AverageNodalVariableValue & pps = static_cast<const AverageNodalVariableValue &>(y);
68  _sum += pps._sum;
69  _n += pps._n;
70 }
71 // doco-thread-end
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:103
const unsigned int _qp
Quadrature point index.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
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.
registerMooseObject("MooseApp", AverageNodalVariableValue)
Base class for user-specific data.
Definition: UserObject.h:37
AverageNodalVariableValue(const InputParameters &parameters)