Gyselalib++
 
Loading...
Searching...
No Matches
cartesian_to_czarny.hpp
1// SPDX-License-Identifier: MIT
2#pragma once
3
4#include <ddc/ddc.hpp>
5
6#include <sll/view.hpp>
7
8#include "mapping_tools.hpp"
9
10// Pre-declaration of analytical inverse
11template <class R, class Theta, class X, class Y>
13
25template <class X, class Y, class R, class Theta>
27{
28public:
37
39 using CoordArg = ddc::Coordinate<X, Y>;
41 using CoordResult = ddc::Coordinate<R, Theta>;
42
43private:
44 double m_epsilon;
45 double m_e;
46
47public:
59 CartesianToCzarny(double epsilon, double e) : m_epsilon(epsilon), m_e(e) {}
60
67 KOKKOS_FUNCTION CartesianToCzarny(CartesianToCzarny const& other)
68 : m_epsilon(other.epsilon())
69 , m_e(other.e())
70 {
71 }
72
80
81 ~CartesianToCzarny() = default;
82
92
102
110 KOKKOS_FUNCTION double epsilon() const
111 {
112 return m_epsilon;
113 }
114
122 KOKKOS_FUNCTION double e() const
123 {
124 return m_e;
125 }
126
134 KOKKOS_FUNCTION ddc::Coordinate<R, Theta> operator()(ddc::Coordinate<X, Y> const& coord) const
135 {
136 const double x = ddc::get<X>(coord);
137 const double y = ddc::get<Y>(coord);
138 const double ex = 1. + m_epsilon * x;
139 const double ex2 = (m_epsilon * x * x - 2. * x - m_epsilon);
140 const double xi2 = 1. / (1. - m_epsilon * m_epsilon * 0.25);
141 const double xi = Kokkos::sqrt(xi2);
142 const double r = Kokkos::sqrt(y * y * ex * ex / (m_e * m_e * xi2) + ex2 * ex2 * 0.25);
143 double theta = Kokkos::atan2(2. * y * ex, (m_e * xi * ex2));
144 if (theta < 0) {
145 theta = 2 * M_PI + theta;
146 }
147 return ddc::Coordinate<R, Theta>(r, theta);
148 }
149
159};
160
161namespace mapping_detail {
162template <class X, class Y, class R, class Theta, class ExecSpace>
163struct MappingAccessibility<ExecSpace, CartesianToCzarny<X, Y, R, Theta>> : std::true_type
164{
165};
166} // namespace mapping_detail
A class for describing the Czarny 2D mapping.
Definition cartesian_to_czarny.hpp:27
CzarnyToCartesian< R, Theta, X, Y > get_inverse_mapping() const
Get the inverse mapping.
Definition cartesian_to_czarny.hpp:155
KOKKOS_FUNCTION ddc::Coordinate< R, Theta > operator()(ddc::Coordinate< X, Y > const &coord) const
Convert the coordinate (x,y) to the equivalent coordinate.
Definition cartesian_to_czarny.hpp:134
CartesianToCzarny(CartesianToCzarny &&x)=default
Instantiate a CartesianToCzarny from another temporary CartesianToCzarny (rvalue).
CartesianToCzarny & operator=(CartesianToCzarny &&x)=default
Assign a CartesianToCzarny from another temporary CartesianToCzarny (rvalue).
KOKKOS_FUNCTION CartesianToCzarny(CartesianToCzarny const &other)
Instantiate a CartesianToCzarny from another CartesianToCzarny (lvalue).
Definition cartesian_to_czarny.hpp:67
CartesianToCzarny(double epsilon, double e)
Instantiate a CartesianToCzarny from parameters.
Definition cartesian_to_czarny.hpp:59
CartesianToCzarny & operator=(CartesianToCzarny const &x)=default
Assign a CartesianToCzarny from another CartesianToCzarny (lvalue).
ddc::Coordinate< R, Theta > CoordResult
The type of the result of the function described by this mapping.
Definition cartesian_to_czarny.hpp:41
KOKKOS_FUNCTION double epsilon() const
Return the parameter.
Definition cartesian_to_czarny.hpp:110
KOKKOS_FUNCTION double e() const
Return the parameter.
Definition cartesian_to_czarny.hpp:122
ddc::Coordinate< X, Y > CoordArg
The type of the argument of the function described by this mapping.
Definition cartesian_to_czarny.hpp:39
A class for describing the Czarny 2D mapping.
Definition czarny_to_cartesian.hpp:50
Define non periodic real R dimension.
Definition geometry.hpp:31
Define periodic real Theta dimension.
Definition geometry.hpp:42
Define non periodic real X dimension.
Definition geometry.hpp:278
Define non periodic real Y dimension.
Definition geometry.hpp:289