DDC 0.6.0
Loading...
Searching...
No Matches
bsplines_uniform.hpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <array>
8#include <cassert>
9#include <memory>
10#include <tuple>
11
12#include <ddc/ddc.hpp>
13
14#include "math_tools.hpp"
15#include "view.hpp"
16
17namespace ddc {
18
19namespace detail {
20
21struct UniformBSplinesBase
22{
23};
24
25template <class ExecSpace, class ODDim, class Layout, class OMemorySpace>
26void uniform_bsplines_integrals(
27 ExecSpace const& execution_space,
28 ddc::ChunkSpan<double, ddc::DiscreteDomain<ODDim>, Layout, OMemorySpace> int_vals);
29
30} // namespace detail
31
32template <class T>
34{
35};
36
37/**
38 * The type of a uniform 1D spline basis (B-spline).
39 *
40 * Knots for uniform B-splines are uniformly distributed (the associated discrete dimension
41 * is a UniformPointSampling).
42 *
43 * @tparam CDim The tag identifying the continuous dimension on which the support of the B-spline functions are defined.
44 * @tparam D The degree of the B-splines.
45 */
46template <class CDim, std::size_t D>
47class UniformBSplines : detail::UniformBSplinesBase
48{
49 static_assert(D > 0, "Parameter `D` must be positive");
50
51public:
52 /// @brief The tag identifying the continuous dimension on which the support of the B-splines are defined.
53 using continuous_dimension_type = CDim;
54
55 /// @brief The discrete dimension representing B-splines.
56 using discrete_dimension_type = UniformBSplines;
57
58 /** @brief The degree of B-splines.
59 *
60 * @return The degree.
61 */
62 static constexpr std::size_t degree() noexcept
63 {
64 return D;
65 }
66
67 /** @brief Indicates if the B-splines are periodic or not.
68 *
69 * @return A boolean indicating if the B-splines are periodic or not.
70 */
71 static constexpr bool is_periodic() noexcept
72 {
73 return CDim::PERIODIC;
74 }
75
76 /** @brief Indicates if the B-splines are uniform or not (this is the case here).
77 *
78 * @return A boolean indicating if the B-splines are uniform or not.
79 */
80 static constexpr bool is_uniform() noexcept
81 {
82 return true;
83 }
84
85 /** @brief Storage class of the static attributes of the discrete dimension.
86 *
87 * @tparam DDim The name of the discrete dimension.
88 * @tparam MemorySpace The Kokkos memory space where the attributes are being stored.
89 */
90 template <class DDim, class MemorySpace>
91 class Impl
92 {
93 template <class ODDim, class OMemorySpace>
94 friend class Impl;
95
96 template <class ExecSpace, class ODDim, class Layout, class OMemorySpace>
97 friend void detail::uniform_bsplines_integrals(
98 ExecSpace const& execution_space,
99 ddc::ChunkSpan<double, ddc::DiscreteDomain<ODDim>, Layout, OMemorySpace> int_vals);
100
101 public:
102 /// @brief The type of the knots defining the B-splines.
103 using knot_discrete_dimension_type = UniformBsplinesKnots<DDim>;
104
105 /// @brief The type of the discrete dimension representing the B-splines.
106 using discrete_dimension_type = UniformBSplines;
107
108 /// @brief The type of a DiscreteDomain whose elements identify the B-splines.
109 using discrete_domain_type = DiscreteDomain<DDim>;
110
111 /// @brief The type of a DiscreteElement identifying a B-spline.
112 using discrete_element_type = DiscreteElement<DDim>;
113
114 /// @brief The type of a DiscreteVector representing an "index displacement" between two B-splines.
115 using discrete_vector_type = DiscreteVector<DDim>;
116
117 private:
118 // In the periodic case, they contain the periodic point twice!!!
119 ddc::DiscreteDomain<knot_discrete_dimension_type> m_knot_domain;
120 ddc::DiscreteDomain<knot_discrete_dimension_type> m_break_point_domain;
121
122 ddc::DiscreteElement<DDim> m_reference;
123
124 public:
125 Impl() = default;
126
127 /** Constructs a spline basis (B-splines) with n equidistant knots over \f$[a, b]\f$.
128 *
129 * @param rmin The real ddc::coordinate of the first knot.
130 * @param rmax The real ddc::coordinate of the last knot.
131 * @param ncells The number of cells in the range [rmin, rmax].
132 */
133 explicit Impl(ddc::Coordinate<CDim> rmin, ddc::Coordinate<CDim> rmax, std::size_t ncells)
134 : m_reference(ddc::create_reference_discrete_element<DDim>())
135 {
136 assert(ncells > 0);
137 std::tie(m_break_point_domain, m_knot_domain, std::ignore, std::ignore)
138 = ddc::init_discrete_space<knot_discrete_dimension_type>(
139 knot_discrete_dimension_type::template init_ghosted<
140 knot_discrete_dimension_type>(
141 rmin,
142 rmax,
143 ddc::DiscreteVector<knot_discrete_dimension_type>(ncells + 1),
144 ddc::DiscreteVector<knot_discrete_dimension_type>(degree()),
145 ddc::DiscreteVector<knot_discrete_dimension_type>(degree())));
146 }
147
148 /** @brief Copy-constructs from another Impl with a different Kokkos memory space.
149 *
150 * @param impl A reference to the other Impl.
151 */
152 template <class OriginMemorySpace>
153 explicit Impl(Impl<DDim, OriginMemorySpace> const& impl)
154 : m_knot_domain(impl.m_knot_domain)
155 , m_break_point_domain(impl.m_break_point_domain)
156 , m_reference(impl.m_reference)
157 {
158 }
159
160 /** @brief Copy-constructs.
161 *
162 * @param x A reference to another Impl.
163 */
164 Impl(Impl const& x) = default;
165
166 /** @brief Move-constructs.
167 *
168 * @param x An rvalue to another Impl.
169 */
170 Impl(Impl&& x) = default;
171
172 /// @brief Destructs.
173 ~Impl() = default;
174
175 /** @brief Copy-assigns.
176 *
177 * @param x A reference to another Impl.
178 * @return A reference to the copied Impl.
179 */
180 Impl& operator=(Impl const& x) = default;
181
182 /** @brief Move-assigns.
183 *
184 * @param x An rvalue to another Impl.
185 * @return A reference to this object.
186 */
187 Impl& operator=(Impl&& x) = default;
188
189 /** @brief Evaluates non-zero B-splines at a given coordinate.
190 *
191 * The values are computed for every B-spline with support at the given coordinate x. There are only (degree+1)
192 * B-splines which are non-zero at any given point. It is these B-splines which are evaluated.
193 * This can be useful to calculate a spline approximation of a function. A spline approximation at coordinate x
194 * is a linear combination of these B-spline evaluations weighted with the spline coefficients of the spline-transformed
195 * initial discrete function.
196 *
197 * @param[out] values The values of the B-splines evaluated at coordinate x. It has to be a 1D mdspan with (degree+1) elements.
198 * @param[in] x The coordinate where B-splines are evaluated. It has to be in the range of break points coordinates.
199 * @return The index of the first B-spline which is evaluated.
200 */
201 KOKKOS_INLINE_FUNCTION discrete_element_type
202 eval_basis(DSpan1D values, ddc::Coordinate<CDim> const& x) const
203 {
204 assert(values.size() == degree() + 1);
205 return eval_basis(values, x, degree());
206 }
207
208 /** @brief Evaluates non-zero B-spline derivatives at a given coordinate
209 *
210 * The derivatives are computed for every B-spline with support at the given coordinate x. There are only (degree+1)
211 * B-splines which are non-zero at any given point. It is these B-splines which are differentiated.
212 * A spline approximation of a derivative at coordinate x is a linear
213 * combination of those B-spline derivatives weighted with the spline coefficients of the spline-transformed
214 * initial discrete function.
215 *
216 * @param[out] derivs The derivatives of the B-splines evaluated at coordinate x. It has to be a 1D mdspan with (degree+1) elements.
217 * @param[in] x The coordinate where B-spline derivatives are evaluated. It has to be in the range of break points coordinates.
218 * @return The index of the first B-spline which is evaluated.
219 */
220 KOKKOS_INLINE_FUNCTION discrete_element_type
221 eval_deriv(DSpan1D derivs, ddc::Coordinate<CDim> const& x) const;
222
223 /** @brief Evaluates non-zero B-spline values and \f$n\f$ derivatives at a given coordinate
224 *
225 * The values and derivatives are computed for every B-spline with support at the given coordinate x. There are only (degree+1)
226 * B-splines which are non-zero at any given point. It is these B-splines which are evaluated and differentiated.
227 * A spline approximation of a derivative at coordinate x is a linear
228 * combination of those B-spline derivatives weighted with spline coefficients of the spline-transformed
229 * initial discrete function.
230 *
231 * @param[out] derivs The values and \f$n\f$ derivatives of the B-splines evaluated at coordinate x. It has to be a 2D mdspan of sizes (degree+1, n+1).
232 * @param[in] x The coordinate where B-spline derivatives are evaluated. It has to be in the range of break points coordinates.
233 * @param[in] n The number of derivatives to evaluate (in addition to the B-spline values themselves).
234 * @return The index of the first B-spline which is evaluated.
235 */
237 ddc::DSpan2D derivs,
238 ddc::Coordinate<CDim> const& x,
239 std::size_t n) const;
240
241 /** @brief Returns the coordinate of the first support knot associated to a DiscreteElement identifying a B-spline.
242 *
243 * Each B-spline has a support defined over (degree+2) knots. For a B-spline identified by the
244 * provided DiscreteElement, this function returns the first knot in the support of the B-spline.
245 * In other words it returns the lower bound of the support.
246 *
247 * @param[in] ix DiscreteElement identifying the B-spline.
248 * @return DiscreteElement of the lower bound of the support of the B-spline.
249 */
250 KOKKOS_INLINE_FUNCTION ddc::DiscreteElement<knot_discrete_dimension_type>
251 get_first_support_knot(discrete_element_type const& ix) const
252 {
253 return m_knot_domain.front() + (ix - m_reference).value();
254 }
255
256 /** @brief Returns the coordinate of the last support knot associated to a DiscreteElement identifying a B-spline.
257 *
258 * Each B-spline has a support defined over (degree+2) knots. For a B-spline identified by the
259 * provided DiscreteElement, this function returns the last knot in the support of the B-spline.
260 * In other words it returns the upper bound of the support.
261 *
262 * @param[in] ix DiscreteElement identifying the B-spline.
263 * @return DiscreteElement of the upper bound of the support of the B-spline.
264 */
265 KOKKOS_INLINE_FUNCTION ddc::DiscreteElement<knot_discrete_dimension_type>
266 get_last_support_knot(discrete_element_type const& ix) const
267 {
269 + ddc::DiscreteVector<knot_discrete_dimension_type>(degree() + 1);
270 }
271
272 /** @brief Returns the coordinate of the lower bound of the domain on which the B-splines are defined.
273 *
274 * @return Coordinate of the lower bound of the domain.
275 */
276 KOKKOS_INLINE_FUNCTION ddc::Coordinate<CDim> rmin() const noexcept
277 {
278 return ddc::coordinate(m_break_point_domain.front());
279 }
280
281 /** @brief Returns the coordinate of the upper bound of the domain on which the B-splines are defined.
282 *
283 * @return Coordinate of the upper bound of the domain.
284 */
285 KOKKOS_INLINE_FUNCTION ddc::Coordinate<CDim> rmax() const noexcept
286 {
287 return ddc::coordinate(m_break_point_domain.back());
288 }
289
290 /** @brief Returns the length of the domain.
291 *
292 * @return The length of the domain.
293 */
294 KOKKOS_INLINE_FUNCTION double length() const noexcept
295 {
296 return rmax() - rmin();
297 }
298
299 /** @brief Returns the number of elements necessary to construct a spline representation of a function.
300 *
301 * For a non-periodic domain the number of elements necessary to construct a spline representation of a function
302 * is equal to the number of basis functions. However in the periodic case it additionally includes degree additional elements
303 * which allow the first B-splines to be evaluated close to rmax (where they also appear due to the periodicity).
304 *
305 * @return The number of elements necessary to construct a spline representation of a function.
306 */
307 KOKKOS_INLINE_FUNCTION std::size_t size() const noexcept
308 {
309 return degree() + ncells();
310 }
311
312 /** @brief Returns the discrete domain including eventual additional B-splines in the periodic case. See size().
313 *
314 * @return The discrete domain including eventual additional B-splines.
315 */
316 KOKKOS_INLINE_FUNCTION discrete_domain_type full_domain() const
317 {
318 return discrete_domain_type(m_reference, discrete_vector_type(size()));
319 }
320
321 /** @brief Returns the discrete domain which describes the break points.
322 *
323 * @return The discrete domain describing the break points.
324 */
325 KOKKOS_INLINE_FUNCTION ddc::DiscreteDomain<knot_discrete_dimension_type>
326 break_point_domain() const
327 {
328 return m_break_point_domain;
329 }
330
331 /** @brief Returns the number of basis functions.
332 *
333 * The number of functions in the spline basis.
334 *
335 * @return The number of basis functions.
336 */
337 KOKKOS_INLINE_FUNCTION std::size_t nbasis() const noexcept
338 {
339 return ncells() + !is_periodic() * degree();
340 }
341
342 /** @brief Returns the number of cells over which the B-splines are defined.
343 *
344 * The number of cells over which the B-splines and any spline representation are defined.
345 * In other words the number of polynomials that comprise a spline representation on the domain where the basis is defined.
346 *
347 * @return The number of cells over which the B-splines are defined.
348 */
349 KOKKOS_INLINE_FUNCTION std::size_t ncells() const noexcept
350 {
351 return m_break_point_domain.size() - 1;
352 }
353
354 private:
355 KOKKOS_INLINE_FUNCTION double inv_step() const noexcept
356 {
357 return 1.0 / ddc::step<knot_discrete_dimension_type>();
358 }
359
360 KOKKOS_INLINE_FUNCTION discrete_element_type
361 eval_basis(DSpan1D values, ddc::Coordinate<CDim> const& x, std::size_t degree) const;
362
363 KOKKOS_INLINE_FUNCTION void get_icell_and_offset(
364 int& icell,
365 double& offset,
366 ddc::Coordinate<CDim> const& x) const;
367 };
368};
369
370template <class DDim>
371struct is_uniform_bsplines : public std::is_base_of<detail::UniformBSplinesBase, DDim>::type
372{
373};
374
375/**
376 * @brief Indicates if a tag corresponds to uniform B-splines or not.
377 *
378 * @tparam The presumed uniform B-splines.
379 */
380template <class DDim>
382
383template <class CDim, std::size_t D>
384template <class DDim, class MemorySpace>
385KOKKOS_INLINE_FUNCTION ddc::DiscreteElement<DDim> UniformBSplines<CDim, D>::
386 Impl<DDim, MemorySpace>::eval_basis(
387 DSpan1D values,
388 ddc::Coordinate<CDim> const& x,
389 [[maybe_unused]] std::size_t const degree) const
390{
391 assert(values.size() == degree + 1);
392
393 double offset;
394 int jmin;
395 // 1. Compute cell index 'icell' and x_offset
396 // 2. Compute index range of B-splines with support over cell 'icell'
397 get_icell_and_offset(jmin, offset, x);
398
399 // 3. Compute values of aforementioned B-splines
400 double xx;
401 double temp;
402 double saved;
403 DDC_MDSPAN_ACCESS_OP(values, 0) = 1.0;
404 for (std::size_t j = 1; j < values.size(); ++j) {
405 xx = -offset;
406 saved = 0.0;
407 for (std::size_t r = 0; r < j; ++r) {
408 xx += 1;
409 temp = DDC_MDSPAN_ACCESS_OP(values, r) / j;
410 DDC_MDSPAN_ACCESS_OP(values, r) = saved + xx * temp;
411 saved = (j - xx) * temp;
412 }
413 DDC_MDSPAN_ACCESS_OP(values, j) = saved;
414 }
415
416 return m_reference + jmin;
417}
418
419template <class CDim, std::size_t D>
420template <class DDim, class MemorySpace>
421KOKKOS_INLINE_FUNCTION ddc::DiscreteElement<DDim> UniformBSplines<CDim, D>::
422 Impl<DDim, MemorySpace>::eval_deriv(DSpan1D derivs, ddc::Coordinate<CDim> const& x) const
423{
424 assert(derivs.size() == degree() + 1);
425
426 double offset;
427 int jmin;
428 // 1. Compute cell index 'icell' and x_offset
429 // 2. Compute index range of B-splines with support over cell 'icell'
430 get_icell_and_offset(jmin, offset, x);
431
432 // 3. Compute derivatives of aforementioned B-splines
433 // Derivatives are normalized, hence they should be divided by dx
434 double xx;
435 double temp;
436 double saved;
437 DDC_MDSPAN_ACCESS_OP(derivs, 0) = 1.0 / ddc::step<knot_discrete_dimension_type>();
438 for (std::size_t j = 1; j < degree(); ++j) {
439 xx = -offset;
440 saved = 0.0;
441 for (std::size_t r = 0; r < j; ++r) {
442 xx += 1.0;
443 temp = DDC_MDSPAN_ACCESS_OP(derivs, r) / j;
444 DDC_MDSPAN_ACCESS_OP(derivs, r) = saved + xx * temp;
445 saved = (j - xx) * temp;
446 }
447 DDC_MDSPAN_ACCESS_OP(derivs, j) = saved;
448 }
449
450 // Compute derivatives
451 double bjm1 = derivs[0];
452 double bj = bjm1;
453 DDC_MDSPAN_ACCESS_OP(derivs, 0) = -bjm1;
454 for (std::size_t j = 1; j < degree(); ++j) {
455 bj = DDC_MDSPAN_ACCESS_OP(derivs, j);
456 DDC_MDSPAN_ACCESS_OP(derivs, j) = bjm1 - bj;
457 bjm1 = bj;
458 }
459 DDC_MDSPAN_ACCESS_OP(derivs, degree()) = bj;
460
461 return m_reference + jmin;
462}
463
464template <class CDim, std::size_t D>
465template <class DDim, class MemorySpace>
466KOKKOS_INLINE_FUNCTION ddc::DiscreteElement<DDim> UniformBSplines<CDim, D>::
467 Impl<DDim, MemorySpace>::eval_basis_and_n_derivs(
468 ddc::DSpan2D const derivs,
469 ddc::Coordinate<CDim> const& x,
470 std::size_t const n) const
471{
472 std::array<double, (degree() + 1) * (degree() + 1)> ndu_ptr;
473 Kokkos::mdspan<double, Kokkos::extents<std::size_t, degree() + 1, degree() + 1>> const ndu(
474 ndu_ptr.data());
475 std::array<double, 2 * (degree() + 1)> a_ptr;
476 Kokkos::mdspan<double, Kokkos::extents<std::size_t, degree() + 1, 2>> const a(a_ptr.data());
477 double offset;
478 int jmin;
479
480 assert(x - rmin() >= -length() * 1e-14);
481 assert(rmax() - x >= -length() * 1e-14);
482 // assert(n >= 0); as long as n is unsigned
483 assert(n <= degree());
484 assert(derivs.extent(0) == 1 + degree());
485 assert(derivs.extent(1) == 1 + n);
486
487 // 1. Compute cell index 'icell' and x_offset
488 // 2. Compute index range of B-splines with support over cell 'icell'
489 get_icell_and_offset(jmin, offset, x);
490
491 // 3. Recursively evaluate B-splines (eval_basis)
492 // up to self%degree, and store them all in the upper-right triangle of
493 // ndu
494 double xx;
495 double temp;
496 double saved;
497 DDC_MDSPAN_ACCESS_OP(ndu, 0, 0) = 1.0;
498 for (std::size_t j = 1; j < degree() + 1; ++j) {
499 xx = -offset;
500 saved = 0.0;
501 for (std::size_t r = 0; r < j; ++r) {
502 xx += 1.0;
503 temp = DDC_MDSPAN_ACCESS_OP(ndu, j - 1, r) / j;
504 DDC_MDSPAN_ACCESS_OP(ndu, j, r) = saved + xx * temp;
505 saved = (j - xx) * temp;
506 }
507 DDC_MDSPAN_ACCESS_OP(ndu, j, j) = saved;
508 }
509 for (std::size_t i = 0; i < ndu.extent(1); ++i) {
510 DDC_MDSPAN_ACCESS_OP(derivs, i, 0) = DDC_MDSPAN_ACCESS_OP(ndu, degree(), i);
511 }
512
513 for (int r = 0; r < int(degree() + 1); ++r) {
514 int s1 = 0;
515 int s2 = 1;
516 DDC_MDSPAN_ACCESS_OP(a, 0, 0) = 1.0;
517 for (int k = 1; k < int(n + 1); ++k) {
518 double d = 0.0;
519 int const rk = r - k;
520 int const pk = degree() - k;
521 if (r >= k) {
522 DDC_MDSPAN_ACCESS_OP(a, 0, s2) = DDC_MDSPAN_ACCESS_OP(a, 0, s1) / (pk + 1);
523 d = DDC_MDSPAN_ACCESS_OP(a, 0, s2) * DDC_MDSPAN_ACCESS_OP(ndu, pk, rk);
524 }
525 int const j1 = rk > -1 ? 1 : (-rk);
526 int const j2 = (r - 1) <= pk ? k : (degree() - r + 1);
527 for (int j = j1; j < j2; ++j) {
528 DDC_MDSPAN_ACCESS_OP(a, j, s2)
529 = (DDC_MDSPAN_ACCESS_OP(a, j, s1) - DDC_MDSPAN_ACCESS_OP(a, j - 1, s1))
530 / (pk + 1);
531 d += DDC_MDSPAN_ACCESS_OP(a, j, s2) * DDC_MDSPAN_ACCESS_OP(ndu, pk, rk + j);
532 }
533 if (r <= pk) {
534 DDC_MDSPAN_ACCESS_OP(a, k, s2) = -DDC_MDSPAN_ACCESS_OP(a, k - 1, s1) / (pk + 1);
535 d += DDC_MDSPAN_ACCESS_OP(a, k, s2) * DDC_MDSPAN_ACCESS_OP(ndu, pk, r);
536 }
537 DDC_MDSPAN_ACCESS_OP(derivs, r, k) = d;
538 Kokkos::kokkos_swap(s1, s2);
539 }
540 }
541
542 // Multiply result by correct factors:
543 // degree!/(degree-n)! = degree*(degree-1)*...*(degree-n+1)
544 // k-th derivatives are normalized, hence they should be divided by dx^k
545 double const inv_dx = inv_step();
546 double d = degree() * inv_dx;
547 for (int k = 1; k < int(n + 1); ++k) {
548 for (std::size_t i = 0; i < derivs.extent(0); ++i) {
549 DDC_MDSPAN_ACCESS_OP(derivs, i, k) *= d;
550 }
551 d *= (degree() - k) * inv_dx;
552 }
553
554 return m_reference + jmin;
555}
556
557template <class CDim, std::size_t D>
558template <class DDim, class MemorySpace>
559KOKKOS_INLINE_FUNCTION void UniformBSplines<CDim, D>::Impl<DDim, MemorySpace>::get_icell_and_offset(
560 int& icell,
561 double& offset,
562 ddc::Coordinate<CDim> const& x) const
563{
564 assert(x - rmin() >= -length() * 1e-14);
565 assert(rmax() - x >= -length() * 1e-14);
566
567 double const inv_dx = inv_step();
568 if (x <= rmin()) {
569 icell = 0;
570 offset = 0.0;
571 } else if (x >= rmax()) {
572 icell = ncells() - 1;
573 offset = 1.0;
574 } else {
575 offset = (x - rmin()) * inv_dx;
576 icell = static_cast<int>(offset);
577 offset = offset - icell;
578
579 // When x is very close to xmax, round-off may cause the wrong answer
580 // icell=ncells and x_offset=0, which we convert to the case x=xmax:
581 if (icell == int(ncells()) && offset == 0.0) {
582 icell = ncells() - 1;
583 offset = 1.0;
584 }
585 }
586}
587
588} // namespace ddc
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
Storage class of the static attributes of the discrete dimension.
KOKKOS_INLINE_FUNCTION ddc::DiscreteElement< knot_discrete_dimension_type > get_last_support_knot(discrete_element_type const &ix) const
Returns the coordinate of the last support knot associated to a DiscreteElement identifying a B-splin...
Impl(ddc::Coordinate< CDim > rmin, ddc::Coordinate< CDim > rmax, std::size_t ncells)
Constructs a spline basis (B-splines) with n equidistant knots over .
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmax() const noexcept
Returns the coordinate of the upper bound of the domain on which the B-splines are defined.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_basis(DSpan1D values, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-splines at a given coordinate.
KOKKOS_INLINE_FUNCTION ddc::DiscreteDomain< knot_discrete_dimension_type > break_point_domain() const
Returns the discrete domain which describes the break points.
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmin() const noexcept
Returns the coordinate of the lower bound of the domain on which the B-splines are defined.
~Impl()=default
Destructs.
KOKKOS_INLINE_FUNCTION std::size_t nbasis() const noexcept
Returns the number of basis functions.
Impl(Impl const &x)=default
Copy-constructs.
KOKKOS_INLINE_FUNCTION std::size_t size() const noexcept
Returns the number of elements necessary to construct a spline representation of a function.
Impl(Impl &&x)=default
Move-constructs.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_basis_and_n_derivs(ddc::DSpan2D derivs, ddc::Coordinate< CDim > const &x, std::size_t n) const
Evaluates non-zero B-spline values and derivatives at a given coordinate.
KOKKOS_INLINE_FUNCTION ddc::DiscreteElement< knot_discrete_dimension_type > get_first_support_knot(discrete_element_type const &ix) const
Returns the coordinate of the first support knot associated to a DiscreteElement identifying a B-spli...
KOKKOS_INLINE_FUNCTION double length() const noexcept
Returns the length of the domain.
Impl(Impl< DDim, OriginMemorySpace > const &impl)
Copy-constructs from another Impl with a different Kokkos memory space.
KOKKOS_INLINE_FUNCTION std::size_t ncells() const noexcept
Returns the number of cells over which the B-splines are defined.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_deriv(DSpan1D derivs, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-spline derivatives at a given coordinate.
Impl & operator=(Impl &&x)=default
Move-assigns.
KOKKOS_INLINE_FUNCTION discrete_domain_type full_domain() const
Returns the discrete domain including eventual additional B-splines in the periodic case.
Impl & operator=(Impl const &x)=default
Copy-assigns.
The type of a uniform 1D spline basis (B-spline).
static constexpr bool is_uniform() noexcept
Indicates if the B-splines are uniform or not (this is the case here).
static constexpr bool is_periodic() noexcept
Indicates if the B-splines are periodic or not.
static constexpr std::size_t degree() noexcept
The degree of B-splines.
UniformPointSampling models a uniform discretization of the provided continuous dimension.
The top-level namespace of DDC.
constexpr bool is_uniform_bsplines_v
Indicates if a tag corresponds to uniform B-splines or not.