10#include "mapping_tools.hpp"
13template <
class X,
class Y,
class R,
class Theta>
48template <
class R,
class Theta,
class X,
class Y>
145 KOKKOS_FUNCTION
double e()
const
157 KOKKOS_FUNCTION ddc::Coordinate<X, Y>
operator()(ddc::Coordinate<R, Theta>
const& coord)
const
159 const double r = ddc::get<R>(coord);
160 const double theta = ddc::get<Theta>(coord);
162 = Kokkos::sqrt(m_epsilon * (m_epsilon + 2.0 * r * Kokkos::cos(theta)) + 1.0);
164 const double x = (1.0 - tmp1) / m_epsilon;
165 const double y = m_e * r * Kokkos::sin(theta)
166 / (Kokkos::sqrt(1.0 - 0.25 * m_epsilon * m_epsilon) * (2.0 - tmp1));
168 return ddc::Coordinate<X, Y>(x, y);
179 KOKKOS_FUNCTION
double jacobian(ddc::Coordinate<R, Theta>
const& coord)
const
181 const double r = ddc::get<R>(coord);
182 const double theta = ddc::get<Theta>(coord);
183 const double xi = Kokkos::sqrt(1. / (1. - m_epsilon * m_epsilon * 0.25));
184 return -r / Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * Kokkos::cos(theta))) * m_e
186 / (2 - Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * Kokkos::cos(theta))));
208 KOKKOS_FUNCTION
void jacobian_matrix(ddc::Coordinate<R, Theta>
const& coord, Matrix_2x2& matrix)
211 const double r = ddc::get<R>(coord);
212 const double theta = ddc::get<Theta>(coord);
214 const double sin_theta = Kokkos::sin(theta);
215 const double cos_theta = Kokkos::cos(theta);
216 const double xi2 = 1. / (1. - m_epsilon * m_epsilon * 0.25);
217 const double xi = Kokkos::sqrt(xi2);
218 const double sqrt_eps = Kokkos::sqrt(m_epsilon * (m_epsilon + 2.0 * r * cos_theta) + 1.0);
219 const double sqrt_eps_2 = 2.0 - sqrt_eps;
221 matrix[0][0] = -cos_theta / sqrt_eps;
222 matrix[0][1] = r * sin_theta / sqrt_eps;
223 matrix[1][0] = m_e * m_epsilon * r * sin_theta * cos_theta * xi
224 / (sqrt_eps_2 * sqrt_eps_2 * sqrt_eps)
225 + m_e * sin_theta * xi / sqrt_eps_2;
227 * (-m_e * m_epsilon * r * sin_theta * sin_theta * xi
228 / (sqrt_eps_2 * sqrt_eps_2 * sqrt_eps)
229 + m_e * cos_theta * xi / sqrt_eps_2);
243 KOKKOS_FUNCTION
double jacobian_11(ddc::Coordinate<R, Theta>
const& coord)
const
245 const double r = ddc::get<R>(coord);
246 const double theta = ddc::get<Theta>(coord);
247 return -Kokkos::cos(theta)
248 / Kokkos::sqrt(m_epsilon * (m_epsilon + 2.0 * r * Kokkos::cos(theta)) + 1.0);
262 KOKKOS_FUNCTION
double jacobian_12(ddc::Coordinate<R, Theta>
const& coord)
const
264 const double r = ddc::get<R>(coord);
265 const double theta = ddc::get<Theta>(coord);
266 return r * Kokkos::sin(theta)
267 / Kokkos::sqrt(m_epsilon * (m_epsilon + 2.0 * r * Kokkos::cos(theta)) + 1.0);
281 KOKKOS_FUNCTION
double jacobian_21(ddc::Coordinate<R, Theta>
const& coord)
const
283 const double r = ddc::get<R>(coord);
284 const double theta = ddc::get<Theta>(coord);
286 const double sin_theta = Kokkos::sin(theta);
287 const double cos_theta = Kokkos::cos(theta);
288 const double xi2 = 1. / (1. - m_epsilon * m_epsilon * 0.25);
289 const double xi = Kokkos::sqrt(xi2);
290 const double tmp1 = Kokkos::sqrt(m_epsilon * (m_epsilon + 2.0 * r * cos_theta) + 1.0);
291 const double tmp2 = 2.0 - tmp1;
292 return m_e * m_epsilon * r * sin_theta * cos_theta * xi / (tmp2 * tmp2 * tmp1)
293 + m_e * sin_theta * xi / tmp2;
307 KOKKOS_FUNCTION
double jacobian_22(ddc::Coordinate<R, Theta>
const& coord)
const
309 const double r = ddc::get<R>(coord);
310 const double theta = ddc::get<Theta>(coord);
312 const double sin_theta = Kokkos::sin(theta);
313 const double cos_theta = Kokkos::cos(theta);
314 const double xi2 = 1. / (1. - m_epsilon * m_epsilon * 0.25);
315 const double xi = Kokkos::sqrt(xi2);
316 const double tmp1 = Kokkos::sqrt(m_epsilon * (m_epsilon + 2.0 * r * cos_theta) + 1.0);
317 const double tmp2 = 2.0 - tmp1;
319 * (-m_e * m_epsilon * r * sin_theta * sin_theta * xi / (tmp2 * tmp2 * tmp1)
320 + m_e * cos_theta * xi / tmp2);
343 ddc::Coordinate<R, Theta>
const& coord,
344 Matrix_2x2& matrix)
const
346 const double r = ddc::get<R>(coord);
347 const double theta = ddc::get<Theta>(coord);
351 const double sin_theta = Kokkos::sin(theta);
352 const double cos_theta = Kokkos::cos(theta);
353 const double xi = Kokkos::sqrt(1. / (1. - m_epsilon * m_epsilon * 0.25));
354 const double divisor = 2 - Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
356 const double fact_1 = 1 / Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
357 const double fact_2 = m_e * m_epsilon * xi * r * sin_theta * fact_1 / divisor / divisor;
358 const double fact_3 = m_e * xi / divisor;
360 matrix[0][0] = -1 / fact_1 * (-sin_theta * fact_2 + cos_theta * fact_3) / fact_3;
361 matrix[0][1] = sin_theta / fact_3;
362 matrix[1][0] = 1 / r / fact_1 * (cos_theta * fact_2 + sin_theta * fact_3) / fact_3;
363 matrix[1][1] = 1 / r * cos_theta / fact_3;
378 const double r = ddc::get<R>(coord);
379 const double theta = ddc::get<Theta>(coord);
381 const double sin_theta = Kokkos::sin(theta);
382 const double cos_theta = Kokkos::cos(theta);
383 const double xi = Kokkos::sqrt(1. / (1. - m_epsilon * m_epsilon * 0.25));
384 const double divisor = 2 - Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
386 const double fact_1 = 1 / Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
387 const double fact_2 = m_e * m_epsilon * xi * r * sin_theta * fact_1 / divisor / divisor;
388 const double fact_3 = m_e * xi / divisor;
390 return -1 / fact_1 * (-sin_theta * fact_2 + cos_theta * fact_3) / fact_3;
405 const double r = ddc::get<R>(coord);
406 const double theta = ddc::get<Theta>(coord);
408 const double sin_theta = Kokkos::sin(theta);
409 const double cos_theta = Kokkos::cos(theta);
410 const double xi = Kokkos::sqrt(1. / (1. - m_epsilon * m_epsilon * 0.25));
411 const double divisor = 2 - Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
413 const double fact_3 = m_e * xi / divisor;
414 return sin_theta / fact_3;
429 const double r = ddc::get<R>(coord);
430 const double theta = ddc::get<Theta>(coord);
434 const double sin_theta = Kokkos::sin(theta);
435 const double cos_theta = Kokkos::cos(theta);
436 const double xi = Kokkos::sqrt(1. / (1. - m_epsilon * m_epsilon * 0.25));
437 const double divisor = 2 - Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
439 const double fact_1 = 1 / Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
440 const double fact_2 = m_e * m_epsilon * xi * r * sin_theta * fact_1 / divisor / divisor;
441 const double fact_3 = m_e * xi / divisor;
443 return 1 / r / fact_1 * (cos_theta * fact_2 + sin_theta * fact_3) / fact_3;
458 const double r = ddc::get<R>(coord);
459 const double theta = ddc::get<Theta>(coord);
463 const double cos_theta = Kokkos::cos(theta);
464 const double xi = Kokkos::sqrt(1. / (1. - m_epsilon * m_epsilon * 0.25));
465 const double divisor = 2 - Kokkos::sqrt(1 + m_epsilon * (m_epsilon + 2.0 * r * cos_theta));
467 const double fact_3 = m_e * xi / divisor;
468 return 1 / r * cos_theta / fact_3;
482namespace mapping_detail {
483template <
class X,
class Y,
class R,
class Theta,
class ExecSpace>
488template <
class X,
class Y,
class R,
class Theta>
493template <
class X,
class Y,
class R,
class Theta>
A class for describing the Czarny 2D mapping.
Definition cartesian_to_czarny.hpp:27
A class for describing the Czarny 2D mapping.
Definition czarny_to_cartesian.hpp:50
KOKKOS_FUNCTION double e() const
Return the parameter.
Definition czarny_to_cartesian.hpp:145
ddc::Coordinate< R, Theta > CoordArg
The type of the argument of the function described by this mapping.
Definition czarny_to_cartesian.hpp:62
KOKKOS_FUNCTION double inv_jacobian_22(ddc::Coordinate< R, Theta > const &coord) const
Compute the (2,2) coefficient of the inverse Jacobian matrix.
Definition czarny_to_cartesian.hpp:456
KOKKOS_FUNCTION double inv_jacobian_12(ddc::Coordinate< R, Theta > const &coord) const
Compute the (1,2) coefficient of the inverse Jacobian matrix.
Definition czarny_to_cartesian.hpp:403
ddc::Coordinate< X, Y > CoordResult
The type of the result of the function described by this mapping.
Definition czarny_to_cartesian.hpp:64
CartesianToCzarny< X, Y, R, Theta > get_inverse_mapping() const
Get the inverse mapping.
Definition czarny_to_cartesian.hpp:476
KOKKOS_FUNCTION double inv_jacobian_21(ddc::Coordinate< R, Theta > const &coord) const
Compute the (2,1) coefficient of the inverse Jacobian matrix.
Definition czarny_to_cartesian.hpp:427
KOKKOS_FUNCTION double epsilon() const
Return the parameter.
Definition czarny_to_cartesian.hpp:133
KOKKOS_FUNCTION double inv_jacobian_11(ddc::Coordinate< R, Theta > const &coord) const
Compute the (1,1) coefficient of the inverse Jacobian matrix.
Definition czarny_to_cartesian.hpp:376
KOKKOS_FUNCTION double jacobian_11(ddc::Coordinate< R, Theta > const &coord) const
Compute the (1,1) coefficient of the Jacobian matrix.
Definition czarny_to_cartesian.hpp:243
CzarnyToCartesian & operator=(CzarnyToCartesian const &x)=default
Assign a CzarnyToCartesian from another CzarnyToCartesian (lvalue).
KOKKOS_FUNCTION void jacobian_matrix(ddc::Coordinate< R, Theta > const &coord, Matrix_2x2 &matrix) const
Compute full Jacobian matrix.
Definition czarny_to_cartesian.hpp:208
KOKKOS_FUNCTION double jacobian_12(ddc::Coordinate< R, Theta > const &coord) const
Compute the (1,2) coefficient of the Jacobian matrix.
Definition czarny_to_cartesian.hpp:262
KOKKOS_FUNCTION ddc::Coordinate< X, Y > operator()(ddc::Coordinate< R, Theta > const &coord) const
Convert the coordinate to the equivalent (x,y) coordinate.
Definition czarny_to_cartesian.hpp:157
CzarnyToCartesian(double epsilon, double e)
Instantiate a CzarnyToCartesian from parameters.
Definition czarny_to_cartesian.hpp:82
KOKKOS_FUNCTION double jacobian_22(ddc::Coordinate< R, Theta > const &coord) const
Compute the (2,2) coefficient of the Jacobian matrix.
Definition czarny_to_cartesian.hpp:307
CzarnyToCartesian(CzarnyToCartesian &&x)=default
Instantiate a CzarnyToCartesian from another temporary CzarnyToCartesian (rvalue).
KOKKOS_FUNCTION CzarnyToCartesian(CzarnyToCartesian const &other)
Instantiate a CzarnyToCartesian from another CzarnyToCartesian (lvalue).
Definition czarny_to_cartesian.hpp:90
KOKKOS_FUNCTION void inv_jacobian_matrix(ddc::Coordinate< R, Theta > const &coord, Matrix_2x2 &matrix) const
Compute full inverse Jacobian matrix.
Definition czarny_to_cartesian.hpp:342
KOKKOS_FUNCTION double jacobian_21(ddc::Coordinate< R, Theta > const &coord) const
Compute the (2,1) coefficient of the Jacobian matrix.
Definition czarny_to_cartesian.hpp:281
CzarnyToCartesian & operator=(CzarnyToCartesian &&x)=default
Assign a CzarnyToCartesian from another temporary CzarnyToCartesian (rvalue).
KOKKOS_FUNCTION double jacobian(ddc::Coordinate< R, Theta > const &coord) const
Compute the Jacobian, the determinant of the Jacobian matrix of the mapping.
Definition czarny_to_cartesian.hpp:179
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