Gyselalib++
geometry.hpp
1 // SPDX-License-Identifier: MIT
2 
3 #pragma once
4 #include <ddc/ddc.hpp>
5 #include <ddc/kernels/fft.hpp>
6 #include <ddc/kernels/splines.hpp>
7 
8 #include "ddc_alias_inline_functions.hpp"
9 #include "ddc_aliases.hpp"
10 #include "ddc_helper.hpp"
11 #include "moments.hpp"
12 #include "non_uniform_interpolation_points.hpp"
13 #include "species_info.hpp"
14 
18 struct X
19 {
23 #ifdef PERIODIC_RDIMX
24  static bool constexpr PERIODIC = true;
25 #else
26  static bool constexpr PERIODIC = false;
27 #endif
28 };
29 
33 struct Vx
34 {
38  static bool constexpr PERIODIC = false;
39 };
40 
44 struct T
45 {
49  static bool constexpr PERIODIC = false;
50 };
51 
52 
53 using CoordT = Coord<T>;
54 using CoordX = Coord<X>;
55 
56 using CoordVx = Coord<Vx>;
57 
58 using CoordXVx = Coord<X, Vx>;
59 
60 int constexpr BSDegreeX = 3;
61 int constexpr BSDegreeVx = 3;
62 
63 #ifdef INPUT_MESH
64 bool constexpr BsplineOnUniformCellsX = false;
65 bool constexpr BsplineOnUniformCellsVx = false;
66 #else
67 bool constexpr BsplineOnUniformCellsX = true;
68 bool constexpr BsplineOnUniformCellsVx = true;
69 #endif
70 
71 struct BSplinesX
72  : std::conditional_t<
73  BsplineOnUniformCellsX,
74  ddc::UniformBSplines<X, BSDegreeX>,
75  ddc::NonUniformBSplines<X, BSDegreeX>>
76 {
77 };
78 struct BSplinesVx
79  : std::conditional_t<
80  BsplineOnUniformCellsVx,
81  ddc::UniformBSplines<Vx, BSDegreeVx>,
82  ddc::NonUniformBSplines<Vx, BSDegreeVx>>
83 {
84 };
85 
86 auto constexpr SplineXBoundary = X::PERIODIC ? ddc::BoundCond::PERIODIC : ddc::BoundCond::GREVILLE;
87 auto constexpr SplineVxBoundary = ddc::BoundCond::HERMITE;
88 
89 #ifdef INPUT_MESH
90 using SplineInterpPointsX
92 using SplineInterpPointsVx
94 #else
95 using SplineInterpPointsX
96  = ddc::GrevilleInterpolationPoints<BSplinesX, SplineXBoundary, SplineXBoundary>;
97 using SplineInterpPointsVx
98  = ddc::GrevilleInterpolationPoints<BSplinesVx, SplineVxBoundary, SplineVxBoundary>;
99 #endif
100 
101 struct GridX : SplineInterpPointsX::interpolation_discrete_dimension_type
102 {
103 };
104 struct GridVx : SplineInterpPointsVx::interpolation_discrete_dimension_type
105 {
106 };
107 
108 using SplineXBuilder = ddc::SplineBuilder<
109  Kokkos::DefaultExecutionSpace,
110  Kokkos::DefaultExecutionSpace::memory_space,
111  BSplinesX,
112  GridX,
113  SplineXBoundary,
114  SplineXBoundary,
115  ddc::SplineSolver::LAPACK,
116  GridX,
117  GridVx>;
118 using SplineXEvaluator = ddc::SplineEvaluator<
119  Kokkos::DefaultExecutionSpace,
120  Kokkos::DefaultExecutionSpace::memory_space,
121  BSplinesX,
122  GridX,
123 #ifdef PERIODIC_RDIMX
124  ddc::PeriodicExtrapolationRule<X>,
125  ddc::PeriodicExtrapolationRule<X>,
126 #else
127  ddc::ConstantExtrapolationRule<X>,
128  ddc::ConstantExtrapolationRule<X>,
129 #endif
130  GridX,
131  GridVx>;
132 using SplineVxBuilder = ddc::SplineBuilder<
133  Kokkos::DefaultExecutionSpace,
134  Kokkos::DefaultExecutionSpace::memory_space,
135  BSplinesVx,
136  GridVx,
137  SplineVxBoundary,
138  SplineVxBoundary,
139  ddc::SplineSolver::LAPACK,
140  GridX,
141  GridVx>;
142 using SplineVxEvaluator = ddc::SplineEvaluator<
143  Kokkos::DefaultExecutionSpace,
144  Kokkos::DefaultExecutionSpace::memory_space,
145  BSplinesVx,
146  GridVx,
147  ddc::ConstantExtrapolationRule<Vx>,
148  ddc::ConstantExtrapolationRule<Vx>,
149  GridX,
150  GridVx>;
151 using SplineXBuilder_1d = ddc::SplineBuilder<
152  Kokkos::DefaultExecutionSpace,
153  Kokkos::DefaultExecutionSpace::memory_space,
154  BSplinesX,
155  GridX,
156  SplineXBoundary,
157  SplineXBoundary,
158  ddc::SplineSolver::LAPACK,
159  GridX>;
160 using SplineXEvaluator_1d = ddc::SplineEvaluator<
161  Kokkos::DefaultExecutionSpace,
162  Kokkos::DefaultExecutionSpace::memory_space,
163  BSplinesX,
164  GridX,
165 #ifdef PERIODIC_RDIMX
166  ddc::PeriodicExtrapolationRule<X>,
167  ddc::PeriodicExtrapolationRule<X>,
168 #else
169  ddc::ConstantExtrapolationRule<X>,
170  ddc::ConstantExtrapolationRule<X>,
171 #endif
172  GridX>;
173 using SplineVxBuilder_1d = ddc::SplineBuilder<
174  Kokkos::DefaultHostExecutionSpace,
175  Kokkos::HostSpace,
176  BSplinesVx,
177  GridVx,
178  SplineVxBoundary,
179  SplineVxBoundary,
180  ddc::SplineSolver::LAPACK,
181  GridVx>;
182 using SplineVxEvaluator_1d = ddc::SplineEvaluator<
183  Kokkos::DefaultHostExecutionSpace,
184  Kokkos::HostSpace,
185  BSplinesVx,
186  GridVx,
187  ddc::ConstantExtrapolationRule<Vx>,
188  ddc::ConstantExtrapolationRule<Vx>,
189  GridVx>;
190 
191 struct GridMom : Moments
192 {
193 };
194 
195 using IdxMom = Idx<GridMom>;
196 
197 using IdxVx = Idx<GridVx>;
198 
199 using IdxX = Idx<GridX>;
200 
201 
202 using IdxSpMom = Idx<Species, GridMom>;
203 
204 using IdxSpMomX = Idx<Species, GridMom, GridX>;
205 
206 using IdxSpX = Idx<Species, GridX>;
207 
208 using IdxSpVx = Idx<Species, GridVx>;
209 
210 using IdxSpXVx = Idx<Species, GridX, GridVx>;
211 
212 using IdxXVx = Idx<GridX, GridVx>;
213 
214 
215 
216 using IdxStepMom = IdxStep<GridMom>;
217 
218 using IdxStepVx = IdxStep<GridVx>;
219 
220 using IdxStepX = IdxStep<GridX>;
221 
222 
223 using IdxStepSpMom = IdxStep<Species, GridMom>;
224 
225 using IdxStepSpMomX = IdxStep<Species, GridMom, GridX>;
226 
227 using IdxStepSpVx = IdxStep<Species, GridVx>;
228 
229 using IdxStepSpX = IdxStep<Species, GridX>;
230 
231 using IdxStepSpXVx = IdxStep<Species, GridX, GridVx>;
232 
233 using IdxStepXVx = IdxStep<GridX, GridVx>;
234 
235 
236 
237 using IdxRangeBSX = IdxRange<BSplinesX>;
238 
239 using IdxRangeBSVx = IdxRange<BSplinesVx>;
240 
241 
242 
243 using IdxRangeMom = IdxRange<GridMom>;
244 
245 using IdxRangeVx = IdxRange<GridVx>;
246 
247 using IdxRangeX = IdxRange<GridX>;
248 
249 using IdxRangeSpMom = IdxRange<Species, GridMom>;
250 
251 using IdxRangeSpMomX = IdxRange<Species, GridMom, GridX>;
252 
253 using IdxRangeSpVx = IdxRange<Species, GridVx>;
254 
255 using IdxRangeSpX = IdxRange<Species, GridX>;
256 
257 using IdxRangeSpXVx = IdxRange<Species, GridX, GridVx>;
258 
259 using IdxRangeXVx = IdxRange<GridX, GridVx>;
260 
261 
262 template <class ElementType>
263 using FieldMemVx = FieldMem<ElementType, IdxRangeVx>;
264 
265 template <class ElementType>
266 using FieldMemX = FieldMem<ElementType, IdxRangeX>;
267 
268 template <class ElementType>
269 using BSFieldMemX = FieldMem<ElementType, IdxRangeBSX>;
270 
271 
272 template <class ElementType>
273 using FieldMemSpMom = FieldMem<ElementType, IdxRangeSpMom>;
274 
275 template <class ElementType>
276 using FieldMemSpMomX = FieldMem<ElementType, IdxRangeSpMomX>;
277 
278 template <class ElementType>
279 using FieldMemSpVx = FieldMem<ElementType, IdxRangeSpVx>;
280 
281 template <class ElementType>
282 using FieldMemSpX = FieldMem<ElementType, IdxRangeSpX>;
283 
284 template <class ElementType>
285 using FieldMemSpXVx = FieldMem<ElementType, IdxRangeSpXVx>;
286 
287 
288 
289 using DFieldMemVx = FieldMemVx<double>;
290 
291 using DFieldMemX = FieldMemX<double>;
292 
293 using DBSFieldMemX = BSFieldMemX<double>;
294 
295 
296 using DFieldMemSpMom = FieldMemSpMom<double>;
297 
298 using DFieldMemSpMomX = FieldMemSpMomX<double>;
299 
300 using DFieldMemSpVx = FieldMemSpVx<double>;
301 
302 using DFieldMemSpX = FieldMemSpX<double>;
303 
304 using DFieldMemSpXVx = FieldMemSpXVx<double>;
305 
306 
307 
308 template <class ElementType>
309 using BSFieldX = Field<ElementType, IdxRangeBSX>;
310 
311 template <class ElementType>
312 using FieldX = Field<ElementType, IdxRangeX>;
313 
314 template <class ElementType>
315 using FieldVx = Field<ElementType, IdxRangeVx>;
316 
317 template <class ElementType>
318 using FieldSpMomX = Field<ElementType, IdxRangeSpMomX>;
319 
320 template <class ElementType>
321 using FieldSpMom = Field<ElementType, IdxRangeSpMom>;
322 
323 template <class ElementType>
324 using FieldSpVx = Field<ElementType, IdxRangeSpVx>;
325 
326 template <class ElementType>
327 using FieldSpX = Field<ElementType, IdxRangeSpX>;
328 
329 template <class ElementType>
330 using FieldSpXVx = Field<ElementType, IdxRangeSpXVx>;
331 
332 
333 using DBSFieldX = BSFieldX<double>;
334 
335 using DFieldVx = FieldVx<double>;
336 
337 using DFieldX = FieldX<double>;
338 
339 using DFieldSpMomX = FieldSpMomX<double>;
340 
341 using DFieldSpMom = FieldSpMom<double>;
342 
343 using DFieldSpVx = FieldSpVx<double>;
344 
345 using DFieldSpX = FieldSpX<double>;
346 
347 using DFieldSpXVx = FieldSpXVx<double>;
348 
349 
350 template <class ElementType>
351 using ConstFieldVx = Field<ElementType const, IdxRangeVx>;
352 
353 template <class ElementType>
354 using ConstFieldX = Field<ElementType const, IdxRangeX>;
355 
356 
357 template <class ElementType>
358 using BSConstFieldX = ConstField<ElementType, IdxRangeBSX>;
359 
360 template <class ElementType>
361 using ConstFieldSpMom = ConstField<ElementType, IdxRangeSpMom>;
362 
363 template <class ElementType>
364 using ConstFieldSpMomX = ConstField<ElementType, IdxRangeSpMomX>;
365 
366 template <class ElementType>
367 using ConstFieldSpMom = ConstField<ElementType, IdxRangeSpMom>;
368 
369 template <class ElementType>
370 using ConstFieldSpVx = ConstField<ElementType, IdxRangeSpVx>;
371 
372 template <class ElementType>
373 using ConstFieldSpX = ConstField<ElementType, IdxRangeSpX>;
374 
375 template <class ElementType>
376 using ConstFieldSpXVx = ConstField<ElementType, IdxRangeSpXVx>;
377 
378 
379 
380 using DConstFieldVx = ConstFieldVx<double>;
381 
382 using DConstFieldX = ConstFieldX<double>;
383 
384 
385 using DBSConstFieldX = BSConstFieldX<double>;
386 
387 using DConstFieldSpMom = ConstFieldSpMom<double>;
388 
389 using DConstFieldSpMomX = ConstFieldSpMomX<double>;
390 
391 using DConstFieldSpMom = ConstFieldSpMom<double>;
392 
393 using DConstFieldSpX = ConstFieldSpX<double>;
394 
395 using DConstFieldSpVx = ConstFieldSpVx<double>;
396 
397 using DConstFieldSpXVx = ConstFieldSpXVx<double>;
398 
399 
404 {
405 public:
409  template <class T>
410  using velocity_dim_for = std::conditional_t<std::is_same_v<T, GridX>, GridVx, void>;
411 
415  template <class T>
416  using spatial_dim_for = std::conditional_t<std::is_same_v<T, GridVx>, GridX, void>;
417 
421  using IdxRangeSpatial = IdxRangeX;
422 
426  using IdxRangeVelocity = IdxRangeVx;
427 
428 
429  // using FdistribuIdxRange = IdxRange<DimSp, typename decltype(SpatialDDom), typename decltype(VelocityDDom)>(IdxRange());
433  using IdxRangeFdistribu = IdxRangeSpXVx;
434 };
A class providing aliases for useful subindex ranges of the geometry.
Definition: geometry.hpp:404
IdxRangeX IdxRangeSpatial
An alias for the spatial discrete index range type.
Definition: geometry.hpp:421
std::conditional_t< std::is_same_v< T, GridX >, GridVx, void > velocity_dim_for
A templated type giving the velocity discretised dimension type associated to a spatial discretised d...
Definition: geometry.hpp:410
std::conditional_t< std::is_same_v< T, GridVx >, GridX, void > spatial_dim_for
A templated type giving the spatial discretised dimension type associated to a velocity discretised d...
Definition: geometry.hpp:416
IdxRangeVx IdxRangeVelocity
An alias for the velocity discrete index range type.
Definition: geometry.hpp:426
IdxRangeSpXVx IdxRangeFdistribu
An alias for the whole distribution function discrete index range type.
Definition: geometry.hpp:433
Moments discrete dimension to access constant attributes related to fluid moments.
Definition: moments.hpp:7
Helper class for the initialisation of the mesh of interpolation points.
Definition: non_uniform_interpolation_points.hpp:44
Definition: geometry.hpp:83
Definition: geometry.hpp:76
Definition: geometry.hpp:192
Definition: geometry.hpp:105
Definition: geometry.hpp:102
A class which describes the real space in the temporal direction.
Definition: geometry.hpp:45
static constexpr bool PERIODIC
A boolean indicating if the dimension is periodic.
Definition: geometry.hpp:49
Define non periodic real X velocity dimension.
Definition: geometry.hpp:301
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:306
Define non periodic real X dimension.
Definition: geometry.hpp:278
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:283