preCICE v3.2.0
Loading...
Searching...
No Matches
DataContext.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <optional>
5#include <string>
6
7#include "MappingContext.hpp"
8#include "MeshContext.hpp"
12#include "mesh/Utils.hpp"
13namespace precice {
14
15namespace testing {
16// Forward declaration to friend the boost test struct
18} // namespace testing
19
20namespace impl {
21
31 friend class testing::DataContextFixture; // Make the fixture friend of this class
32public:
39
44
50 int getDataDimensions() const;
51
57 int getSpatialDimensions() const;
58
65
71 MeshID getMeshID() const;
72
79 bool hasGradient() const;
80
89 int mapData(std::optional<double> after = std::nullopt, bool skipZero = false);
90
99 virtual void appendMappingConfiguration(MappingContext &mappingContext, const MeshContext &meshContext) = 0;
100
106 bool hasMapping() const;
107
108 template <typename Container>
113
131 void addJustInTimeMapping(MappingContext &mappingContext, MeshContext &meshContext);
132
143 {
144 if (mappingCache) {
145 justInTimeMapping->initializeMappingDataCache(*mappingCache);
146 mappingCache->resetData();
147 }
148 }
149
156 {
157 if (mappingCache) {
158 mappingCache->resetTimeStamp();
159 }
160 }
161
168 {
170 if (mappingCache) {
171 mappingCache->resetData();
172 }
173 }
174
175protected:
183
186
190
211
214
222 void appendMapping(MappingContext mappingContext);
223
229 bool hasReadMapping() const;
230
236 bool hasWriteMapping() const;
237
243 int getMeshVertexCount() const;
244
246 bool isValidVertexID(const VertexID id) const;
247
249
250private:
252
254
257};
258
259} // namespace impl
260} // namespace precice
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...
void initializeMappingDataCache()
Initializes the MappingDataCache.
mapping::PtrMapping justInTimeMapping
The just-in-time mapping for this data context.
MeshID getMeshID() const
Get the ID of _mesh.
void invalidateMappingCache()
Resets the time stamp of the MappingDataCache.
void appendMapping(MappingContext mappingContext)
Helper to append a mappingContext, fromData and toData to the corresponding data containers.
virtual void appendMappingConfiguration(MappingContext &mappingContext, const MeshContext &meshContext)=0
Adds a MappingContext and the MeshContext required by the mapping to the corresponding DataContext da...
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.
std::optional< std::size_t > locateInvalidVertexID(const Container &c)
void invalidateMappingCacheAndResetData()
Resets the time stamp of the MappingDataCache and resets the data it holds.
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.
This class provides a lightweight logger.
Definition Logger.hpp:17
std::shared_ptr< Mapping > PtrMapping
provides Mesh, Data and primitives.
std::shared_ptr< Data > PtrData
std::shared_ptr< Mesh > PtrMesh
std::optional< std::size_t > locateInvalidVertexID(const Mesh &mesh, const Container &container)
Definition Utils.hpp:147
contains the testing framework.
Definition helper.hpp:9
Main namespace of the precice library.
int MeshID
Definition Types.hpp:30
int VertexID
Definition Types.hpp:13
Holds a data mapping and related information.
Stores a mesh and related objects and data.