Gyselalib++
polar_spline.hpp
1 #pragma once
2 
3 #include <ddc/ddc.hpp>
4 
5 template <class PolarBSplinesType, class MemSpace = Kokkos::DefaultExecutionSpace::memory_space>
6 struct PolarSplineSpan;
7 
8 template <class PolarBSplinesType, class MemSpace = Kokkos::DefaultExecutionSpace::memory_space>
9 struct PolarSplineView;
10 
11 
18 template <class PolarBSplinesType, class MemSpace = Kokkos::DefaultExecutionSpace::memory_space>
20 {
21 public:
23  using BSplinesR = typename PolarBSplinesType::BSplinesR_tag;
25  using BSplinesTheta = typename PolarBSplinesType::BSplinesTheta_tag;
26 
27 public:
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 
48 public:
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 
93  {
95  }
96 
103  {
105  }
106 };
107 
114 template <class PolarBSplinesType, class MemSpace>
116 {
117 public:
119  using BSplinesR = typename PolarBSplinesType::BSplinesR_tag;
121  using BSplinesTheta = typename PolarBSplinesType::BSplinesTheta_tag;
122 
123 public:
128  ddc::ChunkSpan<
129  double,
130  ddc::DiscreteDomain<BSplinesR, BSplinesTheta>,
131  std::experimental::layout_right,
132  MemSpace>
134 
139  ddc::ChunkSpan<
140  double,
141  ddc::DiscreteDomain<PolarBSplinesType>,
142  std::experimental::layout_right,
143  MemSpace>
145 
146 public:
155  {
156  }
157 
164  {
165  return *this;
166  }
167 
174  {
176  }
177 };
178 
185 template <class PolarBSplinesType, class MemSpace>
187 {
188 public:
190  using BSplinesR = typename PolarBSplinesType::BSplinesR_tag;
192  using BSplinesTheta = typename PolarBSplinesType::BSplinesTheta_tag;
193 
194 public:
199  ddc::ChunkSpan<
200  double const,
201  ddc::DiscreteDomain<BSplinesR, BSplinesTheta>,
202  std::experimental::layout_right,
203  MemSpace> const spline_coef;
204 
209  ddc::ChunkSpan<
210  double const,
211  ddc::DiscreteDomain<PolarBSplinesType>,
212  std::experimental::layout_right,
213  MemSpace> const singular_spline_coef;
214 
215 public:
225  {
226  }
227 
237  {
238  }
239 
246  {
247  return *this;
248  }
249 
256  {
257  return *this;
258  }
259 };
260 
261 template <class T>
262 inline constexpr bool is_polar_spline_v = false;
263 
264 template <class PolarBSplinesType, class MemSpace>
265 inline constexpr bool is_polar_spline_v<PolarSpline<PolarBSplinesType, MemSpace>> = true;
266 
267 template <class PolarBSplinesType, class MemSpace>
268 inline constexpr bool is_polar_spline_v<PolarSplineSpan<PolarBSplinesType, MemSpace>> = true;
269 
270 template <class PolarBSplinesType, class MemSpace>
271 inline constexpr bool is_polar_spline_v<PolarSplineView<PolarBSplinesType, MemSpace>> = true;
272 
280 template <class ExecSpace, class PolarBSplinesType, class MemSpace>
282  ExecSpace const& exec_space,
284 {
286  dst(src.singular_spline_coef.domain(), src.spline_coef.domain());
287  return dst;
288 }
289 
295 template <class PolarBSplinesType, class MemSpace>
298 {
299  return create_mirror(Kokkos::DefaultHostExecutionSpace(), src);
300 }
301 
309 template <class ExecSpace, class PolarBSplinesType, class MemSpace>
311  ExecSpace const& exec_space,
313 {
315  = create_mirror(exec_space, src);
316  ddc::parallel_deepcopy(dst.spline_coef, src.spline_coef);
317  ddc::parallel_deepcopy(dst.singular_spline_coef, src.singular_spline_coef);
318  return dst;
319 }
320 
327 template <class PolarBSplinesType, class MemSpace>
330 {
331  return create_mirror_and_copy(Kokkos::DefaultHostExecutionSpace(), src);
332 }
333 
340 template <class ExecSpace, class PolarBSplinesType, class MemSpace>
341 auto create_mirror_view(
342  ExecSpace const& exec_space,
344 {
345  if constexpr (std::is_same_v<MemSpace, typename ExecSpace::memory_space>) {
346  return src;
347  } else {
349  dst(src.singular_spline_coef.domain(), src.spline_coef.domain());
350  return dst;
351  }
352 }
353 
359 template <class PolarBSplinesType, class MemSpace>
360 auto create_mirror_view(PolarSplineSpan<PolarBSplinesType, MemSpace> const& src)
361 {
362  return create_mirror_view(Kokkos::DefaultHostExecutionSpace(), src);
363 }
364 
373 template <class ExecSpace, class PolarBSplinesType, class MemSpace>
374 auto create_mirror_view_and_copy(
375  ExecSpace const& exec_space,
377 {
378  auto dst = create_mirror_view(exec_space, src);
379  ddc::parallel_deepcopy(dst.spline_coef, src.spline_coef);
380  ddc::parallel_deepcopy(dst.singular_spline_coef, src.singular_spline_coef);
381  return dst;
382 }
383 
390 template <class PolarBSplinesType, class MemSpace>
391 auto create_mirror_view_and_copy(PolarSplineSpan<PolarBSplinesType, MemSpace> const& src)
392 {
393  return create_mirror_view_and_copy(Kokkos::DefaultHostExecutionSpace(), src);
394 }
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
PolarSplineView< PolarBSplinesType, MemSpace > span_cview() const
Get a constant reference to the polar spline referenced by this polar spline view.
Definition: polar_spline.hpp:173
PolarSplineSpan< PolarBSplinesType, MemSpace > span_view()
Get a modifiable reference to the polar spline referenced by this polar spline view.
Definition: polar_spline.hpp:163
ddc::ChunkSpan< double, ddc::DiscreteDomain< PolarBSplinesType >, std::experimental::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:144
ddc::ChunkSpan< double, ddc::DiscreteDomain< BSplinesR, BSplinesTheta >, std::experimental::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
A structure containing the two ChunkViews necessary to define a constant reference to a spline on a s...
Definition: polar_spline.hpp:187
ddc::ChunkSpan< double const, ddc::DiscreteDomain< BSplinesR, BSplinesTheta >, std::experimental::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:203
ddc::ChunkSpan< double const, ddc::DiscreteDomain< PolarBSplinesType >, std::experimental::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:213
PolarSplineView< PolarBSplinesType, MemSpace > span_cview() const
Get a constant reference to the polar spline referenced by this polar spline view.
Definition: polar_spline.hpp:255
PolarSplineSpan< PolarBSplinesType, MemSpace > span_view() const
Get a reference to the polar spline referenced by this polar spline view.
Definition: polar_spline.hpp:245
A structure containing the two Chunks necessary to define a spline on a set of polar basis splines.
Definition: polar_spline.hpp:20
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
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< 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