preCICE v3.2.0
Loading...
Searching...
No Matches
precice::impl::WriteDataContext Class Reference

Stores one Data object with related mesh. Context stores data to be written to and potentially provides a write mapping. More...

#include <WriteDataContext.hpp>

Inheritance diagram for precice::impl::WriteDataContext:
[legend]
Collaboration diagram for precice::impl::WriteDataContext:
[legend]

Public Member Functions

 WriteDataContext (mesh::PtrData data, mesh::PtrMesh mesh)
 Construct a new WriteDataContext object without a mapping.
void resetBufferedData ()
 Resets the writeDataBuffer and the mapping data cache.
void trimAfter (double time)
 Removes stample before time and (if mapping exists) fromData or toData.
void writeAndMapValues (::precice::span< const double > coordinates, ::precice::span< const double > values)
 Forwards the just-in-time mapping API call for writing data to the data context.
void completeJustInTimeMapping ()
 Evaluates the MappingDataCache and stores the result in the _writeDataBuffer.
void writeValuesIntoDataBuffer (::precice::span< const VertexID > vertices, ::precice::span< const double > values)
 Store values in _writeDataBuffer.
void writeGradientsIntoDataBuffer (::precice::span< const VertexID > vertices, ::precice::span< const double > gradients)
 Store gradients in _writeDataBuffer.
void resizeBufferTo (int size)
void storeBufferedData (double currentTime)
 Store data from _writeDataBuffer in persistent storage.
void appendMappingConfiguration (MappingContext &mappingContext, const MeshContext &meshContext) override
 Adds a MappingContext and the MeshContext required by the write mapping to the corresponding WriteDataContext data structures.
 WriteDataContext (const WriteDataContext &copy)=delete
 Disable copy construction.
WriteDataContextoperator= (const WriteDataContext &assign)=delete
 Disable assignment construction.
 WriteDataContext (WriteDataContext &&)=default
 Move constructor, use the implicitly declared.
WriteDataContextoperator= (WriteDataContext &&)=default
Public Member Functions inherited from precice::impl::DataContext
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)
bool hasMapping () const
 Informs the user whether this DataContext has any _mappingContext.
template<typename Container>
std::optional< std::size_tlocateInvalidVertexID (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.

Private Attributes

time::Sample _writeDataBuffer
 Buffer to store written data until it is copied to _providedData->timeStepsStorage()

Static Private Attributes

static logging::Logger _log {"impl::WriteDataContext"}

Additional Inherited Members

Protected Member Functions inherited from precice::impl::DataContext
 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 inherited from precice::impl::DataContext
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::MappingDataCachemappingCache
 Cache for just-in-time mapping.
mapping::PtrMapping justInTimeMapping
 The just-in-time mapping for this data context.
mesh::PtrMesh _mesh

Detailed Description

Stores one Data object with related mesh. Context stores data to be written to and potentially provides a write mapping.

Derived from DataContext

Definition at line 16 of file WriteDataContext.hpp.

Constructor & Destructor Documentation

◆ WriteDataContext() [1/3]

precice::impl::WriteDataContext::WriteDataContext ( mesh::PtrData data,
mesh::PtrMesh mesh )

Construct a new WriteDataContext object without a mapping.

Parameters
dataData associated with this WriteDataContext.
meshMesh associated with this WriteDataContext.

Definition at line 7 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ WriteDataContext() [2/3]

precice::impl::WriteDataContext::WriteDataContext ( const WriteDataContext & copy)
delete

Disable copy construction.

Here is the call graph for this function:

◆ WriteDataContext() [3/3]

precice::impl::WriteDataContext::WriteDataContext ( WriteDataContext && )
default

Move constructor, use the implicitly declared.

Here is the call graph for this function:

Member Function Documentation

◆ appendMappingConfiguration()

void precice::impl::WriteDataContext::appendMappingConfiguration ( MappingContext & mappingContext,
const MeshContext & meshContext )
overridevirtual

Adds a MappingContext and the MeshContext required by the write mapping to the corresponding WriteDataContext data structures.

A write mapping maps _providedData to _toData. A WriteDataContext already has _providedData, but additionally requires _toData.

Parameters
[in]mappingContextContext of write mapping
[in]meshContextContext of mesh this write mapping is mapping to (_toData)

Implements precice::impl::DataContext.

Definition at line 124 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ completeJustInTimeMapping()

void precice::impl::WriteDataContext::completeJustInTimeMapping ( )

Evaluates the MappingDataCache and stores the result in the _writeDataBuffer.

If a just-in-time mapping stores intermediate results in the mappingCache, we need to finalize the mapping in the cache and store the mapped values in the _writeDataBuffer.

See also writeAndMapValues and the documentation of Mapping::completeJustInTimeMapping as well as the impl::MappingDataCache class for more details.

This function needs to be called before calling storeBufferedData, which stores the buffer into the time step storage.

Definition at line 32 of file WriteDataContext.cpp.

◆ operator=() [1/2]

WriteDataContext & precice::impl::WriteDataContext::operator= ( const WriteDataContext & assign)
delete

Disable assignment construction.

Here is the call graph for this function:

◆ operator=() [2/2]

WriteDataContext & precice::impl::WriteDataContext::operator= ( WriteDataContext && )
default
Here is the call graph for this function:

◆ resetBufferedData()

void precice::impl::WriteDataContext::resetBufferedData ( )

Resets the writeDataBuffer and the mapping data cache.

Definition at line 14 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ resizeBufferTo()

void precice::impl::WriteDataContext::resizeBufferTo ( int size)

Definition at line 89 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ storeBufferedData()

void precice::impl::WriteDataContext::storeBufferedData ( double currentTime)

Store data from _writeDataBuffer in persistent storage.

Parameters
[in]currentTimetime data should be associated with

Definition at line 119 of file WriteDataContext.cpp.

◆ trimAfter()

void precice::impl::WriteDataContext::trimAfter ( double time)

Removes stample before time and (if mapping exists) fromData or toData.

Parameters
timethe point in time after which to remove samples

Definition at line 21 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ writeAndMapValues()

void precice::impl::WriteDataContext::writeAndMapValues ( ::precice::span< const double > coordinates,
::precice::span< const double > values )

Forwards the just-in-time mapping API call for writing data to the data context.

writeAndMapValues then forwards the arguments along with a target buffer to the justInTimeMapping this DataContext holds. The function always forwards both, the _writeDataBuffer and the mappingCache. The justInTimeMapping then decides, whether the data can directly be stored in the actual target _writeDataBuffer or whether intermediate results are stored in the mappingCache.

If written data is stored in the mappingCache, the function completeJustInTimeMapping is responsible for evaluating the cache and storing the result in the _writeDataBuffer.

See also the documentation of the impl::MappingDataCache class.

Parameters
[in]coordinatesProvided by the user through the API function
[in]valuesContaining the write data values given by the user

Definition at line 42 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ writeGradientsIntoDataBuffer()

void precice::impl::WriteDataContext::writeGradientsIntoDataBuffer ( ::precice::span< const VertexID > vertices,
::precice::span< const double > gradients )

Store gradients in _writeDataBuffer.

Parameters
[in]verticesids of data
[in]gradientsgradients of data

Definition at line 73 of file WriteDataContext.cpp.

Here is the call graph for this function:

◆ writeValuesIntoDataBuffer()

void precice::impl::WriteDataContext::writeValuesIntoDataBuffer ( ::precice::span< const VertexID > vertices,
::precice::span< const double > values )

Store values in _writeDataBuffer.

Parameters
[in]verticesids of data
[in]valuesvalues of data

Definition at line 59 of file WriteDataContext.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ _log

logging::Logger precice::impl::WriteDataContext::_log {"impl::WriteDataContext"}
staticprivate

Definition at line 117 of file WriteDataContext.hpp.

◆ _writeDataBuffer

time::Sample precice::impl::WriteDataContext::_writeDataBuffer
private

Buffer to store written data until it is copied to _providedData->timeStepsStorage()

Definition at line 120 of file WriteDataContext.hpp.


The documentation for this class was generated from the following files: