DDC 0.12.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
14#include "real_type.hpp"
15
16namespace ddc {
17
18/** A CoordinateElement the type of the scalar used to represent elements of coordinates in the
19 * continuous space.
20 */
21using CoordinateElement = Real;
22
23/** A Coordinate represents a coordinate in the continuous space
24 *
25 * It is tagged by its dimensions.
26 */
27
28template <class... CDims>
29using Coordinate = detail::TaggedVector<CoordinateElement, CDims...>;
30
31template <class... DDims>
32KOKKOS_FUNCTION Coordinate<typename DDims::continuous_dimension_type...> coordinate(
33 DiscreteElement<DDims...> const& c)
34 requires(sizeof...(DDims) > 1)
35{
36 return Coordinate<typename DDims::continuous_dimension_type...>(
37 coordinate(DiscreteElement<DDims>(c))...);
38}
39
40// Gives access to the type of the coordinates of a discrete element
41// Example usage : "using Coords = coordinate_of_t<DElem>;"
42template <class T>
43struct coordinate_of
44{
45 static_assert(is_discrete_element_v<T>, "Parameter T must be of type DiscreteElement");
46 using type = decltype(coordinate(std::declval<T>()));
47};
48
49/// Helper type of \ref ddc::coordinate_of
50template <class T>
51using coordinate_of_t = typename coordinate_of<T>::type;
52
53} // namespace ddc
The top-level namespace of DDC.
KOKKOS_FUNCTION Coordinate< typename DDims::continuous_dimension_type... > coordinate(DiscreteElement< DDims... > const &c)