23 "vpp",
"The VectorPostprocessor to compute histogram of");
25 params.
addRequiredParam<
unsigned int>(
"num_bins",
"The number of bins for the histograms");
32 _vpp_name(getParam<VectorPostprocessorName>(
"vpp")),
33 _num_bins(getParam<unsigned
int>(
"num_bins"))
46 paramError(
"vpp",
"The specified VectorPostprocessor does not have any declared vectors");
65 mooseAssert(
_histogram_data.count(vec_name),
"Error retrieving VPP vector");
82 mooseError(
"Cannot compute histogram without data!");
85 auto & lower_vector = *histo_data.
_lower;
86 auto & upper_vector = *histo_data.
_upper;
97 std::vector<Real> sorted_values(values.size());
98 std::partial_sort_copy(values.begin(), values.end(), sorted_values.begin(), sorted_values.end());
101 auto min = sorted_values.front();
102 auto max = sorted_values.back();
107 auto current_value_iter = sorted_values.begin();
108 auto sorted_values_end = sorted_values.end();
111 for (
unsigned int bin = 0; bin <
_num_bins; bin++)
116 auto lower = (bin * bin_stride) +
min;
117 auto upper = ((bin + 1) * bin_stride) +
min;
119 lower_vector[bin] = lower;
120 upper_vector[bin] = upper;
123 unsigned long int num_values = 0;
124 while (current_value_iter != sorted_values_end && *current_value_iter <= upper)
127 current_value_iter++;
130 histogram[bin] =
static_cast<Real>(num_values);
const unsigned int & _num_bins
The number of bins.
Computes a histogram for each column in a given VectorPostprocessor.
Helper class to hold the vectors for the histogram.
This class is here to combine the VectorPostprocessor interface and the base class VectorPostprocesso...
VectorPostprocessorValue * _upper
The upper edges for each bin.
auto max(const L &left, const R &right)
virtual void execute() override
Execute method.
const VectorPostprocessorValue & getVectorPostprocessorValueByName(const std::string &object_name, const std::string &vector_name, std::size_t t_index=0) const
Get a read-only reference to the vector value associated with the VectorPostprocessor.
std::map< std::string, HistoData > _histogram_data
The VPP vectors that will hold the Histogram for each column.
static InputParameters validParams()
registerMooseObject("MooseApp", HistogramVectorPostprocessor)
const VectorPostprocessorName & _vpp_name
The name of the VPP to work on.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
VectorPostprocessorValue & declareVector(const std::string &vector_name)
Register a new vector to fill up.
VectorPostprocessorValue * _lower
The lower edges for each bin.
virtual void finalize() override
Finalize.
VectorPostprocessorValue * _histogram
Where the data will actually be stored.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
static InputParameters validParams()
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
HistogramVectorPostprocessor(const InputParameters ¶meters)
processor_id_type processor_id() const
Base class for Postprocessors that produce a vector of values.
auto min(const L &left, const R &right)
void computeHistogram(const std::vector< Real > &values, HistoData &histo_data)
Compute the histogram of a vector and fill in the lower/upper edges.
const std::set< std::string > & getVectorNames() const
Return the names of the vectors associated with this object.
void ErrorVector unsigned int