/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/coordinates/coordinates.hh Source File#
|
DiFfRG
|
coordinates.hh
Go to the documentation of this file.
39 static_assert(sizeof...(Coordinates) > 0, "CoordinatePackND requires at least one coordinate system");
41 static_assert(((Coordinates::dim == 1) && ...), "CoordinatePackND requires all coordinates to have dim 1");
59 return forward_impl(device::make_integer_sequence<int, sizeof...(I)>(), device::forward<I>(i)...);
62 KOKKOS_FORCEINLINE_FUNCTION device::array<ctype, dim> forward(const device::array<IT, dim> &coords) const
68 device::array<ctype, dim> KOKKOS_FORCEINLINE_FUNCTION forward_impl(device::integer_sequence<int, Is...>,
74 template <typename... I> KOKKOS_FORCEINLINE_FUNCTION device::array<ctype, sizeof...(I)> backward(I &&...i) const
77 return backward_impl(device::make_integer_sequence<int, sizeof...(I)>(), device::forward<I>(i)...);
81 device::array<ctype, sizeof...(I)> KOKKOS_FORCEINLINE_FUNCTION backward_impl(device::integer_sequence<int, Is...>,
93 constexpr_for<0, sizeof...(Coordinates), 1>([&](auto i) { size *= device::get<i>(coordinates).size(); });
100 constexpr_for<0, sizeof...(Coordinates), 1>([&](auto i) { sizes[i] = device::get<i>(coordinates).size(); });
104 device::array<size_t, sizeof...(Coordinates)> KOKKOS_INLINE_FUNCTION from_linear_index(size_t s) const
109 idx[sizeof...(Coordinates) - 1 - i] = s % device::get<sizeof...(Coordinates) - 1 - i>(coordinates).size();
117 friend bool operator==(const CoordinatePackND<Coordinates...> &r, const CoordinatePackND<Coordinates2...> &l)
157 if (offset + size > base.size()) throw std::runtime_error("SubCoordinates: offset + size must be <= base.size()");
188 template <typename IT> KOKKOS_INLINE_FUNCTION device::array<ctype, dim> forward(device::array<IT, dim> i) const
196 template <typename... I> KOKKOS_FORCEINLINE_FUNCTION device::array<ctype, dim> backward(I &&...i) const
262 template <typename IT> NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const { return start + a * x; }
264 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
292 return "LinearCoordinates1D(" + std::to_string(grid_extent) + ", " + std::to_string(start) + ", " +
313 if (grid_extent == 0) throw std::runtime_error("LogarithmicCoordinates1D: grid_extent must be > 0");
343 template <typename IT> device::array<NT, 1> KOKKOS_FORCEINLINE_FUNCTION forward(const device::array<IT, 1> &x) const
360 NT KOKKOS_FORCEINLINE_FUNCTION backward_derivative(const NT &y) const { return 1. / (y - c) * gem1 / a; }
369 friend bool operator==(const LogarithmicCoordinates1D<NT> &lhs, const LogarithmicCoordinates1D<NT2> &rhs)
402 template <typename Coordinates> auto make_idx_grid(const Coordinates &coordinates) -> std::vector<double>
432 using LogLogCoordinates = CoordinatePackND<LogarithmicCoordinates1D<double>, LogarithmicCoordinates1D<double>>;
433 using LogLinCoordinates = CoordinatePackND<LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>>;
434 using LinLogCoordinates = CoordinatePackND<LinearCoordinates1D<double>, LogarithmicCoordinates1D<double>>;
435 using LinLinCoordinates = CoordinatePackND<LinearCoordinates1D<double>, LinearCoordinates1D<double>>;
437 CoordinatePackND<LogarithmicCoordinates1D<double>, LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>>;
439 CoordinatePackND<LogarithmicCoordinates1D<double>, LinearCoordinates1D<double>, LinearCoordinates1D<double>>;
441 CoordinatePackND<LinearCoordinates1D<double>, LinearCoordinates1D<double>, LinearCoordinates1D<double>>;
Utility class for combining multiple coordinate systems into one.
Definition coordinates.hh:33
const auto & get_coordinates() const
Definition coordinates.hh:87
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, sizeof...(I)> backward(I &&...i) const
Definition coordinates.hh:74
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Definition coordinates.hh:89
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > forward(I &&...i) const
Definition coordinates.hh:56
device::array< size_t, sizeof...(Coordinates)> KOKKOS_INLINE_FUNCTION from_linear_index(size_t s) const
Definition coordinates.hh:104
CoordinatePackND(Coordinates... coordinates)
Construct a new CoordinatePackND object.
Definition coordinates.hh:52
device::array< ctype, sizeof...(I)> KOKKOS_FORCEINLINE_FUNCTION backward_impl(device::integer_sequence< int, Is... >, I &&...i) const
Definition coordinates.hh:81
friend bool operator==(const CoordinatePackND< Coordinates... > &r, const CoordinatePackND< Coordinates2... > &l)
Definition coordinates.hh:117
device::array< size_t, sizeof...(Coordinates)> KOKKOS_FORCEINLINE_FUNCTION sizes() const
Definition coordinates.hh:97
device::array< ctype, dim > KOKKOS_FORCEINLINE_FUNCTION forward_impl(device::integer_sequence< int, Is... >, I &&...i) const
Definition coordinates.hh:68
const device::tuple< Coordinates... > coordinates
Definition coordinates.hh:145
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > forward(const device::array< IT, dim > &coords) const
Definition coordinates.hh:62
typename device::tuple_element< 0, device::tuple< Coordinates... > >::type::ctype ctype
Definition coordinates.hh:44
Definition coordinates.hh:233
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
Definition coordinates.hh:251
friend bool operator==(const LinearCoordinates1D< NT > &lhs, const LinearCoordinates1D< NT2 > &rhs)
Definition coordinates.hh:284
LinearCoordinates1D(size_t grid_extent, double start, double stop)
Definition coordinates.hh:238
NT KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
Transform from the physical space to the grid.
Definition coordinates.hh:275
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Definition coordinates.hh:277
NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const
Transform from the grid to the physical space.
Definition coordinates.hh:262
LinearCoordinates1D(const LinearCoordinates1D< NT2 > &other)
Definition coordinates.hh:246
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION sizes() const
Definition coordinates.hh:279
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
Definition coordinates.hh:264
Definition coordinates.hh:304
LogarithmicCoordinates1D(const LogarithmicCoordinates1D< NT2 > &other)
Definition coordinates.hh:321
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION from_linear_index(size_t i) const
Definition coordinates.hh:326
NT KOKKOS_FORCEINLINE_FUNCTION backward_derivative(const NT &y) const
Definition coordinates.hh:360
friend bool operator==(const LogarithmicCoordinates1D< NT > &lhs, const LogarithmicCoordinates1D< NT2 > &rhs)
Definition coordinates.hh:369
device::array< size_t, 1 > KOKKOS_FORCEINLINE_FUNCTION sizes() const
Definition coordinates.hh:364
std::string to_string() const
Definition coordinates.hh:376
NT KOKKOS_FORCEINLINE_FUNCTION forward(const IT &x) const
Transform from the grid to the physical space.
Definition coordinates.hh:337
NT KOKKOS_FORCEINLINE_FUNCTION backward(const NT &y) const
Transform from the physical space to the grid.
Definition coordinates.hh:354
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Definition coordinates.hh:362
device::array< NT, 1 > KOKKOS_FORCEINLINE_FUNCTION forward(const device::array< IT, 1 > &x) const
Definition coordinates.hh:343
LogarithmicCoordinates1D(size_t grid_extent, NT start, NT stop, NT bias)
Definition coordinates.hh:309
Definition coordinates.hh:149
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > forward(I &&...i) const
Definition coordinates.hh:182
KOKKOS_INLINE_FUNCTION device::array< ctype, dim > forward(device::array< IT, dim > i) const
Definition coordinates.hh:188
KOKKOS_FORCEINLINE_FUNCTION device::array< ctype, dim > backward(I &&...i) const
Definition coordinates.hh:196
size_t KOKKOS_FORCEINLINE_FUNCTION size() const
Definition coordinates.hh:167
device::array< size_t, dim > KOKKOS_INLINE_FUNCTION from_linear_index(size_t s) const
Definition coordinates.hh:169
SubCoordinates(const Base &base, size_t offset, size_t size)
Definition coordinates.hh:154
KOKKOS_INLINE_FUNCTION device::array< ctype, dim > backward(device::array< size_t, dim > i) const
Definition coordinates.hh:201
device::array< size_t, dim > KOKKOS_FORCEINLINE_FUNCTION sizes() const
Definition coordinates.hh:165
Definition coordinates.hh:19
Definition complex_math.hh:10
std::vector< typename Coordinates::ctype > dump_grid(const Coordinates &coordinates)
Definition coordinates.hh:416
constexpr void constexpr_for(F &&f)
A compile-time for loop, which calls the lambda f of signature void(integer) for each index.
Definition utils.hh:31
auto make_idx_grid(const Coordinates &coordinates) -> std::vector< double >
Definition coordinates.hh:402
Generated by