https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11
13
16{
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
27 : ElementPostprocessor(parameters), _v(coupledValue("v")), _w(getMaterialProperty<Real>("weight"))
28{
29}
30
31void
37
38void
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
49void
55
58{
59 if (_weight_integral == 0.0)
60 return 0.0;
61
63}
64
65void
67{
68 const auto & pp = static_cast<const WeightedVariableAverage &>(y);
70 _weight_integral += pp._weight_integral;
71}
const std::vector< double > y
Real PostprocessorValue
registerMooseObject("PhaseFieldApp", WeightedVariableAverage)
static InputParameters validParams()
const QBase *const & _qrule
const MooseArray< Real > & _coord
const MooseArray< Real > & _JxW
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void gatherSum(T &value)
Average a variable value using a weight mask given by a material property.
virtual void initialize() override
WeightedVariableAverage(const InputParameters &parameters)
static InputParameters validParams()
virtual void finalize() override
virtual PostprocessorValue getValue() const override
virtual void threadJoin(const UserObject &y) override
Real _var_integral
integtals for vomputimng the average - computed in execute()
virtual void execute() override
const MaterialProperty< Real > & _w
weight mask for averaging
const VariableValue & _v
variable to average