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.");
94 mappingContext.
toData = data;
115 int executedMappings{0};
120 "Data {0} on mesh {1} didn't contain any data samples while attempting to map to mesh {2}. "
121 "Check your exchange tags to ensure your coupling scheme exchanges the data or the participant produces it using an action. "
122 "The expected exchange tag should look like this: <exchange data=\"{0}\" mesh=\"{1}\" from=... to=... />.",
123 context.fromData->getName(), context.mapping->getInputMesh()->getName(), context.mapping->getOutputMesh()->getName());
126 const auto timestampExists = [times = context.toData->timeStepsStorage().getTimes()](
double lookup) ->
bool {
128 return math::equals(time, lookup);
132 auto &
mapping = *context.mapping;
134 const auto dataDims = context.fromData->getDimensions();
136 for (
const auto &stample : context.fromData->stamples()) {
139 PRECICE_DEBUG(
"Skipping stample t={} (not after {})", stample.timestamp, *after);
143 if (timestampExists(stample.timestamp)) {
144 PRECICE_DEBUG(
"Skipping stample t={} (exists)", stample.timestamp);
150 Eigen::VectorXd::Zero(dataDims *
mapping.getOutputMesh()->nVertices())};
155 PRECICE_INFO(
"Mapping \"{}\" for t={} from \"{}\" to \"{}\"{}",
157 (skipMapping ?
" (skipped zero sample)" :
""));
159 if (
mapping.requiresInitialGuess()) {
160 const FromToDataIDs key{context.fromData->getID(), context.toData->getID()};
170 context.toData->setSampleAtTime(stample.timestamp, std::move(outSample));
173 return executedMappings;
189 return _mesh->isValidVertexID(
id);
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_INFO(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
std::map< FromToDataIDs, Eigen::VectorXd > _initialGuesses
int getMeshVertexCount() const
Get the number of vertices of mesh.
std::pair< int, int > FromToDataIDs
bool hasWriteMapping() const
Informs the user whether this DataContext has any write mapping.
void addJustInTimeMapping(MappingContext &mappingContext, MeshContext &meshContext)
Attach a just-in-time mapping to this data context and setup a corresponding MappingDataCache.
DataContext(mesh::PtrData data, mesh::PtrMesh mesh)
Construct a new DataContext without a mapping. Protected, because only ReadDataContext and WriteDataC...
mapping::PtrMapping justInTimeMapping
The just-in-time mapping for this data context.
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)
std::unique_ptr< mapping::impl::MappingDataCache > mappingCache
Cache for just-in-time mapping.
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
void resetInitialGuesses()
Resets initial guesses of transient mappings to zero.
static logging::Logger _log
Unique mesh associated with _providedData.
std::vector< MappingContext > _mappingContexts
Defines all mappings associated to this DataContext. A DataContext may also exist without a mapping.
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.
contains data mapping from points to meshes.
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
provides Mesh, Data and primitives.
std::shared_ptr< Data > PtrData
std::shared_ptr< Mesh > PtrMesh
contains the time interpolation logic.
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
Stores a mesh and related objects and data.
mesh::PtrMesh mesh
Mesh holding the geometry data structure.