Gyselalib++
geometry.hpp
1 // SPDX-License-Identifier: MIT
2 
3 #pragma once
4 #include <ddc/ddc.hpp>
5 #include <ddc/kernels/splines.hpp>
6 
7 #include "ddc_alias_inline_functions.hpp"
8 #include "ddc_aliases.hpp"
9 #include "ddc_helper.hpp"
10 #include "directional_tag.hpp"
11 #include "vector_field.hpp"
12 #include "vector_field_mem.hpp"
13 
14 
15 
19 struct X
20 {
24  static bool constexpr PERIODIC = true;
25 };
26 
30 struct Y
31 {
35  static bool constexpr PERIODIC = true;
36 };
37 
38 
39 using CoordX = Coord<X>;
40 using CoordY = Coord<Y>;
41 using CoordXY = Coord<X, Y>;
42 
43 int constexpr BSDegreeX = 3;
44 int constexpr BSDegreeY = 3;
45 
46 bool constexpr BsplineOnUniformCellsX = true;
47 bool constexpr BsplineOnUniformCellsY = true;
48 
49 struct BSplinesX
50  : std::conditional_t<
51  BsplineOnUniformCellsX,
52  ddc::UniformBSplines<X, BSDegreeX>,
53  ddc::NonUniformBSplines<X, BSDegreeX>>
54 {
55 };
56 struct BSplinesY
57  : std::conditional_t<
58  BsplineOnUniformCellsY,
59  ddc::UniformBSplines<Y, BSDegreeY>,
60  ddc::NonUniformBSplines<Y, BSDegreeY>>
61 {
62 };
63 
64 ddc::BoundCond constexpr SplineXBoundary = ddc::BoundCond::PERIODIC;
65 ddc::BoundCond constexpr SplineYBoundary = ddc::BoundCond::PERIODIC;
66 
67 // IDim initialisers
68 using SplineInterpPointsX
69  = ddc::GrevilleInterpolationPoints<BSplinesX, SplineXBoundary, SplineXBoundary>;
70 using SplineInterpPointsY
71  = ddc::GrevilleInterpolationPoints<BSplinesY, SplineYBoundary, SplineYBoundary>;
72 
73 // IDim definitions
74 struct GridX : SplineInterpPointsX::interpolation_discrete_dimension_type
75 {
76 };
77 struct GridY : SplineInterpPointsY::interpolation_discrete_dimension_type
78 {
79 };
80 
81 
82 // SplineBuilder and SplineEvaluator definitions
83 using SplineXBuilder_XY = ddc::SplineBuilder<
84  Kokkos::DefaultExecutionSpace,
85  Kokkos::DefaultExecutionSpace::memory_space,
86  BSplinesX,
87  GridX,
88  SplineXBoundary,
89  SplineXBoundary,
90  ddc::SplineSolver::LAPACK,
91  GridX,
92  GridY>;
93 using SplineXEvaluator_XY = ddc::SplineEvaluator<
94  Kokkos::DefaultExecutionSpace,
95  Kokkos::DefaultExecutionSpace::memory_space,
96  BSplinesX,
97  GridX,
98  ddc::PeriodicExtrapolationRule<X>,
99  ddc::PeriodicExtrapolationRule<X>,
100  GridX,
101  GridY>;
102 
103 
104 using SplineYBuilder_XY = ddc::SplineBuilder<
105  Kokkos::DefaultExecutionSpace,
106  Kokkos::DefaultExecutionSpace::memory_space,
107  BSplinesY,
108  GridY,
109  SplineYBoundary,
110  SplineYBoundary,
111  ddc::SplineSolver::LAPACK,
112  GridX,
113  GridY>;
114 using SplineYEvaluator_XY = ddc::SplineEvaluator<
115  Kokkos::DefaultExecutionSpace,
116  Kokkos::DefaultExecutionSpace::memory_space,
117  BSplinesY,
118  GridY,
119  ddc::PeriodicExtrapolationRule<Y>,
120  ddc::PeriodicExtrapolationRule<Y>,
121  GridX,
122  GridY>;
123 
124 // Spline index range
125 using IdxRangeBSX = IdxRange<BSplinesX>;
126 using IdxRangeBSY = IdxRange<BSplinesY>;
127 using IdxRangeBSXY = IdxRange<BSplinesX, BSplinesY>;
128 
129 template <class ElementType>
130 using BSConstFieldXY = Field<ElementType const, IdxRangeBSXY>;
131 using DBSConstFieldXY = BSConstFieldXY<double>;
132 
133 // Index definitions
134 using IdxX = Idx<GridX>;
135 using IdxY = Idx<GridY>;
136 using IdxXY = Idx<GridX, GridY>;
137 
138 // Index Step definitions
139 using IdxStepX = IdxStep<GridX>;
140 using IdxStepY = IdxStep<GridY>;
141 
142 // Index Range definitions
143 using IdxRangeX = IdxRange<GridX>;
144 using IdxRangeY = IdxRange<GridY>;
145 using IdxRangeXY = IdxRange<GridX, GridY>;
146 
147 
148 // Field definitions
149 template <class ElementType>
150 using FieldMemX = FieldMem<ElementType, IdxRangeX>;
151 using DFieldMemX = FieldMemX<double>;
152 
153 template <class ElementType>
154 using FieldMemY = FieldMem<ElementType, IdxRangeY>;
155 using DFieldMemY = FieldMemY<double>;
156 
157 template <class ElementType>
158 using FieldMemXY = FieldMem<ElementType, IdxRangeXY>;
159 using DFieldMemXY = FieldMemXY<double>;
160 
161 
162 // Field definitions
163 template <class ElementType>
164 using FieldX = Field<ElementType, IdxRangeX>;
165 using DFieldX = FieldX<double>;
166 
167 template <class ElementType>
168 using FieldY = Field<ElementType, IdxRangeY>;
169 using DFieldY = FieldY<double>;
170 
171 template <class ElementType>
172 using FieldXY = Field<ElementType, IdxRangeXY>;
173 using DFieldXY = FieldXY<double>;
174 
175 
176 // ConstField definitions
177 template <class ElementType>
178 using ConstFieldX = Field<ElementType const, IdxRangeX>;
179 
180 template <class ElementType>
181 using ConstFieldY = Field<ElementType const, IdxRangeY>;
182 
183 template <class ElementType>
184 using ConstFieldXY = Field<ElementType const, IdxRangeXY>;
185 using DConstFieldXY = ConstFieldXY<double>;
186 
187 
188 // VectorFieldMem aliases
189 // Represent a vector field (v_x, v_y) on indices (x_i, y_j) : (v_x(x_i, y_j), v_y(x_i,y_j))
191  double,
192  IdxRangeXY,
193  NDTag<X, Y>,
194  Kokkos::DefaultExecutionSpace::memory_space>;
195 using VectorFieldXY_XY = typename VectorFieldMemXY_XY::span_type;
196 using VectorConstFieldXY_XY = typename VectorFieldMemXY_XY::view_type;
Pre-declaration of VectorFieldMem.
Definition: vector_field_mem.hpp:54
VectorField< const ElementType, IdxRangeType, NDTag, MemSpace, std::experimental::layout_right > view_type
A type which can hold a constant reference to this VectorFieldMem.
Definition: vector_field_mem.hpp:103
VectorField< ElementType, IdxRangeType, NDTag, MemSpace, std::experimental::layout_right > span_type
A type which can hold a reference to this VectorFieldMem.
Definition: vector_field_mem.hpp:91
Definition: geometry.hpp:76
Definition: geometry.hpp:61
Definition: geometry.hpp:102
Definition: geometry.hpp:78
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