preCICE v3.2.0
|
Stores one Data object with related mesh. More...
#include <DataContext.hpp>
Public Member Functions | |
std::string | getDataName () const |
Get the Name of _providedData. | |
void | resetInitialGuesses () |
Resets initial guesses of transient mappings to zero. | |
int | getDataDimensions () const |
Get the dimensions of _providedData. | |
int | getSpatialDimensions () const |
Get the spatial dimensions of _providedData. | |
std::string | getMeshName () const |
Get the name of _mesh. | |
MeshID | getMeshID () const |
Get the ID of _mesh. | |
bool | hasGradient () const |
Returns whether _providedData has gradient. | |
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) | |
virtual void | appendMappingConfiguration (MappingContext &mappingContext, const MeshContext &meshContext)=0 |
Adds a MappingContext and the MeshContext required by the mapping to the corresponding DataContext data structures. | |
bool | hasMapping () const |
Informs the user whether this DataContext has any _mappingContext. | |
template<typename Container> | |
std::optional< std::size_t > | locateInvalidVertexID (const Container &c) |
void | addJustInTimeMapping (MappingContext &mappingContext, MeshContext &meshContext) |
Attach a just-in-time mapping to this data context and setup a corresponding MappingDataCache. | |
void | initializeMappingDataCache () |
Initializes the MappingDataCache. | |
void | invalidateMappingCache () |
Resets the time stamp of the MappingDataCache. | |
void | invalidateMappingCacheAndResetData () |
Resets the time stamp of the MappingDataCache and resets the data it holds. |
Protected Member Functions | |
DataContext (mesh::PtrData data, mesh::PtrMesh mesh) | |
Construct a new DataContext without a mapping. Protected, because only ReadDataContext and WriteDataContext should use this constructor. | |
void | appendMapping (MappingContext mappingContext) |
Helper to append a mappingContext, fromData and toData to the corresponding data containers. | |
bool | hasReadMapping () const |
Informs the user whether this DataContext has any read mapping. | |
bool | hasWriteMapping () const |
Informs the user whether this DataContext has any write mapping. | |
int | getMeshVertexCount () const |
Get the number of vertices of mesh. | |
bool | isValidVertexID (const VertexID id) const |
Returns true if the given vertexID is valid. |
Protected Attributes | |
std::vector< MappingContext > | _mappingContexts |
Defines all mappings associated to this DataContext. A DataContext may also exist without a mapping. | |
mesh::PtrData | _providedData |
std::unique_ptr< mapping::impl::MappingDataCache > | mappingCache |
Cache for just-in-time mapping. | |
mapping::PtrMapping | justInTimeMapping |
The just-in-time mapping for this data context. | |
mesh::PtrMesh | _mesh |
Private Types | |
using | FromToDataIDs = std::pair<int, int> |
Private Attributes | |
std::map< FromToDataIDs, Eigen::VectorXd > | _initialGuesses |
Static Private Attributes | |
static logging::Logger | _log {"impl::DataContext"} |
Unique mesh associated with _providedData. |
Friends | |
class | testing::DataContextFixture |
Stores one Data object with related mesh.
Definition at line 30 of file DataContext.hpp.
|
private |
Definition at line 255 of file DataContext.hpp.
|
protected |
Construct a new DataContext without a mapping. Protected, because only ReadDataContext and WriteDataContext should use this constructor.
data | Data associated with this DataContext. |
mesh | Mesh associated with this DataContext. |
Definition at line 12 of file DataContext.cpp.
void precice::impl::DataContext::addJustInTimeMapping | ( | MappingContext & | mappingContext, |
MeshContext & | meshContext ) |
Attach a just-in-time mapping to this data context and setup a corresponding MappingDataCache.
A just-in-time mapping ( justInTimeMapping
) might be shared across multiple data contexts (it's a PtrMapping). The MappingDataCache ( mappingCache
), however, is unique for each data context.
There is no need to put this function into a derived class: The Mapping class knows the direction of the mapping and the DataContext is directly called via the API function. Since all mappings within the DataContexts (stored in a std::vector as _mappingContexts
) only call and steer the mapData() execution (and not the computeMapping() execution), we don't register the just-in-time mapping in the _mappingContexts
data structures. For just-in-time mappings, only the computeMapping() part is relevant, whereas the mapData() part is essentially handled through the API function calls.
[in] | mappingContext | The MappingContext which holds the mapping configuration |
[in] | meshContext | The MeshContext holding the relevant data to map |
Definition at line 85 of file DataContext.cpp.
|
protected |
Helper to append a mappingContext, fromData and toData to the corresponding data containers.
mappingContext | MappingContext this DataContext will be associated to. |
Definition at line 69 of file DataContext.cpp.
|
pure virtual |
Adds a MappingContext and the MeshContext required by the mapping to the corresponding DataContext data structures.
A mapping maps the given data from or to _providedData (depending on whether it is a read or write mapping).
[in] | mappingContext | Context of the mapping |
[in] | meshContext | Context of mesh this mapping is mapping from or to |
Implemented in precice::impl::ReadDataContext, and precice::impl::WriteDataContext.
int precice::impl::DataContext::getDataDimensions | ( | ) | const |
Get the dimensions of _providedData.
Definition at line 33 of file DataContext.cpp.
std::string precice::impl::DataContext::getDataName | ( | ) | const |
Get the Name of _providedData.
Definition at line 20 of file DataContext.cpp.
MeshID precice::impl::DataContext::getMeshID | ( | ) | const |
std::string precice::impl::DataContext::getMeshName | ( | ) | const |
Get the name of _mesh.
Definition at line 45 of file DataContext.cpp.
|
protected |
Get the number of vertices of mesh.
Definition at line 51 of file DataContext.cpp.
int precice::impl::DataContext::getSpatialDimensions | ( | ) | const |
Get the spatial dimensions of _providedData.
Definition at line 39 of file DataContext.cpp.
bool precice::impl::DataContext::hasGradient | ( | ) | const |
Returns whether _providedData has gradient.
Definition at line 63 of file DataContext.cpp.
bool precice::impl::DataContext::hasMapping | ( | ) | const |
Informs the user whether this DataContext has any _mappingContext.
Definition at line 105 of file DataContext.cpp.
|
protected |
Informs the user whether this DataContext has any read mapping.
Definition at line 176 of file DataContext.cpp.
|
protected |
Informs the user whether this DataContext has any write mapping.
Definition at line 181 of file DataContext.cpp.
|
inline |
Initializes the MappingDataCache.
Essentially a forward to Mapping::initializeMappingDataCache, where we provide the cache from this class itself.
See Mapping::initializeMappingDataCache and the MappingDataCache documentation for more information.
Definition at line 142 of file DataContext.hpp.
|
inline |
Resets the time stamp of the MappingDataCache.
See also the impl::MappingDataCache for more details.
Definition at line 155 of file DataContext.hpp.
|
inline |
Resets the time stamp of the MappingDataCache and resets the data it holds.
See also the impl::MappingDataCache for more details.
Definition at line 167 of file DataContext.hpp.
|
protected |
Returns true if the given vertexID is valid.
Definition at line 186 of file DataContext.cpp.
|
inline |
int precice::impl::DataContext::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)
[in] | after | only map samples after this optional time |
[in] | skipZero | set output sample to zero if the input sample is zero too |
Definition at line 110 of file DataContext.cpp.
void precice::impl::DataContext::resetInitialGuesses | ( | ) |
Resets initial guesses of transient mappings to zero.
Definition at line 26 of file DataContext.cpp.
|
friend |
Definition at line 31 of file DataContext.hpp.
|
private |
Definition at line 256 of file DataContext.hpp.
|
staticprivate |
Unique mesh associated with _providedData.
Definition at line 253 of file DataContext.hpp.
|
protected |
Defines all mappings associated to this DataContext. A DataContext may also exist without a mapping.
Definition at line 185 of file DataContext.hpp.
|
protected |
Definition at line 248 of file DataContext.hpp.
|
protected |
Unique data this context is associated with For direct and just-in-time mapping, this is data from the received mesh
Definition at line 189 of file DataContext.hpp.
|
protected |
The just-in-time mapping for this data context.
Definition at line 213 of file DataContext.hpp.
|
protected |
Cache for just-in-time mapping.
Purpose: For just-in-time mapping, we want to pre-compute as much data as possible to not have expensive operations repeated in every read/write call of the mapping class.
The cache itself is updated in the associated Mapping class where it is used. However, storing it in the mapping class is not useful, as we might map multiple data from the same mesh. In preCICE, this leads to one (shared) MappingContext in different DataContexts. Hence, we store the data in this unique Mesh-Data pair.
The _mappingContexts
in this class are a std::vector for multiple mappings associated to the same DataContext. However, for one DataContext (read or write) there can only be one just-in-time mapping. For conventional mappings, multiple MappingContexts can only occur in write direction (write to one local mesh, map it to different remote meshes). Since the just-in-time mapping operates on the remote meshes, this multiplicity cannot occur. Thus, one cache per DataContext is enough. See the documentation of impl::MappingDataCache for more information.
Definition at line 210 of file DataContext.hpp.