https://mooseframework.inl.gov
Loading...
Searching...
No Matches
phase_field
src
postprocessors
WeightedVariableAverage.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 "
WeightedVariableAverage.h
"
11
12
registerMooseObject
(
"PhaseFieldApp"
,
WeightedVariableAverage
);
13
14
InputParameters
15
WeightedVariableAverage::validParams
()
16
{
17
InputParameters
params =
ElementPostprocessor::validParams
();
18
params.
addClassDescription
(
19
"Average a variable value using a weight mask given by a material property."
);
20
params.
addCoupledVar
(
"v"
,
"Variable to perform weighted average on."
);
21
params.
addRequiredParam
<MaterialPropertyName>(
"weight"
,
22
"Weight material property for averaging."
);
23
return
params;
24
}
25
26
WeightedVariableAverage::WeightedVariableAverage
(
const
InputParameters
& parameters)
27
:
ElementPostprocessor
(parameters), _v(coupledValue(
"v"
)), _w(getMaterialProperty<Real>(
"weight"
))
28
{
29
}
30
31
void
32
WeightedVariableAverage::initialize
()
33
{
34
_var_integral
= 0.0;
35
_weight_integral
= 0.0;
36
}
37
38
void
39
WeightedVariableAverage::execute
()
40
{
41
for
(
unsigned
int
qp = 0; qp <
_qrule
->n_points(); qp++)
42
{
43
auto
j =
_JxW
[qp] *
_coord
[qp];
44
_var_integral
+= j *
_v
[qp] *
_w
[qp];
45
_weight_integral
+= j *
_w
[qp];
46
}
47
}
48
49
void
50
WeightedVariableAverage::finalize
()
51
{
52
gatherSum
(
_var_integral
);
53
gatherSum
(
_weight_integral
);
54
}
55
56
PostprocessorValue
57
WeightedVariableAverage::getValue
()
const
58
{
59
if
(
_weight_integral
== 0.0)
60
return
0.0;
61
62
return
_var_integral
/
_weight_integral
;
63
}
64
65
void
66
WeightedVariableAverage::threadJoin
(
const
UserObject
&
y
)
67
{
68
const
auto
& pp =
static_cast<
const
WeightedVariableAverage
&
>
(
y
);
69
_var_integral
+= pp.
_var_integral
;
70
_weight_integral
+= pp._weight_integral;
71
}
y
const std::vector< double > y
Definition
EquilibriumConstantFitTest.C:18
PostprocessorValue
Real PostprocessorValue
registerMooseObject
registerMooseObject("PhaseFieldApp", WeightedVariableAverage)
WeightedVariableAverage.h
ElementPostprocessor
ElementPostprocessor::validParams
static InputParameters validParams()
ElementPostprocessor::_qrule
const QBase *const & _qrule
ElementPostprocessor::_coord
const MooseArray< Real > & _coord
ElementPostprocessor::_JxW
const MooseArray< Real > & _JxW
InputParameters::addRequiredParam
void addRequiredParam(const std::string &name, const std::string &doc_string)
InputParameters::addClassDescription
void addClassDescription(const std::string &doc_string)
InputParameters::addCoupledVar
void addCoupledVar(const std::string &name, const std::string &doc_string)
ElementPostprocessor::gatherSum
void gatherSum(T &value)
UserObject
WeightedVariableAverage
Average a variable value using a weight mask given by a material property.
Definition
WeightedVariableAverage.h:20
WeightedVariableAverage::initialize
virtual void initialize() override
Definition
WeightedVariableAverage.C:32
WeightedVariableAverage::WeightedVariableAverage
WeightedVariableAverage(const InputParameters ¶meters)
Definition
WeightedVariableAverage.C:26
WeightedVariableAverage::validParams
static InputParameters validParams()
Definition
WeightedVariableAverage.C:15
WeightedVariableAverage::finalize
virtual void finalize() override
Definition
WeightedVariableAverage.C:50
WeightedVariableAverage::getValue
virtual PostprocessorValue getValue() const override
Definition
WeightedVariableAverage.C:57
WeightedVariableAverage::threadJoin
virtual void threadJoin(const UserObject &y) override
Definition
WeightedVariableAverage.C:66
WeightedVariableAverage::_var_integral
Real _var_integral
integtals for vomputimng the average - computed in execute()
Definition
WeightedVariableAverage.h:40
WeightedVariableAverage::_weight_integral
Real _weight_integral
Definition
WeightedVariableAverage.h:41
WeightedVariableAverage::execute
virtual void execute() override
Definition
WeightedVariableAverage.C:39
WeightedVariableAverage::_w
const MaterialProperty< Real > & _w
weight mask for averaging
Definition
WeightedVariableAverage.h:37
WeightedVariableAverage::_v
const VariableValue & _v
variable to average
Definition
WeightedVariableAverage.h:34
InputParameters
Generated on Fri Aug 21 2026 13:41:26 for https://mooseframework.inl.gov by
1.9.8