https://mooseframework.inl.gov
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 {
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 
27  : ElementPostprocessor(parameters), _v(coupledValue("v")), _w(getMaterialProperty<Real>("weight"))
28 {
29 }
30 
31 void
33 {
34  _var_integral = 0.0;
35  _weight_integral = 0.0;
36 }
37 
38 void
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
51 {
54 }
55 
58 {
59  if (_weight_integral == 0.0)
60  return 0.0;
61 
63 }
64 
65 void
67 {
68  const auto & pp = static_cast<const WeightedVariableAverage &>(y);
69  _var_integral += pp._var_integral;
70  _weight_integral += pp._weight_integral;
71 }
const MooseArray< Real > & _coord
static InputParameters validParams()
const MaterialProperty< Real > & _w
weight mask for averaging
virtual void execute() override
const std::vector< double > y
void addRequiredParam(const std::string &name, const std::string &doc_string)
Average a variable value using a weight mask given by a material property.
virtual void initialize() override
void gatherSum(T &value)
Real PostprocessorValue
void addCoupledVar(const std::string &name, const std::string &doc_string)
virtual void threadJoin(const UserObject &y) override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const QBase *const & _qrule
static InputParameters validParams()
const MooseArray< Real > & _JxW
WeightedVariableAverage(const InputParameters &parameters)
virtual PostprocessorValue getValue() const override
void addClassDescription(const std::string &doc_string)
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
registerMooseObject("PhaseFieldApp", WeightedVariableAverage)
Real _var_integral
integtals for vomputimng the average - computed in execute()
const VariableValue & _v
variable to average
virtual void finalize() override