48 return _mesh->getName();
54 return _mesh->nVertices();
60 return _mesh->getID();
76 PRECICE_ASSERT(!((context.mapping == mappingContext.
mapping) && (context.fromData == mappingContext.
fromData) && (context.fromData == mappingContext.
toData)),
"The appended mapping already exists.");
95 int executedMappings{0};
100 "There must be samples at this point!");
103 const auto timestampExists = [times = context.toData->timeStepsStorage().getTimes()](
double lookup) ->
bool {
105 return math::equals(time, lookup);
109 auto &mapping = *context.mapping;
111 const auto dataDims = context.fromData->getDimensions();
113 for (
const auto &stample : context.fromData->stamples()) {
116 PRECICE_DEBUG(
"Skipping stample t={} (not after {})", stample.timestamp, *after);
120 if (timestampExists(stample.timestamp)) {
121 PRECICE_DEBUG(
"Skipping stample t={} (exists)", stample.timestamp);
127 Eigen::VectorXd::Zero(dataDims * mapping.getOutputMesh()->nVertices())};
132 PRECICE_INFO(
"Mapping \"{}\" for t={} from \"{}\" to \"{}\"{}",
133 getDataName(), stample.timestamp, mapping.getInputMesh()->getName(), mapping.getOutputMesh()->getName(),
134 (skipMapping ?
" (skipped zero sample)" :
""));
136 if (mapping.requiresInitialGuess()) {
137 const FromToDataIDs key{context.fromData->getID(), context.toData->getID()};
140 mapping.map(stample.sample, outSample.values);
147 context.toData->setSampleAtTime(stample.timestamp, std::move(outSample));
150 return executedMappings;
166 return _mesh->isValidVertexID(
id);
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_INFO(...)
#define PRECICE_ASSERT(...)
std::map< FromToDataIDs, Eigen::VectorXd > _initialGuesses
int getMeshVertexCount() const
Get the number of vertices of mesh.
bool hasWriteMapping() const
Informs the user whether this DataContext has any write mapping.
DataContext(mesh::PtrData data, mesh::PtrMesh mesh)
Construct a new DataContext without a mapping. Protected, because only ReadDataContext and WriteDataC...
MeshID getMeshID() const
Get the ID of _mesh.
void appendMapping(MappingContext mappingContext)
Helper to append a mappingContext, fromData and toData to the corresponding data containers.
std::string getDataName() const
Get the Name of _providedData.
bool hasGradient() const
Returns whether _providedData has gradient.
int getDataDimensions() const
Get the dimensions of _providedData.
int mapData(std::optional< double > after=std::nullopt, bool skipZero=false)
Perform the mapping for mapping contexts and the corresponding data context (from and to data)
bool hasMapping() const
Informs the user whether this DataContext has any _mappingContext.
int getSpatialDimensions() const
Get the spatial dimensions of _providedData.
bool hasReadMapping() const
Informs the user whether this DataContext has any read mapping.
bool isValidVertexID(const VertexID id) const
Returns true if the given vertexID is valid.
mesh::PtrData _providedData
Unique data this context is associated with.
void resetInitialGuesses()
Resets initial guesses of transient mappings to zero.
static logging::Logger _log
std::vector< MappingContext > _mappingContexts
Defines all mappings associated to this DataContext. A DataContext may also exist without a mapping.
mesh::PtrMesh _mesh
Unique mesh associated with _providedData.
std::string getMeshName() const
Get the name of _mesh.
static double l2norm(const Eigen::VectorXd &vec)
The l2 norm of a vector is calculated on distributed data.
std::enable_if< std::is_arithmetic< Scalar >::value, bool >::type smallerEquals(Scalar A, Scalar B, Scalar tolerance=NUMERICAL_ZERO_DIFFERENCE)
constexpr double NUMERICAL_ZERO_DIFFERENCE
const RangePreview< Iter > previewRange(Size n, const Range &range)
Holds a data mapping and related information.
mesh::PtrData fromData
data which is mapped from mesh
mapping::PtrMapping mapping
Data mapping.
mesh::PtrData toData
data which is mapped to mesh