6#include "directional_tag.hpp"
7#include "vector_field.hpp"
8#include "vector_field_mem.hpp"
13template <
class InVectorSpace,
class OutVectorSpace,
class Mapping,
class ExecSpace>
26template <
class XIn,
class YIn,
class XOut,
class YOut,
class Mapping,
class ExecSpace>
27class VectorMapper<NDTag<XIn, YIn>, NDTag<XOut, YOut>, Mapping, ExecSpace>
29 static_assert(is_accessible_v<ExecSpace, Mapping>);
31 (std::is_same_v<Coord<XIn, YIn>,
typename Mapping::CoordArg>)
32 || (std::is_same_v<Coord<XIn, YIn>,
typename Mapping::CoordResult>));
34 (std::is_same_v<Coord<XOut, YOut>,
typename Mapping::CoordArg>)
35 || (std::is_same_v<Coord<XOut, YOut>,
typename Mapping::CoordResult>));
64 template <
class IdxRangeType,
class LayoutStr
idedPolicy1,
class LayoutStr
idedPolicy2>
74 LayoutStridedPolicy2> vector_field_input)
76 using IdxType =
typename IdxRangeType::discrete_element_type;
78 Mapping mapping_proxy = m_mapping;
80 if constexpr (std::is_same_v<Coord<XIn, YIn>,
typename Mapping::CoordArg>) {
81 ddc::parallel_for_each(
83 get_idx_range(vector_field_input),
84 KOKKOS_LAMBDA(IdxType idx) {
86 mapping_proxy.jacobian_matrix(ddc::coordinate(idx), map_J);
89 vector_out.array() = mat_vec_mul(map_J, vector_field_input(idx).array());
90 ddcHelper::get<XOut>(vector_field_output)(idx) = ddc::get<XOut>(vector_out);
91 ddcHelper::get<YOut>(vector_field_output)(idx) = ddc::get<YOut>(vector_out);
95 ddc::parallel_for_each(
97 get_idx_range(vector_field_input),
98 KOKKOS_LAMBDA(IdxType idx) {
99 Matrix_2x2 map_J = inv_mapping(ddc::coordinate(idx));
102 vector_out.array() = mat_vec_mul(map_J, vector_field_input(idx).array());
103 ddcHelper::get<XOut>(vector_field_output)(idx) = ddc::get<XOut>(vector_out);
104 ddcHelper::get<YOut>(vector_field_output)(idx) = ddc::get<YOut>(vector_out);
134 class LayoutStridedPolicy>
135auto create_geometry_mirror_view(
136 ExecSpace exec_space,
141 typename ExecSpace::memory_space,
142 LayoutStridedPolicy> vector_field,
145 using CoordOut = std::conditional_t<
146 std::is_same_v<typename Mapping::CoordArg, Coord<X, Y>>,
147 typename Mapping::CoordResult,
148 typename Mapping::CoordArg>;
149 if constexpr (std::is_same_v<CoordOut, Coord<X, Y>>) {
152 using X_out = ddc::type_seq_element_t<0, ddc::to_type_seq_t<CoordOut>>;
153 using Y_out = ddc::type_seq_element_t<1, ddc::to_type_seq_t<CoordOut>>;
155 std::remove_const_t<ElementType>,
158 typename ExecSpace::memory_space>
159 vector_field_out(get_idx_range(vector_field));
161 vector_mapping(exec_space, get_field(vector_field_out), get_const_field(vector_field));
162 return vector_field_out;
A class to calculate the inverse of the Jacobian matrix.
Definition inverse_jacobian_matrix.hpp:18
Pre-declaration of VectorFieldMem.
Definition vector_field_mem.hpp:54
A class which holds multiple (scalar) fields in order to represent a vector field.
Definition vector_field.hpp:64
typename ExecSpace::memory_space memory_space
The type of the memory space where the field is saved (CPU vs GPU).
Definition vector_mapper.hpp:39
void operator()(ExecSpace exec_space, VectorField< double, IdxRangeType, NDTag< XOut, YOut >, memory_space, LayoutStridedPolicy1 > vector_field_output, VectorConstField< double, IdxRangeType, NDTag< XIn, YIn >, memory_space, LayoutStridedPolicy2 > vector_field_input)
Convert vectors defined in the input coordinate system to equivalent vectors in the output coordinate...
Definition vector_mapper.hpp:65
VectorMapper(Mapping mapping)
A constructor for the VectorMapper.
Definition vector_mapper.hpp:54
The general predeclaration of VectorMapper.
Definition vector_mapper.hpp:14
A type describing a vector e.g. (E_x, E_y)
Definition ddc_aliases.hpp:82
Define non periodic real X dimension.
Definition geometry.hpp:278
Define non periodic real Y dimension.
Definition geometry.hpp:289