Gyselalib++
geometry.hpp
1 // SPDX-License-Identifier: MIT
2 #pragma once
3 #include <ddc/ddc.hpp>
4 #include <ddc/kernels/splines.hpp>
5 
6 #include <sll/polar_bsplines.hpp>
7 
8 #include "ddc_alias_inline_functions.hpp"
9 #include "ddc_aliases.hpp"
10 #include "ddc_helper.hpp"
11 #include "directional_tag.hpp"
12 #include "vector_field.hpp"
13 #include "vector_field_mem.hpp"
14 
15 
16 /*
17  * @file geometry.hpp
18  *
19  * Definition of
20  * - @f$ r@f$, @f$ \theta@f$, @f$(r, \theta)@f$ dimensions.
21  * - @f$x@f$, @f$y@f$, @f$(x, y)@f$ dimensions.
22  */
23 
24 
25 // POLAR SPACE AND VELOCITY ----------------------------------------------------------------------
26 // --- Continuous dimensions
30 struct R
31 {
36  static bool constexpr PERIODIC = false;
37 };
41 struct Theta
42 {
47  static bool constexpr PERIODIC = true;
48 };
49 
53 struct Vr
54 {
59  static bool constexpr PERIODIC = false;
60 };
64 struct Vtheta
65 {
70  static bool constexpr PERIODIC = true;
71 };
72 
73 
74 using CoordR = Coord<R>;
75 using CoordTheta = Coord<Theta>;
76 using CoordRTheta = Coord<R, Theta>;
77 
78 using CoordVr = Coord<Vr>;
79 using CoordVtheta = Coord<Vtheta>;
80 
81 // --- Spline definitions
82 int constexpr BSDegreeR = 3;
83 int constexpr BSDegreeP = 3;
84 
85 bool constexpr BsplineOnUniformCellsR = false;
86 bool constexpr BsplineOnUniformCellsP = false;
87 
88 struct BSplinesR
89  : std::conditional_t<
90  BsplineOnUniformCellsR,
91  ddc::UniformBSplines<R, BSDegreeR>,
92  ddc::NonUniformBSplines<R, BSDegreeR>>
93 {
94 };
96  : std::conditional_t<
97  BsplineOnUniformCellsP,
98  ddc::UniformBSplines<Theta, BSDegreeP>,
99  ddc::NonUniformBSplines<Theta, BSDegreeP>>
100 {
101 };
102 struct PolarBSplinesRTheta : PolarBSplines<BSplinesR, BSplinesTheta, 1>
103 {
104 };
105 
106 ddc::BoundCond constexpr SplineRBoundary = ddc::BoundCond::GREVILLE;
107 ddc::BoundCond constexpr SplinePBoundary = ddc::BoundCond::PERIODIC;
108 
109 using SplineInterpPointsR
110  = ddc::GrevilleInterpolationPoints<BSplinesR, SplineRBoundary, SplineRBoundary>;
111 using SplineInterpPointsTheta
112  = ddc::GrevilleInterpolationPoints<BSplinesTheta, SplinePBoundary, SplinePBoundary>;
113 
114 // --- Discrete dimensions
115 struct GridR : SplineInterpPointsR::interpolation_discrete_dimension_type
116 {
117 };
118 struct GridTheta : SplineInterpPointsTheta::interpolation_discrete_dimension_type
119 {
120 };
121 
122 // --- Operators
123 using SplineRThetaBuilder = ddc::SplineBuilder2D<
124  Kokkos::DefaultHostExecutionSpace,
125  Kokkos::HostSpace,
126  BSplinesR,
128  GridR,
129  GridTheta,
130  SplineRBoundary, // boundary at r=0
131  SplineRBoundary, // boundary at rmax
132  SplinePBoundary,
133  SplinePBoundary,
134  ddc::SplineSolver::LAPACK,
135  GridR,
136  GridTheta>;
137 
138 using SplineRThetaEvaluatorConstBound = ddc::SplineEvaluator2D<
139  Kokkos::DefaultHostExecutionSpace,
140  Kokkos::HostSpace,
141  BSplinesR,
143  GridR,
144  GridTheta,
145  ddc::ConstantExtrapolationRule<R, Theta>, // boundary at r=0
146  ddc::ConstantExtrapolationRule<R, Theta>, // boundary at rmax
147  ddc::PeriodicExtrapolationRule<Theta>,
148  ddc::PeriodicExtrapolationRule<Theta>,
149  GridR,
150  GridTheta>;
151 
152 using SplineRThetaEvaluatorNullBound = ddc::SplineEvaluator2D<
153  Kokkos::DefaultHostExecutionSpace,
154  Kokkos::HostSpace,
155  BSplinesR,
157  GridR,
158  GridTheta,
159  ddc::NullExtrapolationRule, // boundary at r=0
160  ddc::NullExtrapolationRule, // boundary at rmax
161  ddc::PeriodicExtrapolationRule<Theta>,
162  ddc::PeriodicExtrapolationRule<Theta>,
163  GridR,
164  GridTheta>;
165 
166 
167 // --- Index definitions
168 using IdxR = Idx<GridR>;
169 using IdxTheta = Idx<GridTheta>;
170 using IdxRTheta = Idx<GridR, GridTheta>;
171 
172 // --- Index Step definitions
173 using IdxStepR = IdxStep<GridR>;
174 using IdxStepTheta = IdxStep<GridTheta>;
175 using IdxStepRTheta = IdxStep<GridR, GridTheta>;
176 
177 // --- Index Range definitions
178 using IdxRangeR = IdxRange<GridR>;
179 using IdxRangeTheta = IdxRange<GridTheta>;
180 using IdxRangeRTheta = IdxRange<GridR, GridTheta>;
181 
182 using IdxRangeBSR = IdxRange<BSplinesR>;
183 using IdxRangeBSTheta = IdxRange<BSplinesTheta>;
184 using IdxRangeBSRTheta = IdxRange<BSplinesR, BSplinesTheta>;
185 using IdxRangeBSPolar = IdxRange<PolarBSplinesRTheta>;
186 
187 
188 // --- FieldMem definitions
189 template <class ElementType>
190 using FieldMemR = FieldMem<ElementType, IdxRangeR>;
191 
192 template <class ElementType>
193 using FieldMemTheta = FieldMem<ElementType, IdxRangeTheta>;
194 
195 template <class ElementType>
196 using FieldMemRTheta = FieldMem<ElementType, IdxRangeRTheta>;
197 
198 using DFieldMemR = FieldMemR<double>;
199 using DFieldMemTheta = FieldMemTheta<double>;
200 using DFieldMemRTheta = FieldMemRTheta<double>;
201 
202 // --- Field definitions
203 template <class ElementType>
204 using FieldR = Field<ElementType, IdxRangeR>;
205 
206 template <class ElementType>
207 using FieldTheta = Field<ElementType, IdxRangeTheta>;
208 
209 // Equivalent to host_t<Field<ElementType, IdxRangeRTheta>> but used for type deductions
210 template <class ElementType>
211 using FieldRTheta = Field<ElementType, IdxRangeRTheta, Kokkos::HostSpace>;
212 
213 using DFieldR = FieldR<double>;
214 using DFieldTheta = FieldTheta<double>;
215 using DFieldRTheta = FieldRTheta<double>;
216 
217 // --- Const Field definitions
218 template <class ElementType>
219 using ConstFieldR = ConstField<ElementType, IdxRangeR>;
220 
221 template <class ElementType>
222 using ConstFieldTheta = ConstField<ElementType, IdxRangeTheta>;
223 
224 template <class ElementType>
225 using ConstFieldRTheta = ConstField<ElementType, IdxRangeRTheta>;
226 
227 using DConstFieldR = ConstFieldR<double>;
228 using DConstFieldTheta = ConstFieldTheta<double>;
229 using DConstFieldRTheta = ConstFieldRTheta<double>;
230 
231 // --- Spline representation definitions
232 using Spline2DMem = DFieldMem<IdxRangeBSRTheta>;
233 using Spline2D = DField<IdxRangeBSRTheta>;
234 using ConstSpline2D = DConstField<IdxRangeBSRTheta>;
235 
242 
246 using IdxPolarBspl = Idx<PolarBSplinesRTheta>;
247 
248 
249 // --- VectorFieldMem definitions
250 template <class Dim1, class Dim2>
252 
253 template <class Dim1, class Dim2>
255 
256 template <class Dim1, class Dim2>
258 
259 
260 
261 template <class Dim1, class Dim2>
263 
264 template <class Dim1, class Dim2>
266 
267 template <class Dim1, class Dim2>
269 
270 
271 
272 // CARTESIAN SPACE AND VELOCITY ------------------------------------------------------------------
273 // --- Continuous dimensions
277 struct X
278 {
283  static bool constexpr PERIODIC = false;
284 };
288 struct Y
289 {
294  static bool constexpr PERIODIC = false;
295 };
296 
300 struct Vx
301 {
306  static bool constexpr PERIODIC = false;
307 };
311 struct Vy
312 {
317  static bool constexpr PERIODIC = false;
318 };
319 
320 
321 using CoordX = Coord<X>;
322 using CoordY = Coord<Y>;
323 using CoordXY = Coord<X, Y>;
324 
325 using CoordVx = Coord<Vx>;
326 using CoordVy = Coord<Vy>;
A class containing all information describing polar bsplines.
Definition: polar_bsplines.hpp:28
Pre-declaration of VectorFieldMem.
Definition: vector_field_mem.hpp:54
A class which holds multiple (scalar) fields in order to represent a vector field.
Definition: vector_field.hpp:64
Definition: geometry.hpp:93
Definition: geometry.hpp:100
Definition: geometry.hpp:116
Definition: geometry.hpp:119
Definition: geometry.hpp:103
A structure containing the two Chunks necessary to define a spline on a set of polar basis splines.
Definition: polar_spline.hpp:20
Define non periodic real R dimension.
Definition: geometry.hpp:31
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:36
Define periodic real Theta dimension.
Definition: geometry.hpp:42
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:47
Define non periodic real R velocity dimension.
Definition: geometry.hpp:54
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:59
Define periodic real Theta velocity dimension.
Definition: geometry.hpp:65
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:70
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 Y velocity dimension.
Definition: geometry.hpp:312
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:317
Define non periodic real X dimension.
Definition: geometry.hpp:278
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:283
Define non periodic real Y dimension.
Definition: geometry.hpp:289
static constexpr bool PERIODIC
Define periodicity of the dimension.
Definition: geometry.hpp:294