Gyselalib++
 
Loading...
Searching...
No Matches
polar_spline.hpp
1#pragma once
2
3#include <ddc/ddc.hpp>
4
5template <class PolarBSplinesType, class MemSpace = Kokkos::DefaultExecutionSpace::memory_space>
6struct PolarSplineSpan;
7
8template <class PolarBSplinesType, class MemSpace = Kokkos::DefaultExecutionSpace::memory_space>
9struct PolarSplineView;
10
11
18template <class PolarBSplinesType, class MemSpace = Kokkos::DefaultExecutionSpace::memory_space>
20{
21public:
23 using BSplinesR = typename PolarBSplinesType::BSplinesR_tag;
25 using BSplinesTheta = typename PolarBSplinesType::BSplinesTheta_tag;
26
27public:
32 ddc::Chunk<
33 double,
34 ddc::DiscreteDomain<BSplinesR, BSplinesTheta>,
35 ddc::KokkosAllocator<double, MemSpace>>
37
42 ddc::Chunk<
43 double,
44 ddc::DiscreteDomain<PolarBSplinesType>,
45 ddc::KokkosAllocator<double, MemSpace>>
47
48public:
58 PolarSpline<PolarBSplinesType, MemSpace>(ddc::DiscreteDomain<BSplinesR, BSplinesTheta> domain)
59 : spline_coef(ddc::DiscreteDomain<BSplinesR, BSplinesTheta>(
60 ddc::select<BSplinesR>(domain).remove_first(
61 ddc::DiscreteVector<BSplinesR>(PolarBSplinesType::continuity + 1)),
62 ddc::select<BSplinesTheta>(domain)))
63 , singular_spline_coef(ddc::DiscreteDomain<PolarBSplinesType>(
64 ddc::DiscreteElement<PolarBSplinesType>(0),
65 ddc::DiscreteVector<PolarBSplinesType>(PolarBSplinesType::n_singular_basis())))
66 {
67 }
68
79 ddc::DiscreteDomain<PolarBSplinesType> singular_domain,
80 ddc::DiscreteDomain<BSplinesR, BSplinesTheta> domain)
81 : spline_coef(domain)
82 , singular_spline_coef(singular_domain.take_first(
83 ddc::DiscreteVector<PolarBSplinesType>(PolarBSplinesType::n_singular_basis())))
84 {
85 }
86
96
106};
107
114template <class PolarBSplinesType, class MemSpace>
116{
117public:
119 using BSplinesR = typename PolarBSplinesType::BSplinesR_tag;
121 using BSplinesTheta = typename PolarBSplinesType::BSplinesTheta_tag;
122
123public:
128 ddc::ChunkSpan<
129 double,
130 ddc::DiscreteDomain<BSplinesR, BSplinesTheta>,
131 Kokkos::layout_right,
132 MemSpace>
134
139 ddc::ChunkSpan<double, ddc::DiscreteDomain<PolarBSplinesType>, Kokkos::layout_right, MemSpace>
153
163
173};
174
181template <class PolarBSplinesType, class MemSpace>
183{
184public:
186 using BSplinesR = typename PolarBSplinesType::BSplinesR_tag;
188 using BSplinesTheta = typename PolarBSplinesType::BSplinesTheta_tag;
189
190public:
195 ddc::ChunkSpan<
196 double const,
197 ddc::DiscreteDomain<BSplinesR, BSplinesTheta>,
198 Kokkos::layout_right,
199 MemSpace> const spline_coef;
200
205 ddc::ChunkSpan<
206 double const,
207 ddc::DiscreteDomain<PolarBSplinesType>,
208 Kokkos::layout_right,
223
233 {
234 }
235
242 {
243 return *this;
244 }
245
252 {
253 return *this;
254 }
255};
256
257template <class T>
258inline constexpr bool is_polar_spline_v = false;
259
260template <class PolarBSplinesType, class MemSpace>
261inline constexpr bool is_polar_spline_v<PolarSpline<PolarBSplinesType, MemSpace>> = true;
262
263template <class PolarBSplinesType, class MemSpace>
264inline constexpr bool is_polar_spline_v<PolarSplineSpan<PolarBSplinesType, MemSpace>> = true;
265
266template <class PolarBSplinesType, class MemSpace>
267inline constexpr bool is_polar_spline_v<PolarSplineView<PolarBSplinesType, MemSpace>> = true;
268
276template <class ExecSpace, class PolarBSplinesType, class MemSpace>
278 ExecSpace const& exec_space,
280{
282 dst(src.singular_spline_coef.domain(), src.spline_coef.domain());
283 return dst;
284}
285
291template <class PolarBSplinesType, class MemSpace>
294{
295 return create_mirror(Kokkos::DefaultHostExecutionSpace(), src);
296}
297
305template <class ExecSpace, class PolarBSplinesType, class MemSpace>
307 ExecSpace const& exec_space,
309{
311 = create_mirror(exec_space, src);
312 ddc::parallel_deepcopy(dst.spline_coef, src.spline_coef);
313 ddc::parallel_deepcopy(dst.singular_spline_coef, src.singular_spline_coef);
314 return dst;
315}
316
323template <class PolarBSplinesType, class MemSpace>
326{
327 return create_mirror_and_copy(Kokkos::DefaultHostExecutionSpace(), src);
328}
329
336template <class ExecSpace, class PolarBSplinesType, class MemSpace>
337auto create_mirror_view(
338 ExecSpace const& exec_space,
340{
341 if constexpr (std::is_same_v<MemSpace, typename ExecSpace::memory_space>) {
342 return src;
343 } else {
345 dst(src.singular_spline_coef.domain(), src.spline_coef.domain());
346 return dst;
347 }
348}
349
355template <class PolarBSplinesType, class MemSpace>
356auto create_mirror_view(PolarSplineSpan<PolarBSplinesType, MemSpace> const& src)
357{
358 return create_mirror_view(Kokkos::DefaultHostExecutionSpace(), src);
359}
360
369template <class ExecSpace, class PolarBSplinesType, class MemSpace>
370auto create_mirror_view_and_copy(
371 ExecSpace const& exec_space,
373{
374 auto dst = create_mirror_view(exec_space, src);
375 ddc::parallel_deepcopy(dst.spline_coef, src.spline_coef);
376 ddc::parallel_deepcopy(dst.singular_spline_coef, src.singular_spline_coef);
377 return dst;
378}
379
386template <class PolarBSplinesType, class MemSpace>
387auto create_mirror_view_and_copy(PolarSplineSpan<PolarBSplinesType, MemSpace> const& src)
388{
389 return create_mirror_view_and_copy(Kokkos::DefaultHostExecutionSpace(), src);
390}
Definition geometry.hpp:93
Definition geometry.hpp:100
A structure containing the two ChunkSpans necessary to define a reference to a spline on a set of pol...
Definition polar_spline.hpp:116
ddc::ChunkSpan< double, ddc::DiscreteDomain< BSplinesR, BSplinesTheta >, Kokkos::layout_right, MemSpace > spline_coef
A ChunkSpan containing the coefficients in front of the b-spline elements which can be expressed as a...
Definition polar_spline.hpp:133
PolarSplineSpan< PolarBSplinesType, MemSpace > span_view()
Get a modifiable reference to the polar spline referenced by this polar spline view.
Definition polar_spline.hpp:159
PolarSplineView< PolarBSplinesType, MemSpace > span_cview() const
Get a constant reference to the polar spline referenced by this polar spline view.
Definition polar_spline.hpp:169
ddc::ChunkSpan< double, ddc::DiscreteDomain< PolarBSplinesType >, Kokkos::layout_right, MemSpace > singular_spline_coef
A ChunkSpan containing the coefficients in front of the b-spline elements near the singular point whi...
Definition polar_spline.hpp:140
A structure containing the two ChunkViews necessary to define a constant reference to a spline on a s...
Definition polar_spline.hpp:183
PolarSplineView< PolarBSplinesType, MemSpace > span_cview() const
Get a constant reference to the polar spline referenced by this polar spline view.
Definition polar_spline.hpp:251
PolarSplineSpan< PolarBSplinesType, MemSpace > span_view() const
Get a reference to the polar spline referenced by this polar spline view.
Definition polar_spline.hpp:241
ddc::ChunkSpan< double const, ddc::DiscreteDomain< PolarBSplinesType >, Kokkos::layout_right, MemSpace > const singular_spline_coef
A ChunkView containing the coefficients in front of the b-spline elements near the singular point whi...
Definition polar_spline.hpp:209
ddc::ChunkSpan< double const, ddc::DiscreteDomain< BSplinesR, BSplinesTheta >, Kokkos::layout_right, MemSpace > const spline_coef
A ChunkView containing the coefficients in front of the b-spline elements which can be expressed as a...
Definition polar_spline.hpp:199
A structure containing the two Chunks necessary to define a spline on a set of polar basis splines.
Definition polar_spline.hpp:20
PolarSplineSpan< PolarBSplinesType, MemSpace > span_view()
Get a modifiable reference to this polar spline.
Definition polar_spline.hpp:92
PolarSplineView< PolarBSplinesType, MemSpace > span_cview() const
Get a constant reference to this polar spline view.
Definition polar_spline.hpp:102
ddc::Chunk< double, ddc::DiscreteDomain< PolarBSplinesType >, ddc::KokkosAllocator< double, MemSpace > > singular_spline_coef
A Chunk containing the coefficients in front of the b-spline elements near the singular point which c...
Definition polar_spline.hpp:46
ddc::Chunk< double, ddc::DiscreteDomain< BSplinesR, BSplinesTheta >, ddc::KokkosAllocator< double, MemSpace > > spline_coef
A Chunk containing the coefficients in front of the b-spline elements which can be expressed as a ten...
Definition polar_spline.hpp:36