preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MappingDataCache.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
5#include "mesh/Mesh.hpp"
7#include "time/Sample.hpp"
8
9namespace precice {
10namespace mapping {
11namespace impl {
12
45public:
47 explicit MappingDataCache(int dataDim);
48
49 // The inData member is for basic mappings (such as NN) and simply stores
50 // the latest evaluation of the waveform relaxation to prevent repeated time
51 // interpolation
53
54 // The std::vector<> member variables here are specific to PUM:
55 // we store cache data for each cluster:
56 // We need a sequence of polynomial contributions
57 // all data here is stored as a Matrix to encode the number of components
58 // the layout is
59 // Eigen::MatrixXd (vertices, components);
60 // Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor, Eigen::Dynamic, 3> instead of MatrixXd?
61 // an alternative layout of this data could be to wrap this in another struct ClusterData which is then within a vector
63 // ...and a vector of P/lambdas (the RBF coefficients)
64 // For conservative mappings, this vector refers to the Au, potentially as vector components
66
68 int getDataDimensions() const;
69
71 bool hasDataAtTimeStamp(double time) const;
72
74 void setTimeStamp(double time);
75
77 void resetTimeStamp();
78
80 void resetData();
81};
82
83// ------------------------------------------------------ HEADER IMPLEMENTATION
85 : inData{-1, time::Sample(dataDim)}
86{
87}
88
90{
91 return inData.sample.dataDims;
92}
93
94inline bool MappingDataCache::hasDataAtTimeStamp(double time) const
95{
96 return math::equals(inData.timestamp, time);
97}
98
99inline void MappingDataCache::setTimeStamp(double time)
100{
101 inData.timestamp = time;
102}
103
105{
106 // Set the timestamp to -1, which is invalid anyway, since the time simulation time can only be positive
107 inData.timestamp = -1;
108}
109
111{
113
114 for (auto &mat : polynomialContributions) {
115 mat.setZero();
116 }
117 for (auto &mat : p) {
118 mat.setZero();
119 }
120}
121} // namespace impl
122} // namespace mapping
123} // namespace precice
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.
Main namespace of the precice library.
static std::unique_ptr< precice::Participant > impl
Definition preciceC.cpp:21
bool hasDataAtTimeStamp(double time) const
Check, if the current data vector (in inData or the std::vectors) hold data of time time.
std::vector< Eigen::MatrixXd > polynomialContributions
void setTimeStamp(double time)
Set the timestamp of the MappingDataCache to the specified time.
int getDataDimensions() const
Returns the number of data components.
void resetData()
Reset all data containers to zero.
void resetTimeStamp()
Reset the time stamp associated with the data.
Sample & setZero()
Sets values and gradients to zero.
Definition Sample.hpp:52
int dataDims
The dimensionality of the data.
Definition Sample.hpp:60
Stample containing timestampled Sample.
Definition Stample.hpp:7