Gyselalib++
 
Loading...
Searching...
No Matches
collisions_dimensions.hpp
1// SPDX-License-Identifier: MIT
2#pragma once
3#include "ddc_alias_inline_functions.hpp"
4#include "ddc_aliases.hpp"
5
18{
19};
20
25
30
32template <class Grid1D>
33inline constexpr bool is_spoofed_dim_v = std::is_base_of_v<InternalSpoofGrid, Grid1D>;
34
39template <class Field>
41{
42 static_assert(!std::is_same_v<Field, Field>, "Unrecognised radial profile type");
43};
44
50template <class Field, class GridR>
52{
53 static_assert(!std::is_same_v<Field, Field>, "Unrecognised poloidal profile type");
54};
55
65template <class Grid1D, class IdxRangeFDistrib>
66inline IdxRange<Grid1D> get_1d_idx_range(IdxRangeFDistrib idx_range)
67{
68 if constexpr (is_spoofed_dim_v<Grid1D>) {
69 return IdxRange<Grid1D>(Idx<Grid1D> {0}, IdxStep<Grid1D> {1});
70 } else {
71 return ddc::select<Grid1D>(idx_range);
72 }
73}
74
82template <class... Grid1D, class IdxRangeFDistrib>
83inline IdxRange<Grid1D...> get_expanded_idx_range(IdxRangeFDistrib idx_range)
84{
85 return IdxRange<Grid1D...>(get_1d_idx_range<Grid1D>(idx_range)...);
86}
87
89template <>
90struct ExtractRDim<double>
91{
93};
94
96template <class GridR, class Layout>
98 ConstField<double, IdxRange<GridR>, Kokkos::DefaultExecutionSpace::memory_space, Layout>>
99{
100 using type = GridR;
101};
102
104template <class ElementType, class IdxRange, class MemSpace, class Layout>
105struct ExtractRDim<Field<ElementType, IdxRange, MemSpace, Layout>>
106{
107 static_assert(
108 std::is_same_v<ElementType, const double>,
109 "The radial profile should be a double and should not be modifiable. Please use a "
110 "constant field.");
111 static_assert(
112 std::is_same_v<MemSpace, Kokkos::DefaultExecutionSpace::memory_space>,
113 "The radial profile should be provided on the GPU");
114 static_assert(
115 (ddc::type_seq_size_v<ddc::to_type_seq_t<IdxRange>>) > 1,
116 "The radial profile should not be defined on more than 1 dimensions.");
117};
118
120template <>
122{
124};
125
127template <class GridR, class Layout>
129 ConstField<double, IdxRange<GridR>, Kokkos::DefaultExecutionSpace::memory_space, Layout>,
130 GridR>
131{
133};
134
136template <class GridR, class GridTheta, class Layout>
138 ConstField<
139 double,
140 IdxRange<GridTheta>,
141 Kokkos::DefaultExecutionSpace::memory_space,
142 Layout>,
143 GridR>
144{
145 using type = GridTheta;
146};
147
149template <class GridR, class GridTheta, class Layout>
151 ConstField<
152 double,
153 IdxRange<GridTheta, GridR>,
154 Kokkos::DefaultExecutionSpace::memory_space,
155 Layout>,
156 GridR>
157{
158 using type = GridTheta;
159};
160
162template <class GridR, class ElementType, class IdxRange, class MemSpace, class Layout>
163struct ExtractThetaDim<Field<ElementType, IdxRange, MemSpace, Layout>, GridR>
164{
165 static_assert(
166 std::is_same_v<ElementType, const double>,
167 "The poloidal profile should be a double and should not be modifiable. Please use a "
168 "constant field.");
169 static_assert(
170 std::is_same_v<MemSpace, Kokkos::DefaultExecutionSpace::memory_space>,
171 "The poloidal profile should be provided on the GPU");
172 static_assert(
173 (ddc::type_seq_size_v<ddc::to_type_seq_t<IdxRange>>) > 2,
174 "The poloidal profile should not be defined on more than 2 dimensions.");
175};
176
183template <class Field>
185{
186 static_assert(!std::is_same_v<Field, Field>, "Unrecognised poloidal profile type");
187};
188
190template <>
191struct ExtractRThetaTags<double>
192{
193 using type = ddc::detail::TypeSeq<>;
194};
195
197template <class IdxRange>
198struct ExtractRThetaTags<DConstField<IdxRange>>
199{
200 using type = ddc::to_type_seq_t<IdxRange>;
201};
202
215template <class Grid1D, class OrderedGrids>
216constexpr bool check_dimension_location(int& idx)
217{
218 if constexpr (!is_spoofed_dim_v<Grid1D>) {
219 bool success = ddc::type_seq_rank_v<Grid1D, OrderedGrids> == idx;
220 idx += 1;
221 return success;
222 } else {
223 return true;
224 }
225}
226
236template <class OrderedGrids, class... ExpectedGrids>
237constexpr bool order_of_last_grids()
238{
239 int n_real_dims = ((is_spoofed_dim_v<ExpectedGrids> ? 0 : 1) + ...);
240 int idx(ddc::type_seq_size_v<OrderedGrids> - n_real_dims);
241 return ((check_dimension_location<ExpectedGrids, OrderedGrids>(idx)) && ...);
242}
243
253template <class OrderedGrids, class... ExpectedGrids>
254constexpr bool order_of_first_grids()
255{
256 int idx(0);
257 return ((check_dimension_location<ExpectedGrids, OrderedGrids>(idx)) && ...);
258}
259
260} // namespace collisions_dimensions
A namespace to collect classes which are necessary to create Fields with the correct number of dimens...
Definition collisions_dimensions.hpp:10
IdxRange< Grid1D > get_1d_idx_range(IdxRangeFDistrib idx_range)
Get the index range for a specific grid from a multi-D index range.
Definition collisions_dimensions.hpp:66
constexpr bool order_of_first_grids()
A helper function to check if the first grids in an ordered set of grids match the order of the provi...
Definition collisions_dimensions.hpp:254
constexpr bool check_dimension_location(int &idx)
A helper function to check if a grid is found at the correct location in a set of ordered grids.
Definition collisions_dimensions.hpp:216
IdxRange< Grid1D... > get_expanded_idx_range(IdxRangeFDistrib idx_range)
Get the index range for specific grid dimensions from a multi-D index range.
Definition collisions_dimensions.hpp:83
constexpr bool order_of_last_grids()
A helper function to check if the final grids in an ordered set of grids match the order of the provi...
Definition collisions_dimensions.hpp:237
constexpr bool is_spoofed_dim_v
Check if a dimension is spoofed but is not present in the actual simulation.
Definition collisions_dimensions.hpp:33
Class to get the type of the radial dimension from a field containing a radial profile.
Definition collisions_dimensions.hpp:41
Class to get a DDC TypeSeq containing the input radial and theta tags.
Definition collisions_dimensions.hpp:185
Class to get the type of the poloidal dimension from a field containing a profile on the poloidal pla...
Definition collisions_dimensions.hpp:52
Definition geometry.hpp:116
Definition geometry.hpp:119
Fake radial dimension to be used if there is no radial dimension in the simulation.
Definition collisions_dimensions.hpp:23
Fake poloidal dimension to be used if there is no poloidal dimension in the simulation.
Definition collisions_dimensions.hpp:28
Create dimensions to act as the radial/poloidal/toroidal tag for Koliop even if these dims don't exis...
Definition collisions_dimensions.hpp:18