preCICE v3.2.0
|
#include <Storage.hpp>
Public Member Functions | |
Storage () | |
Stores data samples in time and provides corresponding convenience functions. | |
Storage & | operator= (const Storage &other) |
Copy assignment operator to assign Storage to this Storage. | |
void | setSampleAtTime (double time, const Sample &sample) |
Store Sample at a specific time. | |
void | setAllSamples (const Sample &sample) |
Overrides all existing samples. | |
void | setInterpolationDegree (int interpolationDegree) |
int | getInterpolationDegree () const |
double | maxStoredTime () const |
Get maximum time that is stored in this Storage. | |
const Sample & | getSampleAtOrAfter (double before) const |
Returns the Sample at time following "before" contained in this Storage. | |
const Sample & | getSampleAtEnd () const |
Returns the last Sample contained in this Storage. | |
Eigen::VectorXd | getTimes () const |
Get all normalized dts stored in this Storage sorted ascending. | |
auto | stamples () const |
Get the stamples. | |
auto | stamples () |
bool | empty () const |
const time::Stample & | last () const |
std::pair< Eigen::VectorXd, Eigen::MatrixXd > | getTimesAndValues () const |
Get all normalized dts and values in ascending order (with respect to normalized dts) | |
int | nTimes () const |
Number of stored times. | |
int | nDofs () const |
Number of Dofs for each values. | |
void | move () |
Move this Storage by deleting all stamples except the one at the end of the window. | |
void | trim () |
Trims this Storage by deleting all values except values associated with the window start. | |
void | clear () |
Clears this Storage by deleting all values. | |
void | clearExceptLast () |
void | trimBefore (double time) |
void | trimAfter (double time) |
SampleResult | sample (double time) const |
Need to use interpolation for the case with changing time grids. | |
Eigen::MatrixXd | sampleGradients (double time) const |
Private Member Functions | |
int | computeUsedDegree (int requestedDegree, int numberOfAvailableSamples) const |
Computes which degree may be used for interpolation. | |
Private Attributes | |
std::vector< Stample > | _stampleStorage |
Stores Stamples on the current window. | |
logging::Logger | _log {"time::Storage"} |
int | _degree |
std::optional< math::Bspline > | _bspline |
Definition at line 13 of file Storage.hpp.
precice::time::Storage::Storage | ( | ) |
Stores data samples in time and provides corresponding convenience functions.
The Storage must be initialized before it can be used. Then values can be stored in the Storage. It is only allowed to store samples with increasing times. Overwriting existing samples or writing samples with a time smaller then the maximum stored time is forbidden. The Storage is considered complete, when a sample for the end of the current window is provided. Then one can only sample from the storage. To add further samples one needs to trim the storage or move to the next time window first.
This Storage is used in the context of Waveform relaxation where samples in time are provided.
Definition at line 12 of file Storage.cpp.
void precice::time::Storage::clear | ( | ) |
Clears this Storage by deleting all values.
Definition at line 117 of file Storage.cpp.
void precice::time::Storage::clearExceptLast | ( | ) |
Definition at line 126 of file Storage.cpp.
|
private |
Computes which degree may be used for interpolation.
Actual degree of interpolating B-spline is determined by number of stored samples and maximum degree defined by the user. Example: If only two samples are available, the maximum degree we may use is 1, even if the user demands degree 2.
requestedDegree | B-spline degree requested by the user. |
numberOfAvailableSamples | Samples available for interpolation. |
Definition at line 240 of file Storage.cpp.
bool precice::time::Storage::empty | ( | ) | const |
Definition at line 176 of file Storage.cpp.
int precice::time::Storage::getInterpolationDegree | ( | ) | const |
Definition at line 68 of file Storage.cpp.
const Sample & precice::time::Storage::getSampleAtEnd | ( | ) | const |
const Sample & precice::time::Storage::getSampleAtOrAfter | ( | double | before | ) | const |
Returns the Sample at time following "before" contained in this Storage.
The stored normalized dt is larger or equal than "before". If "before" is a normalized dt stored in this Storage, this function returns the Sample at "before"
before | a double, where we want to find a normalized dt that comes directly after this one |
Definition at line 155 of file Storage.cpp.
Eigen::VectorXd precice::time::Storage::getTimes | ( | ) | const |
Get all normalized dts stored in this Storage sorted ascending.
Definition at line 167 of file Storage.cpp.
std::pair< Eigen::VectorXd, Eigen::MatrixXd > precice::time::Storage::getTimesAndValues | ( | ) | const |
Get all normalized dts and values in ascending order (with respect to normalized dts)
Definition at line 187 of file Storage.cpp.
const time::Stample & precice::time::Storage::last | ( | ) | const |
Definition at line 181 of file Storage.cpp.
double precice::time::Storage::maxStoredTime | ( | ) | const |
Get maximum time that is stored in this Storage.
Definition at line 73 of file Storage.cpp.
void precice::time::Storage::move | ( | ) |
Move this Storage by deleting all stamples except the one at the end of the window.
Definition at line 93 of file Storage.cpp.
int precice::time::Storage::nDofs | ( | ) | const |
Number of Dofs for each values.
Definition at line 87 of file Storage.cpp.
int precice::time::Storage::nTimes | ( | ) | const |
Number of stored times.
Definition at line 82 of file Storage.cpp.
SampleResult precice::time::Storage::sample | ( | double | time | ) | const |
Need to use interpolation for the case with changing time grids.
time | a double, where we want to sample the waveform |
Definition at line 198 of file Storage.cpp.
Eigen::MatrixXd precice::time::Storage::sampleGradients | ( | double | time | ) | const |
void precice::time::Storage::setAllSamples | ( | const Sample & | sample | ) |
Overrides all existing samples.
This keeps time stamps, but overwrites all samples with a given one. Required in reinitialization
sample | new sample value |
Definition at line 52 of file Storage.cpp.
void precice::time::Storage::setInterpolationDegree | ( | int | interpolationDegree | ) |
Definition at line 59 of file Storage.cpp.
void precice::time::Storage::setSampleAtTime | ( | double | time, |
const Sample & | sample ) |
Store Sample at a specific time.
It is only allowed to store a Sample in time that comes after a Sample that was already stored. Therefore, time has to be larger than maxStoredTime. The function trim() should be used before providing new samples.
time | the time associated with the sample |
sample | stored sample |
Definition at line 27 of file Storage.cpp.
|
inline |
Definition at line 98 of file Storage.hpp.
|
inline |
void precice::time::Storage::trim | ( | ) |
Trims this Storage by deleting all values except values associated with the window start.
Definition at line 105 of file Storage.cpp.
void precice::time::Storage::trimAfter | ( | double | time | ) |
void precice::time::Storage::trimBefore | ( | double | time | ) |
|
mutableprivate |
Definition at line 167 of file Storage.hpp.
|
private |
Definition at line 165 of file Storage.hpp.
|
mutableprivate |
Definition at line 163 of file Storage.hpp.
|
private |
Stores Stamples on the current window.
Definition at line 161 of file Storage.hpp.