11#include "libmesh/parallel_algebra.h"
18 "unique_times",
true,
"Whether duplicate values should be removed from the Times vector");
22 "Absolute tolerance for removing duplicated times when getting a set of unique times");
23 params.
addParam<
bool>(
"auto_sort",
true,
"Whether Times should be sorted");
27 "Wether Times should be broadcasted across all ranks");
28 params.
addParamNamesToGroup(
"auto_broadcast auto_sort unique_times unique_tolerance",
"Advanced");
35 params.
addParam<
bool>(
"dynamic_time_sequence",
37 "Whether the time sequence is dynamic and thus needs to be updated");
48 _need_broadcast(getParam<bool>(
"auto_broadcast")),
49 _need_sort(getParam<bool>(
"auto_sort")),
50 _need_unique(getParam<bool>(
"unique_times")),
51 _unique_tol(getParam<Real>(
"unique_tolerance")),
52 _dynamic_time_sequence(getParam<bool>(
"dynamic_time_sequence"))
60 mooseError(
"Times retrieved with an out-of-bound index");
65 mooseError(
"Times vector has not been initialized.");
72 mooseError(
"Times vector has not been initialized.");
74 Real previous_time =
_times[0];
75 for (
const auto i : make_range(std::size_t(1),
_times.size()))
77 const auto & time =
_times[i];
78 if (MooseUtils::absoluteFuzzyGreaterThan(time, current_time))
89 for (
const auto i : index_range(
_times))
91 const auto & time =
_times[i];
92 if (MooseUtils::absoluteFuzzyGreaterThan(time, current_time))
95 if (
_times.size() && error_if_no_next)
96 mooseError(
"No next time in Times vector for time ",
98 ". Maximum time in vector is ",
100 else if (!error_if_no_next)
101 return std::numeric_limits<Real>::max();
103 mooseError(
"Times vector has not been initialized.");
106const std::vector<Real> &
113 mooseError(
"Times vector has not been initialized.");
137 [
this](Real l, Real r) { return std::abs(l - r) < _unique_tol; }),
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
const ReporterMode REPORTER_MODE_REPLICATED
Reporter object that has a single execution of the "execute" method for each execute flag.
static InputParameters validParams()
This context is specific for vector types of reporters, mainly for declaring a vector of the type fro...
void allgather(const T &send_data, std::vector< T, A > &recv_data) const
void clearTimes()
Clear the times vector.
static InputParameters validParams()
const bool _need_broadcast
Whether generation of times is distributed or not (and therefore needs a broadcast)
const std::vector< Real > & getTimes() const
Getter for the full times vector.
virtual void finalize() override
In charge of reduction across all ranks.
Times(const InputParameters ¶meters)
Real getNextTime(const Real current_time, const bool error_if_no_next) const
Find the next time in the times vector for a given time If current_time is also in the times vector w...
const bool _need_sort
Whether times should be sorted, because they come from different sources for example.
std::vector< Real > & _times
The vector holding the times.
Real getTimeAtIndex(unsigned int index) const
Getter for a single time at a known index.
Real getPreviousTime(const Real current_time) const
Find the previous time in the times vector for a given time If current_time is also in the times vect...
const bool _need_unique
Whether duplicate times should be removed.
const Parallel::Communicator & _communicator