100 for (
auto &targetStample :
_targetData->stamples()) {
101 PyObject *pythonTime = PyFloat_FromDouble(targetStample.timestamp);
102 PyTuple_SetItem(dataArgs, 0, pythonTime);
104 npy_intp targetDim[] = {targetStample.sample.values.size()};
105 double *targetValues =
const_cast<double *
>(targetStample.sample.values.data());
106 _targetValues = PyArray_SimpleNewFromData(1, targetDim, NPY_DOUBLE, targetValues);
107 PRECICE_CHECK(
_targetValues !=
nullptr,
"Creating python target values failed. Please check that the target data name is used by the mesh in action:python.");
112 "Error occurred during call of function performAction() in python module \"{}\". "
113 "The error message is: {}",
125 PRECICE_CHECK(targetStamples.size() == sourceStamples.size(),
"Cannot perform python actions on different amount of samples in target and source data.");
127 for (
size_t i = 0; i < targetStamples.size(); ++i) {
128 auto &targetStample = targetStamples[i];
129 auto &sourceStample = sourceStamples[i];
130 PRECICE_CHECK(
math::equals(sourceStample.timestamp, targetStample.timestamp),
"Trying to perform python action on samples with different timestamps: {} for source data and {} for target data. Time mesh of source data and target data must agree.", sourceStample.timestamp, targetStample.timestamp);
132 PyObject *pythonTime = PyFloat_FromDouble(targetStample.timestamp);
133 PyTuple_SetItem(dataArgs, 0, pythonTime);
135 npy_intp sourceDim[] = {sourceStample.sample.values.size()};
136 double *sourceValues =
const_cast<double *
>(sourceStample.sample.values.data());
137 _sourceValues = PyArray_SimpleNewFromData(1, sourceDim, NPY_DOUBLE, sourceValues);
138 PRECICE_CHECK(
_sourceValues !=
nullptr,
"Creating python source values failed. Please check that the source data name is used by the mesh in action:python.");
141 npy_intp targetDim[] = {targetStample.sample.values.size()};
142 double *targetValues =
const_cast<double *
>(targetStample.sample.values.data());
143 _targetValues = PyArray_SimpleNewFromData(1, targetDim, NPY_DOUBLE, targetValues);
144 PRECICE_CHECK(
_targetValues !=
nullptr,
"Creating python target values failed. Please check that the target data name is used by the mesh in action:python.");
149 "Error occurred during call of function performAction() in python module \"{}\". "
150 "The error message is: {}",
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.