DDC 0.1.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 "ddc/detail/tagged_vector.hpp"
13#include "ddc/discrete_element.hpp"
14#include "ddc/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... DDim, std::enable_if_t<(sizeof...(DDim) > 1), int> = 0>
32KOKKOS_FUNCTION Coordinate<typename DDim::continuous_dimension_type...> coordinate(
33 DiscreteElement<DDim...> const& c)
34{
35 return Coordinate<typename DDim::continuous_dimension_type...>(
36 coordinate(DiscreteElement<DDim>(c))...);
37}
38
39// Gives access to the type of the coordinates of a discrete element
40// Example usage : "using Coords = coordinate_of_t<DElem>;"
41template <class T>
42struct coordinate_of
43{
44 static_assert(is_discrete_element_v<T>, "Parameter T must be of type DiscreteElement");
45 using type = decltype(coordinate(std::declval<T>()));
46};
47
48/// Helper type of \ref ddc::coordinate_of
49template <class T>
50using coordinate_of_t = typename coordinate_of<T>::type;
51
52} // namespace ddc
The top-level namespace of DDC.
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type... > coordinate(DiscreteElement< DDim... > const &c)