4#include "sll/math_tools.hpp"
6#include "inv_jacobian_o_point.hpp"
7#include "inverse_jacobian_matrix.hpp"
8#include "mapping_tools.hpp"
24template <
class Mapping1,
class Mapping2>
27 static_assert(is_mapping_v<Mapping1>);
28 static_assert(is_mapping_v<Mapping2>);
29 static_assert(std::is_same_v<typename Mapping2::CoordResult, typename Mapping1::CoordArg>);
31 is_analytical_mapping_v<Mapping2>,
32 "The second mapping must be analytical to evaluate the jacobian");
43 using InverseMapping2 = inverse_mapping_t<Mapping2>;
45 static_assert(has_2d_jacobian_v<Mapping1, CoordJacobian>);
46 static_assert(has_2d_jacobian_v<InverseMapping2, CoordJacobian>);
51 InverseMapping2 m_inv_mapping_2;
71 (has_singular_o_point_inv_jacobian_v<Map1>)
72 || (has_singular_o_point_inv_jacobian_v<InverseMapping2>),
75 : m_mapping_1(mapping_1)
76 , m_mapping_2(mapping_2)
77 , m_inv_mapping_2(mapping_2.get_inverse_mapping())
78 , m_jacobian_mapping_2(mapping_2.get_inverse_mapping())
81 static_assert(std::is_same_v<Mapping1, Map1>);
94 !((has_singular_o_point_inv_jacobian_v<Map1>)
95 || (has_singular_o_point_inv_jacobian_v<InverseMapping2>)),
98 : m_mapping_1(mapping_1)
99 , m_mapping_2(mapping_2)
100 , m_inv_mapping_2(mapping_2.get_inverse_mapping())
101 , m_jacobian_mapping_2(mapping_2.get_inverse_mapping())
104 static_assert(std::is_same_v<Mapping1, Map1>);
116 return m_mapping_1(m_mapping_2(coord));
139 Matrix_2x2 jacobian_mapping_1;
140 m_mapping_1.jacobian_matrix(coord, jacobian_mapping_1);
142 Matrix_2x2 m_jacobian_mapping_2 = m_jacobian_mapping_2(coord);
144 matrix = mat_mul(jacobian_mapping_1, m_jacobian_mapping_2);
209 return determinant(J);
230 (has_singular_o_point_inv_jacobian_v<Mapping1>)
231 || (has_singular_o_point_inv_jacobian_v<InverseMapping2>)) {
232 using R = ddc::type_seq_element_t<0, ddc::to_type_seq_t<CoordJacobian>>;
233 using Theta = ddc::type_seq_element_t<1, ddc::to_type_seq_t<CoordJacobian>>;
234 double r = ddc::get<R>(coord);
239 Matrix_2x2 J_0 = o_point_val();
241 non_singular_inverse_jacobian_matrix(coord_eps, J_eps);
242 matrix[0][0] = (1 - r / m_epsilon) * J_0[0][0] + r / m_epsilon * J_eps[0][0];
243 matrix[0][1] = (1 - r / m_epsilon) * J_0[0][1] + r / m_epsilon * J_eps[0][1];
244 matrix[1][0] = (1 - r / m_epsilon) * J_0[1][0] + r / m_epsilon * J_eps[1][0];
245 matrix[1][1] = (1 - r / m_epsilon) * J_0[1][1] + r / m_epsilon * J_eps[1][1];
247 non_singular_inverse_jacobian_matrix(coord, matrix);
250 non_singular_inverse_jacobian_matrix(coord, matrix);
316 return determinant(J);
324 template <
class Mapping>
325 KOKKOS_INLINE_FUNCTION Mapping
const&
get()
const
327 static_assert(std::is_same_v<Mapping, Mapping1> || std::is_same_v<Mapping, Mapping2>);
328 if constexpr (std::is_same_v<Mapping, Mapping1>) {
352 KOKKOS_INLINE_FUNCTION
void non_singular_inverse_jacobian_matrix(
354 Matrix_2x2& matrix)
const
357 Matrix_2x2 inv_jacobian_mapping_1 = inv_jacobian_matrix_1(coord);
359 Matrix_2x2 inv_jacobian_mapping_2;
360 m_inv_mapping_2.jacobian_matrix(coord, inv_jacobian_mapping_2);
362 matrix = mat_mul(inv_jacobian_mapping_2, inv_jacobian_mapping_1);
367namespace mapping_detail {
368template <
class Mapping1,
class Mapping2,
class ExecSpace>
369struct MappingAccessibility<ExecSpace,
CombinedMapping<Mapping1, Mapping2>>
371 static constexpr bool value = MappingAccessibility<ExecSpace, Mapping1>::value
372 && MappingAccessibility<ExecSpace, Mapping2>::value;
A class which describes a mapping which is constructed by combining two mappings.
Definition combined_mapping.hpp:26
KOKKOS_INLINE_FUNCTION double inv_jacobian_12(CoordJacobian const &coord_rtheta) const
Compute the (1,2) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:273
KOKKOS_INLINE_FUNCTION double jacobian_11(CoordJacobian const &coord_rtheta) const
Compute the (1,1) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:153
KOKKOS_INLINE_FUNCTION double inv_jacobian_11(CoordJacobian const &coord_rtheta) const
Compute the (1,1) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:260
CombinedMapping(Map1 mapping_1, Mapping2 mapping_2, double epsilon)
Build a CombinedMapping from the component mappings.
Definition combined_mapping.hpp:74
KOKKOS_INLINE_FUNCTION double jacobian_22(CoordJacobian const &coord_rtheta) const
Compute the (2,2) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:192
KOKKOS_FUNCTION void inv_jacobian_matrix(CoordJacobian const &coord, Matrix_2x2 &matrix) const
Compute the full inverse Jacobian matrix.
Definition combined_mapping.hpp:227
typename Mapping1::CoordResult CoordResult
The type of the result of the function described by this mapping.
Definition combined_mapping.hpp:38
KOKKOS_INLINE_FUNCTION void jacobian_matrix(CoordJacobian const &coord, Matrix_2x2 &matrix) const
Compute full Jacobian matrix.
Definition combined_mapping.hpp:136
KOKKOS_INLINE_FUNCTION double jacobian_12(CoordJacobian const &coord_rtheta) const
Compute the (1,2) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:166
CombinedMapping(Map1 mapping_1, Mapping2 mapping_2)
Build a CombinedMapping from the component mappings.
Definition combined_mapping.hpp:97
typename Mapping2::CoordArg CoordArg
The type of the argument of the function described by this mapping.
Definition combined_mapping.hpp:36
KOKKOS_INLINE_FUNCTION double jacobian_21(CoordJacobian const &coord_rtheta) const
Compute the (2,1) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:179
KOKKOS_INLINE_FUNCTION double inv_jacobian(CoordJacobian const &coord_rtheta) const
Compute the determinant of the Jacobian matrix.
Definition combined_mapping.hpp:312
KOKKOS_INLINE_FUNCTION Mapping const & get() const
Get access to one of the internal mappings.
Definition combined_mapping.hpp:325
typename Mapping2::CoordResult CoordJacobian
The coordinate system on which the Jacobian is described.
Definition combined_mapping.hpp:40
KOKKOS_INLINE_FUNCTION double inv_jacobian_22(CoordJacobian const &coord_rtheta) const
Compute the (2,2) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:299
KOKKOS_INLINE_FUNCTION double inv_jacobian_21(CoordJacobian const &coord_rtheta) const
Compute the (2,1) coefficient of the Jacobian matrix.
Definition combined_mapping.hpp:286
CoordResult operator()(CoordArg coord)
Convert the argument coordinate to the equivalent result coordinate.
Definition combined_mapping.hpp:114
KOKKOS_INLINE_FUNCTION double jacobian(CoordJacobian const &coord_rtheta) const
Compute the determinant of the Jacobian matrix.
Definition combined_mapping.hpp:205
An operator for calculating the inverse of the Jacobian at an O-point.
Definition inv_jacobian_o_point.hpp:27
A class to calculate the inverse of the Jacobian matrix.
Definition inverse_jacobian_matrix.hpp:18
Define non periodic real R dimension.
Definition geometry.hpp:31
Define periodic real Theta dimension.
Definition geometry.hpp:42