15#include "libmesh/quadrature.h"
23 params.
addClassDescription(
"Compute histograms of volume fractions binned according to component "
24 "values of an array variable.");
25 params.
addParam<
unsigned int>(
"bin_number", 50,
"Number of histogram bins");
26 params.
addCoupledVar(
"variable",
"Variable to bin the volume of");
35 _nbins(getParam<unsigned
int>(
"bin_number")),
36 _min_value(getParam<Real>(
"min_value")),
37 _max_value(getParam<Real>(
"max_value")),
38 _deltaV((_max_value - _min_value) / _nbins),
39 _value(coupledArrayValue(
"variable")),
40 _var(*getArrayVar(
"variable", 0)),
41 _bin_center(declareVector(
"value"))
44 mooseError(
"ArrayVariableValueVolumeHistogram works on exactly one coupled variable");
46 for (
const unsigned int i : make_range(
_var.
count()))
51 for (
const unsigned int i : make_range(
_nbins))
60 volume->assign(
_nbins, 0.0);
67 for (
auto _qp : make_range(
_qrule->n_points()))
69 for (
const unsigned int i : make_range(
_var.
count()))
75 if (bin >= 0 &&
static_cast<unsigned int>(bin) <
_nbins)
84 for (
const unsigned int i : make_range(
_var.
count()))
92 mooseAssert(uo._volumes.size() ==
_volumes.size(),
93 "Inconsistent number of array variable components across threads.");
95 for (
const unsigned int i : make_range(
_var.
count()))
97 mooseAssert(uo._volumes[i]->size() ==
_volumes[i]->size(),
98 "Inconsistent volume vector lengths across threads.");
99 for (
const unsigned int j : index_range(*
_volumes[i]))
100 (*
_volumes[i])[j] += (*uo._volumes[i])[j];
registerMooseObject("MooseApp", ArrayVariableValueVolumeHistogram)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
void ErrorVector unsigned int
Compute histograms of volume fractions binned according to component values of an array variable.
const unsigned int _nbins
number of histogram bins
virtual void execute() override
Execute method.
virtual void threadJoin(const UserObject &y) override
Must override.
ArrayVariableValueVolumeHistogram(const InputParameters ¶meters)
virtual void finalize() override
Finalize.
std::vector< VectorPostprocessorValue * > _volumes
aggregated volumes of all components for the given bin
const ArrayVariableValue & _value
coupled variable that is being binned
const Real _deltaV
bin width
static InputParameters validParams()
VectorPostprocessorValue & _bin_center
value mid point of the bin
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
unsigned int _qp
current quadrature point - used in computeVolume()
const Real _min_value
minimum variable value
const ArrayMooseVariable & _var
coupled array variable
unsigned int coupledComponents(const std::string &var_name) const
Number of coupled components.
const QBase *const & _qrule
const MooseArray< Real > & _coord
const MooseArray< Real > & _JxW
static InputParameters validParams()
const std::string & arrayVariableComponent(const unsigned int i) const
Returns the variable name of a component of an array variable.
unsigned int count() const
Get the number of components Note: For standard and vector variables, the number is one.
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Base class for user-specific data.
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.