1#include <boost/range.hpp>
13 : _stampleStorage{}, _degree(0)
21 for (
const auto &stample : other.
stamples()) {
48 existingSample->sample =
sample;
88 PRECICE_ASSERT(
nTimes() >= 2,
"Calling Storage::move() is only allowed, if there is a sample at the beginning and at the end. This ensures that this function is only called at the end of the window.",
getTimes());
132 auto beforeTime = [time](
const auto &s) {
return math::smaller(s.timestamp, time); };
141 auto afterTime = [time](
const auto &s) {
return math::greater(s.timestamp, time); };
156 return stample->sample;
162 auto times = Eigen::VectorXd(
nTimes());
163 for (
int i = 0; i < times.size(); i++) {
182 auto times = Eigen::VectorXd(
nTimes());
184 for (
int i = 0; i < times.size(); i++) {
195 if (usedDegree == 0) {
210 _bspline.emplace(times, values, usedDegree);
213 return _bspline.value().interpolateAt(time);
220 if (usedDegree == 0) {
224 PRECICE_WARN(
"You specified interpolation degree of {}, but only degree 0 is supported for gradient interpolation", usedDegree);
231 return std::min(requestedDegree, numberOfAvailableSamples - 1);
#define PRECICE_WARN(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
void trimAfter(double time)
Eigen::VectorXd sample(double time) const
Need to use interpolation for the case with changing time grids.
Sample getSampleAtOrAfter(double before) const
Returns the Sample at time following "before" contained in this Storage.
auto stamples() const
Get the stamples.
void trimBefore(double time)
int findTimeId(double time) const
void setSampleAtTime(double time, const Sample &sample)
Store Sample at a specific time.
Storage()
Stores data samples in time and provides corresponding convenience functions.
void clear()
Clears this Storage by deleting all values.
int nDofs() const
Number of Dofs for each values.
Eigen::MatrixXd sampleGradients(double time) const
void trim()
Trims this Storage by deleting all values except values associated with the window start.
std::pair< Eigen::VectorXd, Eigen::MatrixXd > getTimesAndValues() const
Get all normalized dts and values in ascending order (with respect to normalized dts)
double maxStoredTime() const
Get maximum time that is stored in this Storage.
std::optional< math::Bspline > _bspline
int computeUsedDegree(int requestedDegree, int numberOfAvailableSamples) const
Computes which degree may be used for interpolation.
Storage & operator=(const Storage &other)
Copy assignment operator to assign Storage to this Storage.
void setInterpolationDegree(int interpolationDegree)
std::vector< Stample > _stampleStorage
Stores Stamples on the current window.
void move()
Move this Storage by deleting all stamples except the one at the end of the window.
int nTimes() const
Number of stored times.
Eigen::VectorXd getTimes() const
Get all normalized dts stored in this Storage sorted ascending.
time::Sample getSampleAtBeginning()
const time::Stample & last() const
time::Sample getSampleAtEnd()
int getInterpolationDegree() const
static const int MAX_WAVEFORM_DEGREE
The maximum allowed interpolation degree.
static const int MIN_WAVEFORM_DEGREE
The minimum required interpolation degree.
constexpr bool equals(const Eigen::MatrixBase< DerivedA > &A, const Eigen::MatrixBase< DerivedB > &B, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Compares two Eigen::MatrixBase for equality up to tolerance.
std::enable_if< std::is_arithmetic< Scalar >::value, bool >::type smallerEquals(Scalar A, Scalar B, Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
std::enable_if< std::is_arithmetic< Scalar >::value, bool >::type smaller(Scalar A, Scalar B, Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
std::enable_if< std::is_arithmetic< Scalar >::value, bool >::type greater(Scalar A, Scalar B, Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
contains the time interpolation logic.
Eigen::MatrixXd gradients
The gradients of the data. Use gradients.col(i) to get the gradient at vertex i.
Stample containing timestampled Sample.