4 #include "ddc_alias_inline_functions.hpp"
5 #include "ddc_aliases.hpp"
6 #include "vector_field_mem.hpp"
13 class MemorySpace = Kokkos::DefaultExecutionSpace::memory_space,
14 class LayoutStridedPolicy = std::experimental::layout_right>
22 class LayoutStridedPolicy>
23 inline constexpr
bool enable_vector_field<
31 class LayoutStridedPolicy>
32 inline constexpr
bool enable_data_access_methods<
40 class LayoutStridedPolicy>
41 inline constexpr
bool enable_borrowed_vector_field<
59 class LayoutStridedPolicy>
62 Field<ElementType, IdxRangeType, MemorySpace, LayoutStridedPolicy>,
69 using field_type = Field<ElementType, IdxRangeType, MemorySpace, LayoutStridedPolicy>;
78 using typename base_type::NDTypeTag;
80 using typename base_type::chunk_span_type;
81 using typename base_type::chunk_view_type;
123 template <
class,
class,
class,
class,
class>
126 template <
class OElementType,
class Allocator, std::size_t... Is>
129 std::index_sequence<Is...>
const&) noexcept
141 class SFINAEElementType = ElementType,
142 class = std::enable_if_t<std::is_const_v<SFINAEElementType>>,
145 VectorFieldMem<OElementType, IdxRangeType, NDTag, Allocator> const& other,
146 std::index_sequence<Is...>
const&) noexcept
147 : base_type((
field_type(ddcHelper::get<ddc::type_seq_element_t<Is, NDTag>>(other)))...)
154 template <
class OElementType, std::size_t... Is>
161 LayoutStridedPolicy>
const& other,
162 std::index_sequence<Is...>
const&) noexcept
163 : base_type((
field_type(ddcHelper::get<ddc::type_seq_element_t<Is, NDTag>>(other)))...)
167 template <
class SliceType, std::size_t... Is>
168 constexpr
auto get_slice(SliceType
const& slice_spec, std::index_sequence<Is...>
const&)
170 auto chunk_slices = std::make_tuple(
171 this->
template get<ddc::type_seq_element_t<Is, NDTag>>()[slice_spec]...);
172 using FieldType = std::tuple_element_t<0, decltype(chunk_slices)>;
175 typename FieldType::discrete_domain_type,
177 typename FieldType::memory_space,
178 typename FieldType::layout_type>(std::move(std::get<Is>(chunk_slices))...);
185 template <
class... ODDims,
typename T,
T... ints>
187 operator()(Idx<ODDims...>
const& delems, std::integer_sequence<T, ints...>)
const noexcept
189 return element_type((base_type::m_values[ints](delems))...);
212 template <
class OElementType,
class Allocator>
215 :
VectorField(other, std::make_index_sequence<base_type::NDims> {})
225 class SFINAEElementType = ElementType,
226 class = std::enable_if_t<std::is_const_v<SFINAEElementType>>,
229 VectorFieldMem<OElementType, IdxRangeType, NDTag, Allocator> const& other) noexcept
230 :
VectorField(other, std::make_index_sequence<base_type::NDims> {})
234 template <
class OElementType,
class Allocator>
240 template <
class OElementType>
246 LayoutStridedPolicy>
const& other) noexcept
247 :
VectorField(other, std::make_index_sequence<base_type::NDims> {})
256 class... OElementType,
257 class = std::enable_if_t<
258 std::conjunction_v<std::is_same<OElementType, ElementType>...>>,
259 class = std::enable_if_t<
sizeof...(OElementType) == base_type::NDims>>
270 class = std::enable_if_t<std::conjunction_v<std::is_same<FieldType, field_type>...>>>
317 template <
class... ODDims>
320 Idx<ODDims...> delem_idx(delems...);
322 operator()(delem_idx, std::make_integer_sequence<
int, element_type::size()> {});
329 template <
class... ODDims,
class = std::enable_if_t<
sizeof...(ODDims) != 1>>
330 KOKKOS_FUNCTION
element_type operator()(Idx<ODDims...>
const& delems)
const noexcept
332 return this->operator()(delems, std::make_integer_sequence<
int, element_type::size()> {});
346 template <
class... QueryDDims>
347 constexpr
auto operator[](Idx<QueryDDims...>
const& slice_spec)
349 return get_slice(slice_spec, std::make_index_sequence<base_type::NDims> {});
361 template <
class... QueryDDims>
362 constexpr
auto operator[](IdxRange<QueryDDims...>
const& oidx_range)
364 return get_slice(oidx_range, std::make_index_sequence<base_type::NDims> {});
372 template <
class QueryTag>
373 inline constexpr chunk_span_type
get() const noexcept
376 ddc::in_tags_v<QueryTag, NDTypeTag>,
377 "requested Tag absent from TaggedVector");
378 return base_type::m_values[ddc::type_seq_rank_v<QueryTag, NDTypeTag>].span_view();
386 class MemorySpace = Kokkos::DefaultExecutionSpace::memory_space,
387 class LayoutStridedPolicy = std::experimental::layout_right>
Definition: vector_field_common.hpp:9
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
constexpr chunk_span_type get() const noexcept
Get the Field describing the component in the QueryTag direction.
Definition: vector_field.hpp:373
constexpr auto operator[](IdxRange< QueryDDims... > const &oidx_range)
Slice out some dimensions.
Definition: vector_field.hpp:362
typename base_type::discrete_domain_type discrete_domain_type
The type of the index range on which the field is defined.
Definition: vector_field.hpp:113
typename base_type::element_type element_type
The type of an element in one of the Fields comprising the VectorField.
Definition: vector_field.hpp:76
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField(VectorField const &other)=default
Constructs a new VectorField by copy, yields a new view to the same data.
KOKKOS_FUNCTION VectorField(index_range_type const &idx_range, OElementType *... ptr)
Constructs a new VectorField from scratch.
Definition: vector_field.hpp:260
KOKKOS_FUNCTION element_type operator()(Idx< ODDims > const &... delems) const noexcept
Element access using a list of Idxs.
Definition: vector_field.hpp:318
typename field_type::memory_space memory_space
The type of the memory space where the field is saved (CPU vs GPU).
Definition: vector_field.hpp:120
constexpr KOKKOS_FUNCTION VectorField(FieldType... fields)
Constructs a new VectorField containing references to Field.
Definition: vector_field.hpp:271
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField & operator=(VectorField const &other)=default
Copy-assigns a new value to this VectorField, yields a new view to the same data.
constexpr view_type span_cview() const
Get a constant reference to the vector field referred to by this vector field span.
Definition: vector_field.hpp:295
VectorField< const ElementType, IdxRangeType, NDTag, MemorySpace, LayoutStridedPolicy > view_type
A type which can hold a constant reference to a VectorFieldMem.
Definition: vector_field.hpp:98
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField & operator=(VectorField &&other)=default
Move-assigns a new value to this VectorField.
Field< ElementType, IdxRangeType, MemorySpace, LayoutStridedPolicy > field_type
Type describing the object which can be extracted from this VectorField using the get<> function.
Definition: vector_field.hpp:69
KOKKOS_DEFAULTED_FUNCTION ~VectorField()=default
VectorField destructor.
constexpr KOKKOS_FUNCTION VectorField(VectorField< OElementType, index_range_type, NDTag, MemorySpace, LayoutStridedPolicy > const &other) noexcept
Constructs a new VectorField by copy of a chunk, yields a new view to the same data.
Definition: vector_field.hpp:241
constexpr span_type span_view() const
Get a modifiable reference to the vector field referred to by this vector field span.
Definition: vector_field.hpp:308
constexpr KOKKOS_FUNCTION VectorField(VectorFieldMem< OElementType, IdxRangeType, NDTag, Allocator > &other) noexcept
Constructs a new VectorField from a VectorFieldMem, yields a new view to the same data.
Definition: vector_field.hpp:213
LayoutStridedPolicy layout_type
Type describing the way in which the data is laid out in the Field memory.
Definition: vector_field.hpp:106
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField(VectorField &&other)=default
Constructs a new VectorField by move.
constexpr auto operator[](Idx< QueryDDims... > const &slice_spec)
Slice out some dimensions.
Definition: vector_field.hpp:347
constexpr KOKKOS_DEFAULTED_FUNCTION VectorField()=default
Empty VectorField.
discrete_domain_type index_range_type
The IdxRange on which the fields in this object are defined.
Definition: vector_field.hpp:115
A class which describes the real space in the temporal direction.
Definition: geometry.hpp:45