Gyselalib++
 
Loading...
Searching...
No Matches
barycentric_to_cartesian.hpp
1#pragma once
2
3#include <ddc/ddc.hpp>
4
5#include "mapping_tools.hpp"
6
20template <class Corner1Tag, class Corner2Tag, class Corner3Tag, class X, class Y>
22{
23public:
25 using CoordArg = ddc::Coordinate<Corner1Tag, Corner2Tag, Corner3Tag>;
26
28 using CoordResult = ddc::Coordinate<X, Y>;
29
30private:
31 using CartesianCoord = ddc::Coordinate<X, Y>;
32
33private:
34 CartesianCoord m_corner1;
35 CartesianCoord m_corner2;
36 CartesianCoord m_corner3;
37
38public:
47 CartesianCoord const& corner1,
48 CartesianCoord const& corner2,
49 CartesianCoord const& corner3)
50 : m_corner1(corner1)
51 , m_corner2(corner2)
52 , m_corner3(corner3)
53 {
54 }
55
61
67
70
77
84
92 KOKKOS_FUNCTION CoordResult operator()(CoordArg const& pos) const
93 {
94 const double l1 = ddc::get<Corner1Tag>(pos);
95 const double l2 = ddc::get<Corner2Tag>(pos);
96 const double l3 = ddc::get<Corner3Tag>(pos);
97
98 const double x1 = ddc::get<X>(m_corner1);
99 const double x2 = ddc::get<X>(m_corner2);
100 const double x3 = ddc::get<X>(m_corner3);
101 const double y1 = ddc::get<Y>(m_corner1);
102 const double y2 = ddc::get<Y>(m_corner2);
103 const double y3 = ddc::get<Y>(m_corner3);
104
105 const double x = x1 * l1 + x2 * l2 + x3 * l3;
106 const double y = y1 * l1 + y2 * l2 + y3 * l3;
107
108 return CartesianCoord(x, y);
109 }
110};
A class to convert barycentric coordinates to cartesian coordinates on a triangle.
Definition barycentric_to_cartesian.hpp:22
BarycentricToCartesian(BarycentricToCartesian const &other)=default
A copy operator for the mapping operator.
ddc::Coordinate< Corner1Tag, Corner2Tag, Corner3Tag > CoordArg
The type of a coordinate in the barycentric coordinate system.
Definition barycentric_to_cartesian.hpp:25
BarycentricToCartesian & operator=(BarycentricToCartesian &&x)=default
A r-value copy operator for the mapping operator.
KOKKOS_FUNCTION CoordResult operator()(CoordArg const &pos) const
The operator to get the equivalent cartesian coordinate of the barycentric coordinate.
Definition barycentric_to_cartesian.hpp:92
BarycentricToCartesian(CartesianCoord const &corner1, CartesianCoord const &corner2, CartesianCoord const &corner3)
Construct the operator which converts between the coordinate systems.
Definition barycentric_to_cartesian.hpp:46
BarycentricToCartesian & operator=(BarycentricToCartesian const &x)=default
A copy operator for the mapping operator.
~BarycentricToCartesian()=default
The destructor of the mapping operator.
BarycentricToCartesian(BarycentricToCartesian &&x)=default
A r-value copy operator for the mapping operator.
ddc::Coordinate< X, Y > CoordResult
The type of a coordinate in the cartesian coordinate system.
Definition barycentric_to_cartesian.hpp:28