preCICE v3.1.2
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"
10#include "mesh/Utils.hpp"
11
12namespace precice {
13
14namespace testing {
15// Forward declaration to friend the boost test struct
16class DataContextFixture;
17} // namespace testing
18
19namespace impl {
20
30 friend class testing::DataContextFixture; // Make the fixture friend of this class
31public:
38
43
49 int getDataDimensions() const;
50
56 int getSpatialDimensions() const;
57
64
70 MeshID getMeshID() const;
71
78 bool hasGradient() const;
79
88 int mapData(std::optional<double> after = std::nullopt, bool skipZero = false);
89
98 virtual void appendMappingConfiguration(MappingContext &mappingContext, const MeshContext &meshContext) = 0;
99
105 bool hasMapping() const;
106
107 template <typename Container>
112
113protected:
121
124
127
135 void appendMapping(MappingContext mappingContext);
136
142 bool hasReadMapping() const;
143
149 bool hasWriteMapping() const;
150
156 int getMeshVertexCount() const;
157
159 bool isValidVertexID(const VertexID id) const;
160
161private:
164
166
169};
170
171} // namespace impl
172} // namespace precice
Stores one Data object with related mesh.
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.
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)
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)
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.
This class provides a lightweight logger.
Definition Logger.hpp:16
std::optional< std::size_t > locateInvalidVertexID(const Mesh &mesh, const Container &container)
Definition Utils.hpp:148
Main namespace of the precice library.
int MeshID
Definition Types.hpp:30
int VertexID
Definition Types.hpp:13
static std::unique_ptr< precice::Participant > impl
Definition preciceC.cpp:21
Holds a data mapping and related information.
Stores a mesh and related objects and data.