preCICE v3.1.2
Loading...
Searching...
No Matches
Mapping.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4#include <iosfwd>
5
6#include "mesh/Mesh.hpp"
8
9namespace precice {
10namespace mapping {
11
15class Mapping {
16public:
35
45 enum class MeshRequirement {
46 UNDEFINED = 0,
48 VERTEX = 1,
50 FULL = 2
51 };
52
63 enum class InitialGuessRequirement : bool {
64 Required = true,
65 None = false
66 };
67
69 Mapping(Constraint constraint, int dimensions, bool requiresGradientData, InitialGuessRequirement initialGuessRequirement);
70
71 Mapping &operator=(Mapping &&) = delete;
72
74 virtual ~Mapping() = default;
75
82 void setMeshes(
83 const mesh::PtrMesh &input,
84 const mesh::PtrMesh &output);
85
86 const mesh::PtrMesh &getInputMesh() const;
87
88 const mesh::PtrMesh &getOutputMesh() const;
89
92
95
98
100 virtual void computeMapping() = 0;
101
107 bool hasComputedMapping() const;
108
110 virtual bool hasConstraint(const Constraint &constraint) const;
111
113 bool isScaledConsistent() const;
114
116 bool requiresInitialGuess() const;
117
119 const Eigen::VectorXd &initialGuess() const;
120
121 Eigen::VectorXd &initialGuess();
122
124 bool hasInitialGuess() const;
125
127 virtual void clear() = 0;
128
130 void map(int inputDataID, int outputDataID);
132 void map(int inputDataID, int outputDataID, Eigen::VectorXd &initialGuess);
133
147 void map(const time::Sample &input, Eigen::VectorXd &output);
148
169 void map(const time::Sample &input, Eigen::VectorXd &output, Eigen::VectorXd &initialGuess);
170
172 virtual void tagMeshFirstRound() = 0;
173
175 virtual void tagMeshSecondRound() = 0;
176
184 virtual void scaleConsistentMapping(const Eigen::VectorXd &input, Eigen::VectorXd &output, Constraint type) const;
185
187 bool requiresGradientData() const;
188
190 virtual std::string getName() const = 0;
191
192protected:
194 mesh::PtrMesh input() const;
195
197 mesh::PtrMesh output() const;
198
200 void setInputRequirement(MeshRequirement requirement);
201
203 void setOutputRequirement(MeshRequirement requirement);
204
205 int getDimensions() const;
206
209
212
225 virtual void mapConservative(const time::Sample &input, Eigen::VectorXd &output) = 0;
238 virtual void mapConsistent(const time::Sample &input, Eigen::VectorXd &output) = 0;
239
240private:
243
246
249
252
255
257
260
262 Eigen::VectorXd *_initialGuess = nullptr;
263};
264
270
276
277} // namespace mapping
278} // namespace precice
std::ostream & out
Abstract base class for mapping of data from one mesh to another.
Definition Mapping.hpp:15
bool requiresInitialGuess() const
Return true if the mapping requires an initial guess.
Definition Mapping.cpp:50
mesh::PtrMesh output() const
Returns pointer to output mesh.
Definition Mapping.cpp:91
Eigen::VectorXd & initialGuess()
Definition Mapping.cpp:69
virtual void tagMeshSecondRound()=0
Method used by partition. Tags vertices that can be filtered out.
Mapping & operator=(Mapping &&)=delete
Constraint _constraint
Determines whether mapping is consistent or conservative.
Definition Mapping.hpp:242
mesh::PtrMesh _input
Pointer to input mesh.
Definition Mapping.hpp:251
virtual void mapConsistent(const time::Sample &input, Eigen::VectorXd &output)=0
Maps data using a consistent constraint.
MeshRequirement
Specifies requirements for the input and output meshes of a mapping.
Definition Mapping.hpp:45
Constraint
Specifies additional constraints for a mapping.
Definition Mapping.hpp:29
Eigen::VectorXd * _initialGuess
Pointer to the initialGuess set and unset by map.
Definition Mapping.hpp:262
InitialGuessRequirement _initialGuessRequirement
The InitialGuessRequirement of the Mapping.
Definition Mapping.hpp:259
virtual void clear()=0
Removes a computed mapping.
void setMeshes(const mesh::PtrMesh &input, const mesh::PtrMesh &output)
Sets input and output meshes carrying data to be mapped.
Definition Mapping.cpp:27
Mapping(Constraint constraint, int dimensions, bool requiresGradientData, InitialGuessRequirement initialGuessRequirement)
Constructor, takes mapping constraint.
Definition Mapping.cpp:11
mesh::PtrMesh input() const
Returns pointer to input mesh.
Definition Mapping.cpp:86
bool _hasComputedMapping
Flag to indicate whether computeMapping() has been called.
Definition Mapping.hpp:208
Constraint getConstraint() const
Returns the constraint (consistent/conservative) of the mapping.
Definition Mapping.cpp:45
bool isScaledConsistent() const
Returns true if mapping is a form of scaled consistent mapping.
Definition Mapping.cpp:257
virtual void scaleConsistentMapping(const Eigen::VectorXd &input, Eigen::VectorXd &output, Constraint type) const
Scales the consistently mapped output data such that the surface integral of the values on input mesh...
Definition Mapping.cpp:174
void setInputRequirement(MeshRequirement requirement)
Sets the mesh requirement for the input mesh.
Definition Mapping.cpp:96
bool hasInitialGuess() const
True if initialGuess().size() == 0.
Definition Mapping.cpp:55
mesh::PtrMesh _output
Pointer to output mesh.
Definition Mapping.hpp:254
bool requiresGradientData() const
Returns whether the mapping requires gradient data.
Definition Mapping.cpp:113
virtual void tagMeshFirstRound()=0
Method used by partition. Tags vertices that could be owned by this rank.
MeshRequirement _inputRequirement
Requirement on input mesh.
Definition Mapping.hpp:245
virtual std::string getName() const =0
Returns the name of the mapping method for logging purpose.
virtual void mapConservative(const time::Sample &input, Eigen::VectorXd &output)=0
Maps data using a conservative constraint.
virtual void computeMapping()=0
Computes the mapping coefficients from the in- and output mesh.
MeshRequirement _outputRequirement
Requirement on output mesh.
Definition Mapping.hpp:248
const mesh::PtrMesh & getOutputMesh() const
Definition Mapping.cpp:40
void setOutputRequirement(MeshRequirement requirement)
Sets the mesh requirement for the output mesh.
Definition Mapping.cpp:102
bool hasComputedMapping() const
Returns true, if the mapping has been computed.
Definition Mapping.cpp:252
void map(int inputDataID, int outputDataID)
Definition Mapping.cpp:126
MeshRequirement getInputRequirement() const
Returns the requirement on the input mesh.
Definition Mapping.cpp:76
virtual ~Mapping()=default
Destructor, empty.
const mesh::PtrMesh & getInputMesh() const
Definition Mapping.cpp:35
MeshRequirement getOutputRequirement() const
Returns the requirement on the output mesh.
Definition Mapping.cpp:81
virtual bool hasConstraint(const Constraint &constraint) const
Checks whether the mapping has the given constraint or not.
Definition Mapping.cpp:247
InitialGuessRequirement
Specifies whether the mapping requires an initial guess.
Definition Mapping.hpp:63
bool _requiresGradientData
Flag if gradient data is required for the mapping.
Definition Mapping.hpp:211
bool operator<(Mapping::MeshRequirement lhs, Mapping::MeshRequirement rhs)
Definition Mapping.cpp:262
std::ostream & operator<<(std::ostream &out, Mapping::MeshRequirement val)
Definition Mapping.cpp:275
Main namespace of the precice library.