Gyselalib++
 
Loading...
Searching...
No Matches
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
30struct R
31{
36 static bool constexpr PERIODIC = false;
37};
41struct Theta
42{
47 static bool constexpr PERIODIC = true;
48};
49
53struct Vr
54{
59 static bool constexpr PERIODIC = false;
60};
64struct Vtheta
65{
70 static bool constexpr PERIODIC = true;
71};
72
73
74using CoordR = Coord<R>;
75using CoordTheta = Coord<Theta>;
76using CoordRTheta = Coord<R, Theta>;
77
78using CoordVr = Coord<Vr>;
79using CoordVtheta = Coord<Vtheta>;
80
81// --- Spline definitions
82int constexpr BSDegreeR = 3;
83int constexpr BSDegreeP = 3;
84
85bool constexpr BsplineOnUniformCellsR = false;
86bool constexpr BsplineOnUniformCellsP = false;
87
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};
102struct PolarBSplinesRTheta : PolarBSplines<BSplinesR, BSplinesTheta, 1>
103{
104};
105
106ddc::BoundCond constexpr SplineRBoundary = ddc::BoundCond::GREVILLE;
107ddc::BoundCond constexpr SplinePBoundary = ddc::BoundCond::PERIODIC;
108
109using SplineInterpPointsR
110 = ddc::GrevilleInterpolationPoints<BSplinesR, SplineRBoundary, SplineRBoundary>;
111using SplineInterpPointsTheta
112 = ddc::GrevilleInterpolationPoints<BSplinesTheta, SplinePBoundary, SplinePBoundary>;
113
114// --- Discrete dimensions
115struct GridR : SplineInterpPointsR::interpolation_discrete_dimension_type
116{
117};
118struct GridTheta : SplineInterpPointsTheta::interpolation_discrete_dimension_type
119{
120};
121
122// --- Operators
123using 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
138using 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
152using 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
168using IdxR = Idx<GridR>;
169using IdxTheta = Idx<GridTheta>;
170using IdxRTheta = Idx<GridR, GridTheta>;
171
172// --- Index Step definitions
173using IdxStepR = IdxStep<GridR>;
174using IdxStepTheta = IdxStep<GridTheta>;
175using IdxStepRTheta = IdxStep<GridR, GridTheta>;
176
177// --- Index Range definitions
178using IdxRangeR = IdxRange<GridR>;
179using IdxRangeTheta = IdxRange<GridTheta>;
180using IdxRangeRTheta = IdxRange<GridR, GridTheta>;
181
182using IdxRangeBSR = IdxRange<BSplinesR>;
183using IdxRangeBSTheta = IdxRange<BSplinesTheta>;
184using IdxRangeBSRTheta = IdxRange<BSplinesR, BSplinesTheta>;
185using IdxRangeBSPolar = IdxRange<PolarBSplinesRTheta>;
186
187
188// --- FieldMem definitions
189template <class ElementType>
190using FieldMemR = FieldMem<ElementType, IdxRangeR>;
191
192template <class ElementType>
193using FieldMemTheta = FieldMem<ElementType, IdxRangeTheta>;
194
195template <class ElementType>
196using FieldMemRTheta = FieldMem<ElementType, IdxRangeRTheta>;
197
198using DFieldMemR = FieldMemR<double>;
199using DFieldMemTheta = FieldMemTheta<double>;
200using DFieldMemRTheta = FieldMemRTheta<double>;
201
202// --- Field definitions
203template <class ElementType>
204using FieldR = Field<ElementType, IdxRangeR>;
205
206template <class ElementType>
207using FieldTheta = Field<ElementType, IdxRangeTheta>;
208
209// Equivalent to host_t<Field<ElementType, IdxRangeRTheta>> but used for type deductions
210template <class ElementType>
211using FieldRTheta = Field<ElementType, IdxRangeRTheta, Kokkos::HostSpace>;
212
213using DFieldR = FieldR<double>;
214using DFieldTheta = FieldTheta<double>;
215using DFieldRTheta = FieldRTheta<double>;
216
217// --- Const Field definitions
218template <class ElementType>
219using ConstFieldR = ConstField<ElementType, IdxRangeR>;
220
221template <class ElementType>
222using ConstFieldTheta = ConstField<ElementType, IdxRangeTheta>;
223
224template <class ElementType>
225using ConstFieldRTheta = ConstField<ElementType, IdxRangeRTheta>;
226
227using DConstFieldR = ConstFieldR<double>;
228using DConstFieldTheta = ConstFieldTheta<double>;
229using DConstFieldRTheta = ConstFieldRTheta<double>;
230
231// --- Spline representation definitions
232using Spline2DMem = DFieldMem<IdxRangeBSRTheta>;
233using Spline2D = DField<IdxRangeBSRTheta>;
234using ConstSpline2D = DConstField<IdxRangeBSRTheta>;
235
242
246using IdxPolarBspl = Idx<PolarBSplinesRTheta>;
247
248
249// --- VectorFieldMem definitions
250template <class Dim1, class Dim2>
252
253template <class Dim1, class Dim2>
255
256template <class Dim1, class Dim2>
258
259
260
261template <class Dim1, class Dim2>
263
264template <class Dim1, class Dim2>
266
267template <class Dim1, class Dim2>
269
270
271
272// CARTESIAN SPACE AND VELOCITY ------------------------------------------------------------------
273// --- Continuous dimensions
277struct X
278{
283 static bool constexpr PERIODIC = false;
284};
288struct Y
289{
294 static bool constexpr PERIODIC = false;
295};
296
300struct Vx
301{
306 static bool constexpr PERIODIC = false;
307};
311struct Vy
312{
317 static bool constexpr PERIODIC = false;
318};
319
320
321using CoordX = Coord<X>;
322using CoordY = Coord<Y>;
323using CoordXY = Coord<X, Y>;
324
325using CoordVx = Coord<Vx>;
326using 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 bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:36
Define periodic real Theta dimension.
Definition geometry.hpp:42
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:47
Define non periodic real R velocity dimension.
Definition geometry.hpp:54
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:59
Define periodic real Theta velocity dimension.
Definition geometry.hpp:65
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:70
Define non periodic real X velocity dimension.
Definition geometry.hpp:301
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:306
Define non periodic real Y velocity dimension.
Definition geometry.hpp:312
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:317
Define non periodic real X dimension.
Definition geometry.hpp:278
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:283
Define non periodic real Y dimension.
Definition geometry.hpp:289
static bool constexpr PERIODIC
Define periodicity of the dimension.
Definition geometry.hpp:294