DDC 0.8.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 <type_traits>
8#include <utility>
9
10#include <Kokkos_Macros.hpp>
11
12#include "detail/tagged_vector.hpp"
13
14#include "discrete_element.hpp"
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 <class... DDim, std::enable_if_t<(sizeof...(DDim) > 1), int> = 0>
33KOKKOS_FUNCTION Coordinate<typename DDim::continuous_dimension_type...> coordinate(
34 DiscreteElement<DDim...> const& c)
35{
36 return Coordinate<typename DDim::continuous_dimension_type...>(
37 coordinate(DiscreteElement<DDim>(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 DDim::continuous_dimension_type... > coordinate(DiscreteElement< DDim... > const &c)