7#include <sll/math_tools.hpp>
10#include "mapping_tools.hpp"
27 class SplineEvaluator,
28 class R =
typename SplineEvaluator::continuous_dimension_type1,
29 class Theta =
typename SplineEvaluator::continuous_dimension_type2,
30 class MemorySpace =
typename SplineEvaluator::memory_space>
33 static_assert(std::is_same_v<MemorySpace, typename SplineEvaluator::memory_space>);
39 using BSplineR =
typename SplineEvaluator::bsplines_type1;
60 using spline_idx_range = ddc::DiscreteDomain<BSplineR, BSplineTheta>;
62 using SplineType = ddc::ChunkView<double, spline_idx_range, Kokkos::layout_right, MemorySpace>;
64 using IdxRangeRTheta =
typename SplineEvaluator::evaluation_domain_type;
65 using IdxRangeTheta =
typename SplineEvaluator::evaluation_domain_type2;
66 using IdxTheta =
typename IdxRangeTheta::discrete_element_type;
69 SplineType m_x_spline_representation;
70 SplineType m_y_spline_representation;
71 SplineEvaluator m_spline_evaluator;
72 IdxRangeRTheta m_idx_range_singular_point;
106 SplineType curvilinear_to_x,
107 SplineType curvilinear_to_y,
108 SplineEvaluator
const& evaluator,
110 : m_x_spline_representation(curvilinear_to_x)
111 , m_y_spline_representation(curvilinear_to_y)
112 , m_spline_evaluator(evaluator)
131 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
133 const double x = m_spline_evaluator(coord, m_x_spline_representation.span_cview());
134 const double y = m_spline_evaluator(coord, m_y_spline_representation.span_cview());
135 return ddc::Coordinate<X, Y>(x, y);
152 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord,
153 Matrix_2x2& matrix)
const
156 = m_spline_evaluator.deriv_dim_1(coord, m_x_spline_representation.span_cview());
158 = m_spline_evaluator.deriv_dim_2(coord, m_x_spline_representation.span_cview());
160 = m_spline_evaluator.deriv_dim_1(coord, m_y_spline_representation.span_cview());
162 = m_spline_evaluator.deriv_dim_2(coord, m_y_spline_representation.span_cview());
182 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
184 return m_spline_evaluator.deriv_dim_1(coord, m_x_spline_representation.span_cview());
204 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
206 return m_spline_evaluator.deriv_dim_2(coord, m_x_spline_representation.span_cview());
226 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
228 return m_spline_evaluator.deriv_dim_1(coord, m_y_spline_representation.span_cview());
248 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
250 return m_spline_evaluator.deriv_dim_2(coord, m_y_spline_representation.span_cview());
262 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
266 return determinant(J);
284 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const
288 = m_spline_evaluator.deriv_dim_1(coord, m_x_spline_representation.span_cview());
290 = m_spline_evaluator.deriv_1_and_2(coord, m_x_spline_representation.span_cview());
292 = m_spline_evaluator.deriv_dim_1(coord, m_y_spline_representation.span_cview());
294 = m_spline_evaluator.deriv_1_and_2(coord, m_y_spline_representation.span_cview());
305 return m_idx_range_singular_point;
337 ddc::DiscreteElement<BSplineR, BSplineTheta>
const& el)
const
339 return ddc::Coordinate<X, Y>(m_x_spline_representation(el), m_y_spline_representation(el));
344namespace mapping_detail {
348 class SplineEvaluator,
353struct MappingAccessibility<
357 static constexpr bool value = Kokkos::SpaceAccessibility<ExecSpace, MemorySpace>::accessible;
360template <
class X,
class Y,
class SplineEvaluator,
class R,
class Theta,
class MemorySpace>
366template <
class X,
class Y,
class SplineEvaluator,
class R,
class Theta,
class MemorySpace>
A class for describing discrete 2D mappings from the logical domain to the physical domain.
Definition discrete_to_cartesian.hpp:32
KOKKOS_INLINE_FUNCTION Matrix_2x2 first_order_jacobian_matrix_r_rtheta(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Get the first order expansion of the Jacobian matrix with the theta component divided by r.
Definition discrete_to_cartesian.hpp:283
KOKKOS_FUNCTION DiscreteToCartesian(SplineType curvilinear_to_x, SplineType curvilinear_to_y, SplineEvaluator const &evaluator, IdxRangeRTheta idx_range_singular_point)
Instantiate a DiscreteToCartesian from the coefficients of 2D splines approximating the mapping.
Definition discrete_to_cartesian.hpp:105
KOKKOS_FUNCTION double jacobian_11(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Compute the (1,1) coefficient of the Jacobian matrix.
Definition discrete_to_cartesian.hpp:181
KOKKOS_FUNCTION ddc::Coordinate< X, Y > operator()(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Compute the physical coordinates from the logical coordinates.
Definition discrete_to_cartesian.hpp:130
ddc::Coordinate< X, Y > CoordResult
The type of the result of the function described by this mapping.
Definition discrete_to_cartesian.hpp:57
KOKKOS_FUNCTION void jacobian_matrix(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord, Matrix_2x2 &matrix) const
Compute full Jacobian matrix.
Definition discrete_to_cartesian.hpp:151
typename SplineEvaluator::bsplines_type1 BSplineR
Indicate the bspline type of the first logical dimension.
Definition discrete_to_cartesian.hpp:39
KOKKOS_FUNCTION double jacobian(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Compute the Jacobian, the determinant of the Jacobian matrix of the mapping.
Definition discrete_to_cartesian.hpp:261
KOKKOS_FUNCTION double jacobian_12(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Compute the (1,2) coefficient of the Jacobian matrix.
Definition discrete_to_cartesian.hpp:203
KOKKOS_FUNCTION double jacobian_22(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Compute the (2,2) coefficient of the Jacobian matrix.
Definition discrete_to_cartesian.hpp:247
KOKKOS_INLINE_FUNCTION const ddc::Coordinate< X, Y > control_point(ddc::DiscreteElement< BSplineR, BSplineTheta > const &el) const
Get a control point of the mapping on B-splines.
Definition discrete_to_cartesian.hpp:336
KOKKOS_FUNCTION double jacobian_21(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const
Compute the (2,1) coefficient of the Jacobian matrix.
Definition discrete_to_cartesian.hpp:225
ddc::Coordinate< R, Theta > CoordArg
The type of the argument of the function described by this mapping.
Definition discrete_to_cartesian.hpp:55
KOKKOS_INLINE_FUNCTION IdxRangeRTheta idx_range_singular_point() const
Get the index range describing the points which should be used to evaluate functions at the central p...
Definition discrete_to_cartesian.hpp:303
typename SplineEvaluator::bsplines_type2 BSplineTheta
Indicate the bspline type of the second logical dimension.
Definition discrete_to_cartesian.hpp:43
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