DDC 0.16.0
Loading...
Searching...
No Matches
coordinate.hpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <utility>
8
9#include <Kokkos_Macros.hpp>
10
11#include "detail/tagged_vector.hpp"
12
15#include "real_type.hpp"
16
17namespace ddc {
18
19/** A CoordinateElement the type of the scalar used to represent elements of coordinates in the
20 * continuous space.
21 */
22using CoordinateElement = Real;
23
24/** A Coordinate represents a coordinate in the continuous space
25 *
26 * It is tagged by its dimensions.
27 */
28
29template <class... CDims>
30using Coordinate = detail::TaggedVector<CoordinateElement, CDims...>;
31
32template <concepts::discrete_dimension... DDims>
33KOKKOS_FUNCTION Coordinate<typename DDims::continuous_dimension_type...> coordinate(
34 DiscreteElement<DDims...> const& c)
35 requires(sizeof...(DDims) > 1)
36{
37 return Coordinate<typename DDims::continuous_dimension_type...>(
38 coordinate(DiscreteElement<DDims>(c))...);
39}
40
41// Gives access to the type of the coordinates of a discrete element
42// Example usage : "using Coords = coordinate_of_t<DElem>;"
43template <class T>
44struct coordinate_of
45{
46 static_assert(is_discrete_element_v<T>, "Parameter T must be of type DiscreteElement");
47 using type = decltype(coordinate(std::declval<T>()));
48};
49
50/// Helper type of \ref ddc::coordinate_of
51template <class T>
52using coordinate_of_t = coordinate_of<T>::type;
53
54} // namespace ddc
The top-level namespace of DDC.
KOKKOS_FUNCTION Coordinate< typename DDims::continuous_dimension_type... > coordinate(DiscreteElement< DDims... > const &c)