22 "Windowed statistics (mean, std, drift) and a running time average of a postprocessor, "
23 "using only samples from start_time onwards.");
25 params.
addRequiredParam<PostprocessorName>(
"postprocessor",
"The postprocessor to monitor.");
27 "Simulation time from which samples are used for all statistics.");
29 "window", 100,
"window > 1",
"Number of time steps in one window.");
31 MooseEnum stats(getStatisticOptions(),
"mean");
34 params.
addParam<Real>(
"reference_value",
36 "Scale used to normalize relative_drift. "
37 "If 0, the magnitude of the window mean is used.");
44 _pp(getPostprocessorValue(
"postprocessor")),
45 _window(getParam<unsigned
int>(
"window")),
46 _statistic(getParam<
MooseEnum>(
"statistic").getEnum<Statistic>()),
47 _start_time(getParam<Real>(
"start_time")),
48 _reference(getParam<Real>(
"reference_value")),
49 _history(declareRestartableData<
std::vector<Real>>(
"history")),
50 _last_step(declareRestartableData<
int>(
"last_step", -1)),
51 _averaging(declareRestartableData<bool>(
"averaging", false)),
52 _sum(declareRestartableData<Real>(
"sum", 0.0)),
53 _avg_time(declareRestartableData<Real>(
"avg_time", 0.0)),
62 for (std::size_t i = begin; i < end; ++i)
64 return end > begin ? s / (end - begin) : 0.0;
99 const std::size_t n =
_history.size();
100 const std::size_t nw = std::min<std::size_t>(n,
_window);
104 case Statistic::MEAN:
112 for (std::size_t i = n - nw; i < n; ++i)
114 _value = nw > 1 ? std::sqrt(s / (nw - 1)) : 0.0;
118 case Statistic::TIME_INTEGRATED_MEAN:
123 case Statistic::STATISTICS_TIME:
registerMooseObject("MooseApp", TimeWindowedStatisticsPostProcessor)
void ErrorVector unsigned int
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Time statistics of another postprocessor, using only samples with t >= start_time.
Real _value
Value of the selected statistic computed in the latest execute()
static InputParameters validParams()
Real & _sum
Time integral of the monitored value since start_time, with the rectangle rule.
Real windowMean(std::size_t begin, std::size_t end) const
Arithmetic mean of the stored samples in the half-open index range [begin, end)
Real & _avg_time
Length of the time integration interval, the sum of the time steps clipped to start_time.
TimeWindowedStatisticsPostProcessor(const InputParameters ¶meters)
const PostprocessorValue & _pp
Value of the monitored postprocessor.
bool & _averaging
Whether averaging has started, i.e. a time step with t >= start_time has been reached.
const Statistic _statistic
Statistic reported by getValue()
const Real _start_time
Simulation time from which samples are recorded.
int & _last_step
Time step index of the last recorded sample, used to record at most one sample per step.
std::vector< Real > & _history
Recorded samples, one per time step, most recent last; capped at 2 * _window entries.
virtual void execute() override
Execute method.
const unsigned int _window
Number of most recent time steps used by the windowed statistics (mean, std)
Real & _dt
Time step size.
int & _t_step
The number of the time step.