5 #include "coordinate_converter.hpp"
20 template <
class X,
class Y,
class Corner1Tag,
class Corner2Tag,
class Corner3Tag>
23 ddc::Coordinate<X, Y>,
24 ddc::Coordinate<Corner1Tag, Corner2Tag, Corner3Tag>>
26 ddc::Coordinate<Corner1Tag, Corner2Tag, Corner3Tag>,
27 ddc::Coordinate<X, Y>>
98 const double x = ddc::get<X>(pos);
99 const double y = ddc::get<Y>(pos);
100 const double x1 = ddc::get<X>(m_corner1);
101 const double x2 = ddc::get<X>(m_corner2);
102 const double x3 = ddc::get<X>(m_corner3);
103 const double y1 = ddc::get<Y>(m_corner1);
104 const double y2 = ddc::get<Y>(m_corner2);
105 const double y3 = ddc::get<Y>(m_corner3);
107 const double div = ((y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3));
108 const double lam1 = ((y2 - y3) * (x - x3) + (x3 - x2) * (y - y3)) / div;
109 const double lam2 = ((y - y3) * (x1 - x3) + (x3 - x) * (y1 - y3)) / div;
110 const double lam3 = 1 - lam1 - lam2;
123 const double l1 = ddc::get<Corner1Tag>(pos);
124 const double l2 = ddc::get<Corner2Tag>(pos);
125 const double l3 = ddc::get<Corner3Tag>(pos);
127 const double x1 = ddc::get<X>(m_corner1);
128 const double x2 = ddc::get<X>(m_corner2);
129 const double x3 = ddc::get<X>(m_corner3);
130 const double y1 = ddc::get<Y>(m_corner1);
131 const double y2 = ddc::get<Y>(m_corner2);
132 const double y3 = ddc::get<Y>(m_corner3);
134 const double x = x1 * l1 + x2 * l2 + x3 * l3;
135 const double y = y1 * l1 + y2 * l2 + y3 * l3;
A class to convert cartesian coordinates to barycentric coordinates on a triangle.
Definition: barycentric_coordinates.hpp:28
ddc::Coordinate< X, Y > CartesianCoord
The type of a coordinate in the cartesian coordinate system.
Definition: barycentric_coordinates.hpp:34
CartesianToBarycentricCoordinates(CartesianToBarycentricCoordinates &&x)=default
A r-value copy operator for the mapping operator.
KOKKOS_FUNCTION CartesianCoord operator()(BarycentricCoord const &pos) const final
The operator to get the equivalent cartesian coordinate of the barycentric coordinate.
Definition: barycentric_coordinates.hpp:121
CartesianToBarycentricCoordinates(CartesianToBarycentricCoordinates const &other)=default
A copy operator for the mapping operator.
CartesianToBarycentricCoordinates(CartesianCoord const &corner1, CartesianCoord const &corner2, CartesianCoord const &corner3)
Construct the operator which converts between the coordinate systems.
Definition: barycentric_coordinates.hpp:49
~CartesianToBarycentricCoordinates()=default
The destructor of the mapping operator.
CartesianToBarycentricCoordinates & operator=(CartesianToBarycentricCoordinates &&x)=default
A r-value copy operator for the mapping operator.
CartesianToBarycentricCoordinates & operator=(CartesianToBarycentricCoordinates const &x)=default
A copy operator for the mapping operator.
KOKKOS_FUNCTION BarycentricCoord operator()(CartesianCoord const &pos) const final
The operator to get the equivalent barycentric coordinate of the cartesian coordinate.
Definition: barycentric_coordinates.hpp:96
ddc::Coordinate< Corner1Tag, Corner2Tag, Corner3Tag > BarycentricCoord
The type of a coordinate in the barycentric coordinate system.
Definition: barycentric_coordinates.hpp:31
An operator to convert from the start coordinate type to the end coordinate type.
Definition: coordinate_converter.hpp:13