https://mooseframework.inl.gov
Loading...
Searching...
No Matches
src
postprocessors
AverageNodalVariableValue.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 "
AverageNodalVariableValue.h
"
11
#include "
MooseMesh.h
"
12
#include "
SubProblem.h
"
13
14
registerMooseObject
(
"MooseApp"
,
AverageNodalVariableValue
);
15
16
InputParameters
17
AverageNodalVariableValue::validParams
()
18
{
19
InputParameters
params =
NodalVariablePostprocessor::validParams
();
20
21
params.
addClassDescription
(
"Computes the average value of a field by sampling all nodal "
22
"solutions on the domain or within a subdomain"
);
23
return
params;
24
}
25
26
AverageNodalVariableValue::AverageNodalVariableValue
(
const
InputParameters
& parameters)
27
:
NodalVariablePostprocessor
(parameters), _sum(0), _n(0)
28
{
29
}
30
31
// doco-init-start
32
void
33
AverageNodalVariableValue::initialize
()
34
{
35
_sum
= 0;
36
_n
= 0;
37
}
38
// doco-init-end
39
40
// doco-execute-get-start
41
void
42
AverageNodalVariableValue::execute
()
43
{
44
_sum
+=
_u
[
_qp
];
45
_n
++;
46
}
47
48
Real
49
AverageNodalVariableValue::getValue
()
const
50
{
51
return
_sum
/
_n
;
52
}
53
// doco-execute-get-end
54
55
// doco-final-start
56
void
57
AverageNodalVariableValue::finalize
()
58
{
59
gatherSum
(
_sum
);
60
gatherSum
(
_n
);
61
}
62
// doco-final-end
63
64
// doco-thread-start
65
void
66
AverageNodalVariableValue::threadJoin
(
const
UserObject
& y)
67
{
68
const
auto
& pps =
static_cast<
const
AverageNodalVariableValue
&
>
(y);
69
_sum
+= pps.
_sum
;
70
_n
+= pps._n;
71
}
72
// doco-thread-end
registerMooseObject
registerMooseObject("MooseApp", AverageNodalVariableValue)
AverageNodalVariableValue.h
MooseMesh.h
SubProblem.h
AverageNodalVariableValue
Definition
AverageNodalVariableValue.h:15
AverageNodalVariableValue::_sum
Real _sum
Definition
AverageNodalVariableValue.h:28
AverageNodalVariableValue::initialize
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition
AverageNodalVariableValue.C:33
AverageNodalVariableValue::getValue
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition
AverageNodalVariableValue.C:49
AverageNodalVariableValue::validParams
static InputParameters validParams()
Definition
AverageNodalVariableValue.C:17
AverageNodalVariableValue::finalize
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
Definition
AverageNodalVariableValue.C:57
AverageNodalVariableValue::threadJoin
virtual void threadJoin(const UserObject &y) override
Must override.
Definition
AverageNodalVariableValue.C:66
AverageNodalVariableValue::execute
virtual void execute() override
Execute method.
Definition
AverageNodalVariableValue.C:42
AverageNodalVariableValue::AverageNodalVariableValue
AverageNodalVariableValue(const InputParameters ¶meters)
Definition
AverageNodalVariableValue.C:26
AverageNodalVariableValue::_n
unsigned int _n
Definition
AverageNodalVariableValue.h:29
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition
InputParameters.h:68
InputParameters::addClassDescription
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Definition
InputParameters.C:81
NodalUserObject::_qp
const unsigned int _qp
Quadrature point index.
Definition
NodalUserObject.h:45
NodalVariablePostprocessor
This is a base class for other classes which compute post-processed values based on nodal solution va...
Definition
NodalVariablePostprocessor.h:21
NodalVariablePostprocessor::_u
const VariableValue & _u
Holds the solution at current quadrature points.
Definition
NodalVariablePostprocessor.h:29
NodalVariablePostprocessor::validParams
static InputParameters validParams()
Definition
NodalVariablePostprocessor.C:16
UserObjectBase::gatherSum
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Definition
UserObjectBase.h:96
UserObject
Base class for user-specific data.
Definition
UserObject.h:20
Generated on Fri Aug 21 2026 13:33:58 for https://mooseframework.inl.gov by
1.9.8