7 #include <sll/view.hpp>
9 #include "coordinate_converter.hpp"
10 #include "curvilinear2d_to_cartesian.hpp"
11 #include "jacobian.hpp"
12 #include "mapping_tools.hpp"
13 #include "pseudo_cartesian_compatible_mapping.hpp"
32 class SplineEvaluator,
33 class R =
typename SplineEvaluator::continuous_dimension_type1,
34 class Theta =
typename SplineEvaluator::continuous_dimension_type2,
35 class MemorySpace =
typename SplineEvaluator::memory_space>
42 static_assert(std::is_same_v<MemorySpace, typename SplineEvaluator::memory_space>);
48 using BSplineR =
typename SplineEvaluator::bsplines_type1;
70 using spline_idx_range = ddc::DiscreteDomain<BSplineR, BSplineTheta>;
72 using SplineType = ddc::
73 ChunkView<double, spline_idx_range, std::experimental::layout_right, MemorySpace>;
75 using IdxRangeTheta =
typename SplineEvaluator::evaluation_domain_type2;
76 using IdxTheta =
typename IdxRangeTheta::discrete_element_type;
79 SplineType m_x_spline_representation;
80 SplineType m_y_spline_representation;
81 SplineEvaluator m_spline_evaluator;
82 IdxRangeTheta m_idx_range_theta;
117 SplineType curvilinear_to_x,
118 SplineType curvilinear_to_y,
119 SplineEvaluator
const& evaluator,
120 IdxRangeTheta idx_range_theta)
121 : m_x_spline_representation(curvilinear_to_x)
122 , m_y_spline_representation(curvilinear_to_y)
123 , m_spline_evaluator(evaluator)
124 , m_idx_range_theta(idx_range_theta)
142 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const final
144 const double x = m_spline_evaluator(coord, m_x_spline_representation.span_cview());
145 const double y = m_spline_evaluator(coord, m_y_spline_representation.span_cview());
146 return ddc::Coordinate<X, Y>(x, y);
168 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord,
172 = m_spline_evaluator.deriv_dim_1(coord, m_x_spline_representation.span_cview());
174 = m_spline_evaluator.deriv_dim_2(coord, m_x_spline_representation.span_cview());
176 = m_spline_evaluator.deriv_dim_1(coord, m_y_spline_representation.span_cview());
178 = m_spline_evaluator.deriv_dim_2(coord, m_y_spline_representation.span_cview());
198 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const final
200 return m_spline_evaluator.deriv_dim_1(coord, m_x_spline_representation.span_cview());
220 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const final
222 return m_spline_evaluator.deriv_dim_2(coord, m_x_spline_representation.span_cview());
242 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const final
244 return m_spline_evaluator.deriv_dim_1(coord, m_y_spline_representation.span_cview());
264 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const& coord)
const final
266 return m_spline_evaluator.deriv_dim_2(coord, m_y_spline_representation.span_cview());
322 for (IdxTheta ip : m_idx_range_theta) {
323 const double th = ddc::coordinate(ip);
324 ddc::Coordinate<curvilinear_tag_r, curvilinear_tag_theta>
const coord(0, th);
325 double const deriv_1_x
326 = m_spline_evaluator.deriv_dim_1(coord, m_x_spline_representation.span_cview());
327 double const deriv_1_2_x
329 .deriv_1_and_2(coord, m_x_spline_representation.span_cview());
330 double const deriv_1_y
331 = m_spline_evaluator.deriv_dim_1(coord, m_y_spline_representation.span_cview());
332 double const deriv_1_2_y
334 .deriv_1_and_2(coord, m_y_spline_representation.span_cview());
337 double const j11 = deriv_1_x * Kokkos::cos(th) - deriv_1_2_x * Kokkos::sin(th);
338 double const j12 = deriv_1_x * Kokkos::sin(th) + deriv_1_2_x * Kokkos::cos(th);
339 double const j21 = deriv_1_y * Kokkos::cos(th) - deriv_1_2_y * Kokkos::sin(th);
340 double const j22 = deriv_1_y * Kokkos::sin(th) + deriv_1_2_y * Kokkos::cos(th);
342 double const jacobian = j11 * j22 - j12 * j21;
352 int const theta_size = m_idx_range_theta.size();
353 matrix[0][0] /= theta_size;
354 matrix[0][1] /= theta_size;
355 matrix[1][0] /= theta_size;
356 matrix[1][1] /= theta_size;
448 ddc::DiscreteElement<BSplineR, BSplineTheta>
const& el)
const
450 return ddc::Coordinate<X, Y>(m_x_spline_representation(el), m_y_spline_representation(el));
455 namespace mapping_detail {
459 class SplineEvaluator,
464 struct MappingAccessibility<
468 static constexpr
bool value = Kokkos::SpaceAccessibility<ExecSpace, MemorySpace>::accessible;
An operator to convert from the start coordinate type to the end coordinate type.
Definition: coordinate_converter.hpp:13
A class for describing curvilinear 2D mappings from the logical domain to the physical domain.
Definition: curvilinear2d_to_cartesian.hpp:9
A class for describing discrete 2D mappings from the logical domain to the physical domain.
Definition: discrete_to_cartesian.hpp:41
KOKKOS_FUNCTION double to_pseudo_cartesian_jacobian_11_center() const final
Compute the (1,1) coefficient of the pseudo-Cartesian Jacobian matrix at the central point.
Definition: discrete_to_cartesian.hpp:367
typename Curvilinear2DToCartesian< X, Y, R, Theta >::curvilinear_tag_theta curvilinear_tag_theta
Indicate the second logical coordinate.
Definition: discrete_to_cartesian.hpp:62
KOKKOS_FUNCTION double jacobian_21(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const final
Compute the (2,1) coefficient of the Jacobian matrix.
Definition: discrete_to_cartesian.hpp:241
KOKKOS_FUNCTION double jacobian_22(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const final
Compute the (2,2) coefficient of the Jacobian matrix.
Definition: discrete_to_cartesian.hpp:263
KOKKOS_FUNCTION double jacobian_12(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const final
Compute the (1,2) coefficient of the Jacobian matrix.
Definition: discrete_to_cartesian.hpp:219
KOKKOS_FUNCTION void to_pseudo_cartesian_jacobian_center_matrix(Matrix_2x2 &matrix) const final
Compute the full Jacobian matrix from the mapping to the pseudo-Cartesian mapping at the central poin...
Definition: discrete_to_cartesian.hpp:314
ddc::Coordinate< X, Y > CoordResult
The type of the result of the function described by this mapping.
Definition: discrete_to_cartesian.hpp:67
typename Curvilinear2DToCartesian< X, Y, R, Theta >::cartesian_tag_y cartesian_tag_y
Indicate the second physical coordinate.
Definition: discrete_to_cartesian.hpp:57
typename SplineEvaluator::bsplines_type1 BSplineR
Indicate the bspline type of the first logical dimension.
Definition: discrete_to_cartesian.hpp:48
typename Curvilinear2DToCartesian< X, Y, R, Theta >::cartesian_tag_x cartesian_tag_x
Indicate the first physical coordinate.
Definition: discrete_to_cartesian.hpp:55
KOKKOS_FUNCTION void jacobian_matrix(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord, Matrix_2x2 &matrix) const final
Compute full Jacobian matrix.
Definition: discrete_to_cartesian.hpp:167
typename Curvilinear2DToCartesian< X, Y, R, Theta >::curvilinear_tag_r curvilinear_tag_r
Indicate the first logical coordinate.
Definition: discrete_to_cartesian.hpp:59
KOKKOS_FUNCTION double to_pseudo_cartesian_jacobian_12_center() const final
Compute the (1,2) coefficient of the pseudo-Cartesian Jacobian matrix at the central point.
Definition: discrete_to_cartesian.hpp:382
KOKKOS_FUNCTION double to_pseudo_cartesian_jacobian_21_center() const final
Compute the (2,1) coefficient of the pseudo-Cartesian Jacobian matrix at the central point.
Definition: discrete_to_cartesian.hpp:397
KOKKOS_FUNCTION double to_pseudo_cartesian_jacobian_22_center() const final
Compute the (2,2) coefficient of the pseudo-Cartesian Jacobian matrix at the central point.
Definition: discrete_to_cartesian.hpp:412
KOKKOS_FUNCTION ddc::Coordinate< X, Y > operator()(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const final
Compute the physical coordinates from the logical coordinates.
Definition: discrete_to_cartesian.hpp:141
ddc::Coordinate< R, Theta > CoordArg
The type of the argument of the function described by this mapping.
Definition: discrete_to_cartesian.hpp:65
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:447
KOKKOS_FUNCTION double jacobian_11(ddc::Coordinate< curvilinear_tag_r, curvilinear_tag_theta > const &coord) const final
Compute the (1,1) coefficient of the Jacobian matrix.
Definition: discrete_to_cartesian.hpp:197
KOKKOS_FUNCTION DiscreteToCartesian(SplineType curvilinear_to_x, SplineType curvilinear_to_y, SplineEvaluator const &evaluator, IdxRangeTheta idx_range_theta)
Instantiate a DiscreteToCartesian from the coefficients of 2D splines approximating the mapping.
Definition: discrete_to_cartesian.hpp:116
typename SplineEvaluator::bsplines_type2 BSplineTheta
Indicate the bspline type of the second logical dimension.
Definition: discrete_to_cartesian.hpp:52
A specialisation of Jacobian to handle non-analytical terms.
Definition: jacobian.hpp:184
KOKKOS_FUNCTION double jacobian(ddc::Coordinate< typename SplineEvaluator::continuous_dimension_type1, typename SplineEvaluator::continuous_dimension_type2 > const &coord) const final
Compute the Jacobian, the determinant of the Jacobian matrix of the mapping.
Definition: jacobian.hpp:194
An operator to calculate the Jacobian matrix of the mapping from the physical domain to the pseudo-Ca...
Definition: pseudo_cartesian_compatible_mapping.hpp:42
std::array< std::array< double, 2 >, 2 > Matrix_2x2
The type of the pseudo-Cartesian Jacobian matrix and its inverse.
Definition: pseudo_cartesian_compatible_mapping.hpp:45
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