DDC 0.15.1
Loading...
Searching...
No Matches
spline_evaluator_nd.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 <cstddef>
9#include <tuple>
10#include <type_traits>
11#include <utility>
12
13#include <ddc/ddc.hpp>
14
15#include <Kokkos_Core.hpp>
16
17#include "deriv.hpp"
18#include "integrals.hpp"
20
21namespace ddc {
22
23/**
24 * @brief A class to evaluate, differentiate or integrate a spline function of arbitrary dimension.
25 *
26 * A class which contains an operator () which can be used to evaluate, differentiate or integrate a spline function of arbitrary dimension.
27 *
28 * @tparam Args... The template parameters of the evaluator:
29 * - ExecSpace The Kokkos execution space on which the spline evaluation is performed.
30 * - MemorySpace The Kokkos memory space on which the data (spline coefficients and evaluation) is stored.
31 * - BSplines A TypeSeq containing the N discrete dimensions representing the B-splines along the dimensions of interest.
32 * - EvaluationDDim A TypeSeq containing the discrete dimensions on which evaluation points are defined.
33 * - ExtrapolationRule A TypeSeq containing the lower and upper extrapolation rules along each dimension of interest.
34 */
35template <
36 class ExecSpace,
37 class MemorySpace,
38 class BSplines,
39 class EvaluationDDim,
40 class ExtrapolationRule>
41class SplineEvaluatorND;
42
43template <
44 class ExecSpace,
45 class MemorySpace,
46 class... BSplines,
47 class... EvaluationDDim,
48 class... ExtrapolationRule>
49class SplineEvaluatorND<
50 ExecSpace,
51 MemorySpace,
52 detail::TypeSeq<BSplines...>,
53 detail::TypeSeq<EvaluationDDim...>,
54 detail::TypeSeq<ExtrapolationRule...>>
55{
56private:
57 static constexpr std::size_t dimension = sizeof...(BSplines);
58
59 using bsplines_ts = detail::TypeSeq<BSplines...>;
60 // A value that can be used to do a pack expansion over (0, 1, ..., Dimension)
61 template <class BSpline>
62 static constexpr std::size_t s_idx = ddc::type_seq_rank_v<BSpline, bsplines_ts>;
63
64 using evaluation_ddim_ts = detail::TypeSeq<EvaluationDDim...>;
65 using lower_extrap_rule_ts = detail::TypeSeq<
66 ddc::type_seq_element_t<2 * s_idx<BSplines>, detail::TypeSeq<ExtrapolationRule...>>...>;
67 using upper_extrap_rule_ts = detail::TypeSeq<ddc::type_seq_element_t<
68 2 * s_idx<BSplines> + 1,
69 detail::TypeSeq<ExtrapolationRule...>>...>;
70
71public:
72 /// @brief The type of the Ith evaluation continuous dimension used by this class.
73 /// @tparam I the requested dimension
74 template <std::size_t I>
75 using continuous_dimension_type
76 = ddc::type_seq_element_t<I, bsplines_ts>::continuous_dimension_type;
77
78 /// @brief The type of the Kokkos execution space used by this class.
79 using exec_space = ExecSpace;
80
81 /// @brief The type of the Kokkos memory space used by this class.
82 using memory_space = MemorySpace;
83
84 /// @brief The type of the Ith discrete dimension of interest used by this class.
85 template <std::size_t I>
86 using evaluation_discrete_dimension_type = ddc::type_seq_element_t<I, evaluation_ddim_ts>;
87
88 /// @brief The discrete dimension representing the B-splines along Ith dimension.
89 template <std::size_t I>
90 using bsplines_type = ddc::type_seq_element_t<I, bsplines_ts>;
91
92 /**
93 * @brief The type of the domain for the 1D, 2D, ... or ND evaluation mesh along specified dimensions used by this class.
94 *
95 * @tparam Dims the required dimensions, 0 indexed
96 */
97 template <std::size_t... Dims>
98 using evaluation_domain_type = ddc::DiscreteDomain<evaluation_discrete_dimension_type<Dims>...>;
99
100 /**
101 * @brief The type of the whole domain representing evaluation points.
102 *
103 * @tparam The batched discrete domain on which the interpolation points are defined.
104 */
105 template <concepts::discrete_domain BatchedInterpolationDDom>
106 using batched_evaluation_domain_type = BatchedInterpolationDDom;
107
108 /**
109 * @brief The type of the 1D, 2D, ... or ND spline domain corresponding to the specified dimensions of interest.
110 *
111 * @tparam Dims the required dimensions, 0 indexed
112 */
113 template <std::size_t... Dims>
114 using spline_domain_type = ddc::DiscreteDomain<bsplines_type<Dims>...>;
115
116 /**
117 * @brief The type of the batch domain (obtained by removing the dimensions of interest
118 * from the whole domain).
119 *
120 * @tparam The batched discrete domain on which the interpolation points are defined.
121 */
122 template <concepts::discrete_domain BatchedInterpolationDDom>
123 using batch_domain_type
124 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_remove_t<
125 ddc::to_type_seq_t<BatchedInterpolationDDom>,
126 evaluation_ddim_ts>>;
127
128 /**
129 * @brief The type of the whole spline domain (cartesian product of ND spline domain
130 * and batch domain) preserving the underlying memory layout (order of dimensions).
131 *
132 * @tparam The batched discrete domain on which the interpolation points are defined.
133 */
134 template <concepts::discrete_domain BatchedInterpolationDDom>
135 using batched_spline_domain_type
136 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
137 ddc::to_type_seq_t<BatchedInterpolationDDom>,
138 evaluation_ddim_ts,
139 bsplines_ts>>;
140
141 /// @brief The type of the extrapolation rule at the lower boundary along the Ith dimension.
142 template <std::size_t I>
143 using lower_extrapolation_rule_type = ddc::type_seq_element_t<I, lower_extrap_rule_ts>;
144
145 /// @brief The type of the extrapolation rule at the upper boundary along the Ith dimension.
146 template <std::size_t I>
147 using upper_extrapolation_rule_type = ddc::type_seq_element_t<I, upper_extrap_rule_ts>;
148
149private:
150 cexa::tuple<ddc::type_seq_element_t<s_idx<BSplines>, lower_extrap_rule_ts>...>
151 m_lower_extrap_rules;
152 cexa::tuple<ddc::type_seq_element_t<s_idx<BSplines>, upper_extrap_rule_ts>...>
153 m_upper_extrap_rules;
154
155 /**
156 * @brief Build a SplineEvaluatorND acting on batched_spline_domain.
157 *
158 * @param extrap_rules The extrapolation rules at the lower then upper boundary, for each dimension.
159 */
160 explicit SplineEvaluatorND(cexa::tuple<ExtrapolationRule...> const& extrap_rules)
161 : m_lower_extrap_rules(cexa::get<2 * s_idx<BSplines>>(extrap_rules)...)
162 , m_upper_extrap_rules(cexa::get<2 * s_idx<BSplines> + 1>(extrap_rules)...)
163 {
164 }
165
166public:
167 static_assert(
168 sizeof...(BSplines) == dimension,
169 "Number of BSpline dims should be equal to the dimension");
170 static_assert(
171 sizeof...(EvaluationDDim) == dimension,
172 "Number of evaluation dims should be equal to the dimensions");
173 static_assert(
174 ddc::type_seq_size_v<lower_extrap_rule_ts> == dimension,
175 "Number of lower extrapolation rules should be equal to the dimension");
176 static_assert(
177 ddc::type_seq_size_v<upper_extrap_rule_ts> == dimension,
178 "Number of upper extrapolation rules should be equal to the dimension");
179
180 static_assert(
181 ((std::is_same_v<
182 ddc::type_seq_element_t<s_idx<BSplines>, lower_extrap_rule_ts>,
183 ddc::PeriodicExtrapolationRule<typename BSplines::continuous_dimension_type>>
184 == BSplines::is_periodic()
185 && std::is_same_v<
186 ddc::type_seq_element_t<s_idx<BSplines>, upper_extrap_rule_ts>,
188 typename BSplines::continuous_dimension_type>>
189 == BSplines::is_periodic())
190 && ...),
191 "PeriodicExtrapolationRule has to be used if and only if dimension is periodic");
192 static_assert(
193 (std::is_invocable_r_v<
194 double,
195 ddc::type_seq_element_t<s_idx<BSplines>, lower_extrap_rule_ts>,
196 ddc::Coordinate<typename BSplines::continuous_dimension_type...>,
197 ddc::ChunkSpan<
198 double const,
199 ddc::DiscreteDomain<BSplines...>,
200 Kokkos::layout_right,
201 memory_space>>
202 && ...),
203 "LowerExtrapolationRule::operator() has to be callable "
204 "with usual arguments.");
205 static_assert(
206 (std::is_invocable_r_v<
207 double,
208 ddc::type_seq_element_t<s_idx<BSplines>, upper_extrap_rule_ts>,
209 ddc::Coordinate<typename BSplines::continuous_dimension_type...>,
210 ddc::ChunkSpan<
211 double const,
212 ddc::DiscreteDomain<BSplines...>,
213 Kokkos::layout_right,
214 memory_space>>
215 && ...),
216 "UpperExtrapolationRule::operator() has to be callable "
217 "with usual arguments.");
218
219 /**
220 * @brief Build a SplineEvaluatorND acting on batched_spline_domain.
221 *
222 * @param extrap_rules The extrapolation rules at the lower then upper boundary, for each dimension.
223 *
224 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
225 */
226 explicit SplineEvaluatorND(ExtrapolationRule const&... extrap_rules)
227 : SplineEvaluatorND(cexa::make_tuple(extrap_rules...))
228 {
229 }
230
231 /**
232 * @brief Copy-constructs.
233 *
234 * @param x A reference to another SplineEvaluator.
235 */
236 SplineEvaluatorND(SplineEvaluatorND const& x) = default;
237
238 /**
239 * @brief Move-constructs.
240 *
241 * @param x An rvalue to another SplineEvaluator.
242 */
243 SplineEvaluatorND(SplineEvaluatorND&& x) = default;
244
245 /// @brief Destructs.
246 ~SplineEvaluatorND() = default;
247
248 /**
249 * @brief Copy-assigns.
250 *
251 * @param x A reference to another SplineEvaluator.
252 * @return A reference to this object.
253 */
254 SplineEvaluatorND& operator=(SplineEvaluatorND const& x) = default;
255
256 /**
257 * @brief Move-assigns.
258 *
259 * @param x An rvalue to another SplineEvaluator.
260 * @return A reference to this object.
261 */
262 SplineEvaluatorND& operator=(SplineEvaluatorND&& x) = default;
263
264 /**
265 * @brief Get the lower extrapolation rule along the Ith dimension.
266 *
267 * Extrapolation rules are functors used to define the behavior of the SplineEvaluator out of the domain where the break points of the B-splines are defined.
268 *
269 * @return The lower extrapolation rule along the Ith dimension.
270 *
271 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
272 */
273 template <std::size_t I>
274 auto lower_extrapolation_rule() const
275 {
276 return cexa::get<I>(m_lower_extrap_rules);
277 }
278
279 /**
280 * @brief Get the upper extrapolation rule along the Ith dimension.
281 *
282 * Extrapolation rules are functors used to define the behavior of the SplineEvaluator out of the domain where the break points of the B-splines are defined.
283 *
284 * @return The upper extrapolation rule along the Ith dimension.
285 *
286 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
287 */
288 template <std::size_t I>
289 auto upper_extrapolation_rule() const
290 {
291 return cexa::get<I>(m_upper_extrap_rules);
292 }
293
294 /**
295 * @brief Evaluate ND spline function (described by its spline coefficients) at a given coordinate.
296 *
297 * The spline coefficients represent a ND spline function defined on a B-splines (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
298 *
299 * Remark: calling SplineBuilderND then SplineEvaluatorND corresponds to a ND spline interpolation.
300 *
301 * @param coord_eval The coordinate where the spline is evaluated. Note that only the components along the dimensions of interest are used.
302 * @param spline_coef A ChunkSpan storing the ND spline coefficients.
303 *
304 * @return The value of the spline function at the desired coordinate.
305 */
306 template <class Layout, class... CoordsDims>
307 KOKKOS_FUNCTION double operator()(
308 ddc::Coordinate<CoordsDims...> const& coord_eval,
309 ddc::ChunkSpan<
310 double const,
311 ddc::DiscreteDomain<BSplines...>,
312 Layout,
313 memory_space> const spline_coef) const
314 {
315 return eval(coord_eval, spline_coef);
316 }
317
318 /**
319 * @brief Evaluate ND spline function (described by its spline coefficients) on a mesh.
320 *
321 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
322 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
323 *
324 * This is not a nD evaluation. This is a batched ND evaluation. This means that for each slice of coordinates
325 * identified by a batch_domain_type::discrete_element_type, the evaluation is performed with the ND set of
326 * spline coefficients identified by the same batch_domain_type::discrete_element_type.
327 *
328 * Remark: calling SplineBuilderND then SplineEvaluatorND corresponds to a ND spline interpolation.
329 *
330 * @param[out] spline_eval The values of the ND spline function at the desired coordinates. For practical reasons those are
331 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
332 * @param[in] coords_eval The coordinates where the spline is evaluated. Those are
333 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
334 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
335 * the set of ND spline coefficients retained to perform the evaluation).
336 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
337 */
338 template <
339 class Layout1,
340 class Layout2,
341 class Layout3,
342 class BatchedInterpolationDDom,
343 class... CoordsDims>
344 void operator()(
345 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
346 spline_eval,
347 ddc::ChunkSpan<
348 ddc::Coordinate<CoordsDims...> const,
349 BatchedInterpolationDDom,
350 Layout2,
351 memory_space> const coords_eval,
352 ddc::ChunkSpan<
353 double const,
354 batched_spline_domain_type<BatchedInterpolationDDom>,
355 Layout3,
356 memory_space> const spline_coef) const
357 {
358 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
359 evaluation_domain_type const evaluation_domain(spline_eval.domain());
360
361 batch_domain_type<BatchedInterpolationDDom> const batch_domain(coords_eval.domain());
362
363 ddc::parallel_for_each(
364 "ddc_splines_evaluate_Nd",
365 exec_space(),
366 batch_domain,
367 KOKKOS_CLASS_LAMBDA(
368 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
369 j) {
370 auto const spline_eval_ND = spline_eval[j];
371 auto const coords_eval_ND = coords_eval[j];
372 auto const spline_coef_ND = spline_coef[j];
373 ddc::device_for_each(
374 evaluation_domain,
375 [&](evaluation_domain_type::discrete_element_type const i) {
376 spline_eval_ND(i) = eval(coords_eval_ND(i), spline_coef_ND);
377 });
378 });
379 }
380
381 /**
382 * @brief Evaluate ND spline function (described by its spline coefficients) on a mesh.
383 *
384 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
385 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
386 *
387 * This is not a multidimensional evaluation. This is a batched ND evaluation.
388 * This means that for each slice of spline_eval the evaluation is performed with
389 * the ND set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
390 *
391 * Remark: calling SplineBuilderND then SplineEvaluatorND corresponds to a ND spline interpolation.
392 *
393 * @param[out] spline_eval The values of the ND spline function at their coordinates.
394 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
395 */
396 template <class Layout1, class Layout2, class BatchedInterpolationDDom>
397 void operator()(
398 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
399 spline_eval,
400 ddc::ChunkSpan<
401 double const,
402 batched_spline_domain_type<BatchedInterpolationDDom>,
403 Layout2,
404 memory_space> const spline_coef) const
405 {
406 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
407 evaluation_domain_type evaluation_domain(spline_eval.domain());
408
409 batch_domain_type<BatchedInterpolationDDom> const batch_domain(spline_eval.domain());
410
411 ddc::parallel_for_each(
412 "ddc_splines_evaluate_Nd",
413 exec_space(),
414 batch_domain,
415 KOKKOS_CLASS_LAMBDA(
416 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
417 j) {
418 auto const spline_eval_ND = spline_eval[j];
419 auto const spline_coef_ND = spline_coef[j];
420
421 ddc::device_for_each(
422 evaluation_domain,
423 [&](evaluation_domain_type::discrete_element_type const i) {
424 ddc::Coordinate<typename BSplines::continuous_dimension_type...>
425 coord_eval_ND(ddc::coordinate(i));
426 spline_eval_ND(i) = eval(coord_eval_ND, spline_coef_ND);
427 });
428 });
429 }
430
431 /**
432 * @brief Differentiate ND spline function (described by its spline coefficients) at a given coordinate along specified dimensions of interest.
433 *
434 * The spline coefficients represent a ND spline function defined on a B-splines (basis splines). They can be
435 * obtained via various methods, such as using a SplineBuilderND.
436 *
437 * @param deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
438 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
439 * @param coord_eval The coordinate where the spline is differentiated. Note that only the components along the dimensions of interest are used.
440 * @param spline_coef A ChunkSpan storing the ND spline coefficients.
441 *
442 * @return The derivative of the spline function at the desired coordinate.
443 */
444 template <class DElem, class Layout, class... CoordsDims>
445 KOKKOS_FUNCTION double deriv(
446 DElem const& deriv_order,
447 ddc::Coordinate<CoordsDims...> const& coord_eval,
448 ddc::ChunkSpan<
449 double const,
450 ddc::DiscreteDomain<BSplines...>,
451 Layout,
452 memory_space> const spline_coef) const
453 {
454 static_assert(ddc::is_discrete_element_v<DElem>);
455
456 return eval_no_bc(deriv_order, coord_eval, spline_coef);
457 }
458
459
460 /**
461 * @brief Differentiate spline function (described by its spline coefficients) on a mesh along specified dimensions of interest.
462 *
463 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
464 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
465 *
466 * This is not a nD evaluation. This is a batched ND differentiation.
467 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
468 * the differentiation is performed with the ND set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
469 *
470 * @param[in] deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
471 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
472 * @param[out] spline_eval The derivatives of the ND spline function at the desired coordinates. For practical reasons those are
473 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
474 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
475 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
476 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
477 * the set of ND spline coefficients retained to perform the evaluation).
478 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
479 */
480 template <
481 class DElem,
482 class Layout1,
483 class Layout2,
484 class Layout3,
485 class BatchedInterpolationDDom,
486 class... CoordsDims>
487 void deriv(
488 DElem const& deriv_order,
489 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
490 spline_eval,
491 ddc::ChunkSpan<
492 ddc::Coordinate<CoordsDims...> const,
493 BatchedInterpolationDDom,
494 Layout2,
495 memory_space> const coords_eval,
496 ddc::ChunkSpan<
497 double const,
498 batched_spline_domain_type<BatchedInterpolationDDom>,
499 Layout3,
500 memory_space> const spline_coef) const
501 {
502 static_assert(ddc::is_discrete_element_v<DElem>);
503
504 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
505 evaluation_domain_type const evaluation_domain(spline_eval.domain());
506
507 batch_domain_type<BatchedInterpolationDDom> const batch_domain(spline_eval.domain());
508
509 ddc::parallel_for_each(
510 "ddc_splines_cross_differentiate_Nd",
511 exec_space(),
512 batch_domain,
513 KOKKOS_CLASS_LAMBDA(
514 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
515 j) {
516 auto const spline_eval_ND = spline_eval[j];
517 auto const coords_eval_ND = coords_eval[j];
518 auto const spline_coef_ND = spline_coef[j];
519 ddc::device_for_each(
520 evaluation_domain,
521 [&](evaluation_domain_type::discrete_element_type const i) {
522 spline_eval_ND(i) = eval_no_bc(
523 deriv_order,
524 coords_eval_ND(i),
525 spline_coef_ND);
526 });
527 });
528 }
529
530 /**
531 * @brief Differentiate spline function (described by its spline coefficients) on a mesh along specified dimensions of interest.
532 *
533 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
534 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
535 *
536 * This is not a multidimensional evaluation. This is a batched ND evaluation.
537 * This means that for each slice of spline_eval the evaluation is performed with
538 * the ND set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
539 *
540 * @param[in] deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
541 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
542 * @param[out] spline_eval The derivatives of the ND spline function at the desired coordinates.
543 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
544 */
545 template <class DElem, class Layout1, class Layout2, class BatchedInterpolationDDom>
546 void deriv(
547 DElem const& deriv_order,
548 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
549 spline_eval,
550 ddc::ChunkSpan<
551 double const,
552 batched_spline_domain_type<BatchedInterpolationDDom>,
553 Layout2,
554 memory_space> const spline_coef) const
555 {
556 static_assert(is_discrete_element_v<DElem>);
557
558 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
559 evaluation_domain_type evaluation_domain(spline_eval.domain());
560
561 batch_domain_type<BatchedInterpolationDDom> const batch_domain(spline_eval.domain());
562
563 ddc::parallel_for_each(
564 "ddc_splines_cross_differentiate_Nd",
565 exec_space(),
566 batch_domain,
567 KOKKOS_CLASS_LAMBDA(
568 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
569 j) {
570 auto const spline_eval_ND = spline_eval[j];
571 auto const spline_coef_ND = spline_coef[j];
572 ddc::device_for_each(
573 evaluation_domain,
574 [&](evaluation_domain_type::discrete_element_type const i) {
575 ddc::Coordinate<typename BSplines::continuous_dimension_type...>
576 coord_eval_ND(ddc::coordinate(i));
577 spline_eval_ND(i)
578 = eval_no_bc(deriv_order, coord_eval_ND, spline_coef_ND);
579 });
580 });
581 }
582
583 /** @brief Perform batched ND integrations of a spline function (described by its spline coefficients) along the dimensions of interest and store results on a subdomain of batch_domain.
584 *
585 * The spline coefficients represent a ND spline function defined on a B-splines (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
586 *
587 * This is not a nD integration. This is a batched ND integration.
588 * This means that for each element of integrals, the integration is performed with the ND set of
589 * spline coefficients identified by the same DiscreteElement.
590 *
591 * @param[out] integrals The integrals of the ND spline function on the subdomain of batch_domain. For practical reasons those are
592 * stored in a ChunkSpan defined on a batch_domain_type. Note that the coordinates of the
593 * points represented by this domain are unused and irrelevant.
594 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
595 */
596 template <class Layout1, class Layout2, class BatchedDDom, class BatchedSplineDDom>
597 void integrate(
598 ddc::ChunkSpan<double, BatchedDDom, Layout1, memory_space> const integrals,
599 ddc::ChunkSpan<double const, BatchedSplineDDom, Layout2, memory_space> const
600 spline_coef) const
601 {
602 static_assert(
603 ddc::type_seq_contains_v<bsplines_ts, to_type_seq_t<BatchedSplineDDom>>,
604 "The spline coefficients domain must contain the bsplines dimensions");
605 static_assert(
606 std::is_same_v<batch_domain_type<BatchedDDom>, BatchedDDom>,
607 "The integrals domain must only contain the batch dimensions");
608
609 using bsplines_domain_type = ddc::DiscreteDomain<BSplines...>;
610 bsplines_domain_type const bsplines_domain(spline_coef.domain());
611
612 batch_domain_type<BatchedDDom> const batch_domain(integrals.domain());
613 auto values_alloc = cexa::make_tuple(
614 ddc::
615 Chunk(ddc::DiscreteDomain<BSplines>(spline_coef.domain()),
616 ddc::KokkosAllocator<double, memory_space>())...);
617 auto values = cexa::make_tuple(cexa::get<s_idx<BSplines>>(values_alloc).span_view()...);
618 (ddc::integrals(exec_space(), cexa::get<s_idx<BSplines>>(values)), ...);
619
620 ddc::parallel_for_each(
621 "ddc_splines_integrate_bsplines",
622 exec_space(),
623 batch_domain,
624 KOKKOS_LAMBDA(batch_domain_type<BatchedDDom>::discrete_element_type const j) {
625 integrals(j) = 0;
626 ddc::device_for_each(
627 bsplines_domain,
628 [&](bsplines_domain_type::discrete_element_type const i) {
629 integrals(j) += spline_coef(i, j)
630 * (cexa::get<s_idx<BSplines>>(values)(
631 ddc::DiscreteElement<BSplines>(i))
632 * ...);
633 });
634 });
635 }
636
637private:
638 template <std::size_t I, class... CoordsDims>
639 KOKKOS_INLINE_FUNCTION static void update_coord_eval(ddc::Coordinate<CoordsDims...>& coord_eval)
640 {
641 using Dim = continuous_dimension_type<I>;
642 using bsplines_t = bsplines_type<I>;
643
644 if constexpr (bsplines_t::is_periodic()) {
645 if (ddc::get<Dim>(coord_eval) < ddc::discrete_space<bsplines_t>().rmin()
646 || ddc::get<Dim>(coord_eval) > ddc::discrete_space<bsplines_t>().rmax()) {
647 ddc::get<Dim>(coord_eval) -= Kokkos::floor(
648 (ddc::get<Dim>(coord_eval)
649 - ddc::discrete_space<bsplines_t>().rmin())
650 / ddc::discrete_space<bsplines_t>().length())
651 * ddc::discrete_space<bsplines_t>().length();
652 }
653 }
654 }
655
656 template <std::size_t I, class Layout, class... CoordsDims>
657 KOKKOS_INLINE_FUNCTION bool check_needs_extrapolation(
658 ddc::Coordinate<CoordsDims...> coord_eval,
659 ddc::ChunkSpan<
660 double const,
661 ddc::DiscreteDomain<BSplines...>,
662 Layout,
663 memory_space> const spline_coef,
664 double& res) const
665 {
666 if constexpr (!bsplines_type<I>::is_periodic()) {
667 if (ddc::get<continuous_dimension_type<I>>(coord_eval)
668 < ddc::discrete_space<bsplines_type<I>>().rmin()) {
669 res = cexa::get<I>(m_lower_extrap_rules)(coord_eval, spline_coef);
670 return true;
671 }
672 if (ddc::get<continuous_dimension_type<I>>(coord_eval)
673 > ddc::discrete_space<bsplines_type<I>>().rmax()) {
674 res = cexa::get<I>(m_upper_extrap_rules)(coord_eval, spline_coef);
675 return true;
676 }
677 }
678 return false;
679 }
680
681 /**
682 * @brief Evaluate the function on B-splines at the coordinate given.
683 *
684 * This function firstly deals with the boundary conditions and calls the SplineEvaluatorND::eval_no_bc function
685 * to evaluate.
686 *
687 * @param[in] coord_eval The ND coordinate where we want to evaluate.
688 * @param[in] spline_coef The B-splines coefficients of the function we want to evaluate.
689 * @param[out] vals1 A ChunkSpan with the not-null values of each function of the spline in the first dimension.
690 * @param[out] vals2 A ChunkSpan with the not-null values of each function of the spline in the second dimension.
691 *
692 * @return A double with the value of the function at the coordinate given.
693 *
694 * @see SplineBoundaryValue
695 */
696 template <class Layout, class... CoordsDims>
697 KOKKOS_INLINE_FUNCTION double eval(
698 ddc::Coordinate<CoordsDims...> coord_eval,
699 ddc::ChunkSpan<
700 double const,
701 ddc::DiscreteDomain<BSplines...>,
702 Layout,
703 memory_space> const spline_coef) const
704 {
705 (update_coord_eval<s_idx<BSplines>>(coord_eval), ...);
706
707 double res = 0.;
708 // We rely on short circuit here. If we need to extrapolate on one of the dims, `res` will be set and `check_needs_extrapolation` will return true.
709 bool const needs_extrapolation
710 = (... || check_needs_extrapolation<s_idx<BSplines>>(coord_eval, spline_coef, res));
711
712 if (needs_extrapolation) {
713 return res;
714 }
715
716 return eval_no_bc(
717 ddc::DiscreteElement<>(),
718 ddc::Coordinate<typename BSplines::continuous_dimension_type...>(
719 ddc::get<typename BSplines::continuous_dimension_type>(coord_eval)...),
720 spline_coef);
721 }
722
723 template <class BSplinesType, class... DerivDims, class CoordDim>
724 KOKKOS_INLINE_FUNCTION static ddc::DiscreteElement<BSplinesType> get_jmin(
725 ddc::DiscreteElement<DerivDims...> const& deriv_order,
726 Kokkos::mdspan<double, Kokkos::extents<std::size_t, BSplinesType::degree() + 1>> vals,
727 ddc::Coordinate<CoordDim> const& coord_eval)
728 {
729 using deriv_dim = Deriv<typename BSplinesType::continuous_dimension_type>;
730 using deriv_dims = detail::TypeSeq<DerivDims...>;
731 if constexpr (!in_tags_v<deriv_dim, deriv_dims>) {
732 return ddc::discrete_space<BSplinesType>().eval_basis(vals, coord_eval);
733 } else {
734 auto const order = deriv_order.template uid<deriv_dim>();
735 KOKKOS_ASSERT(order > 0 && order <= BSplinesType::degree())
736
737 std::array<double, (BSplinesType::degree() + 1) * (BSplinesType::degree() + 1)>
738 derivs_ptr;
739 Kokkos::mdspan<
740 double,
741 Kokkos::extents<
742 std::size_t,
743 BSplinesType::degree() + 1,
744 Kokkos::dynamic_extent>> const derivs(derivs_ptr.data(), order + 1);
745
746 auto jmin = ddc::discrete_space<BSplinesType>()
747 .eval_basis_and_n_derivs(derivs, coord_eval, order);
748
749 for (std::size_t i = 0; i < BSplinesType::degree() + 1; ++i) {
750 vals[i] = DDC_MDSPAN_ACCESS_OP(derivs, i, order);
751 }
752
753 return jmin;
754 }
755 }
756
757 template <std::size_t N, class Functor, class... Is>
758 KOKKOS_INLINE_FUNCTION static void for_each(
759 std::array<std::size_t, N> const& bounds,
760 Functor const& f,
761 Is... is)
762 {
763 static constexpr std::size_t I = sizeof...(Is);
764 if constexpr (I == N) {
765 f(std::array<std::size_t, N> {is...});
766 } else {
767 for (std::size_t i = 0; i < bounds[I]; ++i) {
768 for_each(bounds, f, is..., i);
769 }
770 }
771 }
772
773 /**
774 * @brief Evaluate the function or its derivative at the coordinate given.
775 *
776 * @param[in] deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
777 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
778 * @param[in] coord_eval The coordinate where we want to evaluate.
779 * @param[in] splne_coef The B-splines coefficients of the function we want to evaluate.
780 */
781 template <class... DerivDims, class Layout, class... CoordsDims>
782 KOKKOS_INLINE_FUNCTION double eval_no_bc(
783 ddc::DiscreteElement<DerivDims...> const& deriv_order,
784 ddc::Coordinate<CoordsDims...> const& coord_eval,
785 ddc::ChunkSpan<
786 double const,
787 ddc::DiscreteDomain<BSplines...>,
788 Layout,
789 memory_space> const spline_coef) const
790 {
791 // Check that the tags are valid
792 static_assert(
793 (in_tags_v<
794 DerivDims,
795 ddc::detail::TypeSeq<Deriv<continuous_dimension_type<s_idx<BSplines>>>...>>
796 && ...),
797 "The only valid dimensions for deriv_order are Deriv<Dim1>, Deriv<Dim2>, ..., "
798 "Deriv<DimN>");
799
800 auto vals_ptr = cexa::make_tuple(std::array<double, BSplines::degree() + 1> {}...);
801 auto const vals = cexa::make_tuple(
802 Kokkos::mdspan<double, Kokkos::extents<std::size_t, BSplines::degree() + 1>>(
803 cexa::get<s_idx<BSplines>>(vals_ptr).data())...);
804
805 auto const jmin = cexa::make_tuple(
806 get_jmin<BSplines>(
807 deriv_order,
808 cexa::get<s_idx<BSplines>>(vals),
809 ddc::Coordinate<typename BSplines::continuous_dimension_type>(
810 coord_eval))...);
811
812 double y = 0.0;
813 for_each(
814 std::array<std::size_t, dimension> {(BSplines::degree() + 1)...},
815 [&](std::array<std::size_t, dimension> idx) {
816 y += spline_coef(
817 ddc::DiscreteElement<BSplines...>(
818 (cexa::get<s_idx<BSplines>>(jmin)
819 + idx[s_idx<BSplines>])...))
820 * (cexa::get<s_idx<BSplines>>(vals)[idx[s_idx<BSplines>]] * ...);
821 });
822
823 return y;
824 }
825};
826
827} // namespace ddc
friend class ChunkSpan
friend class Chunk
Definition chunk.hpp:81
friend class DiscreteDomain
KOKKOS_DEFAULTED_FUNCTION constexpr DiscreteElement()=default
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
A class which provides helper functions to initialise the Greville points from a B-Spline definition.
static ddc::DiscreteDomain< Sampling > get_domain()
Get the domain which gives us access to all of the Greville points.
Helper class for the initialisation of the mesh of interpolation points.
static auto get_sampling()
Get the sampling of interpolation points.
static ddc::DiscreteDomain< Sampling > get_domain()
Get the domain which can be used to access the interpolation points in the sampling.
Storage class of the static attributes of the discrete dimension.
Impl & operator=(Impl &&x)=default
Move-assigns.
Impl(RandomIt breaks_begin, RandomIt breaks_end)
Constructs an Impl by iterating over a range of break points from begin to end.
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmin() const noexcept
Returns the coordinate of the first break point of the domain on which the B-splines are defined.
Impl(std::vector< ddc::Coordinate< CDim > > const &breaks)
Constructs an Impl using a std::vector.
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 std::size_t size() const noexcept
Returns the number of elements necessary to construct a spline representation of a function.
Impl(Impl< DDim, OriginMemorySpace > const &impl)
Copy-constructs from another Impl with a different Kokkos memory space.
~Impl()=default
Destructs.
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::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(Impl &&x)=default
Move-constructs.
Impl(std::initializer_list< ddc::Coordinate< CDim > > breaks)
Constructs an Impl using a brace-list, i.e.
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 std::size_t ncells() const noexcept
Returns the number of cells over which the B-splines are defined.
KOKKOS_INLINE_FUNCTION discrete_domain_type full_domain() const
Returns the discrete domain including eventual additional B-splines in the periodic case.
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 std::size_t npoints() const noexcept
The number of break points.
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 discrete_element_type eval_deriv(DSpan1D derivs, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-spline derivatives at a given coordinate.
KOKKOS_INLINE_FUNCTION double length() const noexcept
Returns the length of the domain.
Impl & operator=(Impl const &x)=default
Copy-assigns.
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmax() const noexcept
Returns the coordinate of the last break point of the domain on which the B-splines are defined.
The type of a non-uniform 1D spline basis (B-spline).
static constexpr std::size_t degree() noexcept
The degree of B-splines.
static constexpr bool is_periodic() noexcept
Indicates if the B-splines are periodic or not.
static constexpr bool is_uniform() noexcept
Indicates if the B-splines are uniform or not (this is not the case here).
NonUniformPointSampling models a non-uniform discretization of the CDim segment .
A class for creating a 2D spline approximation of a function.
SplineBuilder2D(BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder2D acting on the interpolation domain contained in batched_interpolation_domain.
SplineBuilder2D & operator=(SplineBuilder2D const &x)=delete
Copy-assignment is deleted.
SplineBuilder2D(std::string const &label, BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder2D acting on the interpolation domain contained in batched_interpolation_domain.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 2D interpolation mesh used by this class.
SplineBuilder2D(SplineBuilder2D &&x)=default
Move-constructs.
batched_spline_domain_type< BatchedInterpolationDDom > batched_spline_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which spline coefficients are defined.
SplineBuilder2D(interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder2D acting on interpolation_domain.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type< BatchedInterpolationDDom >, Layout, memory_space > spline, ddc::ChunkSpan< double const, BatchedInterpolationDDom, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2=std::nullopt) const
Compute a 2D spline approximation of a function.
~SplineBuilder2D()=default
Destructs.
SplineBuilder2D(std::string const &label, interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder2D acting on interpolation_domain.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2 > spline_domain() const noexcept
Get the 2D domain on which spline coefficients are defined.
SplineBuilder2D(SplineBuilder2D const &x)=delete
Copy-constructor is deleted.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
SplineBuilder2D & operator=(SplineBuilder2D &&x)=default
Move-assigns.
A class for creating a 3D spline approximation of a function.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type< BatchedInterpolationDDom >, Layout, memory_space > spline, ddc::ChunkSpan< double const, BatchedInterpolationDDom, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type3< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type3< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2_max3=std::nullopt) const
Compute a 3D spline approximation of a function.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
SplineBuilder3D(interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder3D acting on interpolation_domain.
SplineBuilder3D(std::string label, BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder3D acting on the interpolation domain contained in batched_interpolation_domain.
SplineBuilder3D & operator=(SplineBuilder3D &&x)=default
Move-assigns.
batched_spline_domain_type< BatchedInterpolationDDom > batched_spline_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which spline coefficients are defined.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2, bsplines_type3 > spline_domain() const noexcept
Get the 3D domain on which spline coefficients are defined.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 3D interpolation mesh used by this class.
~SplineBuilder3D()=default
Destructs.
SplineBuilder3D & operator=(SplineBuilder3D const &x)=delete
Copy-assignment is deleted.
SplineBuilder3D(BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder3D acting on the interpolation domain contained in batched_interpolation_domain.
SplineBuilder3D(std::string label, interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder3D acting on interpolation_domain.
SplineBuilder3D(SplineBuilder3D const &x)=delete
Copy-constructor is deleted.
SplineBuilder3D(SplineBuilder3D &&x)=default
Move-constructs.
A class for creating a spline approximation of a function.
ddc::DiscreteDomain< bsplines_type > spline_domain() const noexcept
Get the 1D domain on which spline coefficients are defined.
SplineBuilder(BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder acting on the interpolation domain contained by batched_interpolation_domain.
SplineBuilder(SplineBuilder const &x)=delete
Copy-constructor is deleted.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 1D interpolation mesh used by this class.
batched_derivs_domain_type< BatchedInterpolationDDom > batched_derivs_xmax_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which derivatives on upper boundary are defined.
static constexpr int s_nbe_xmin
The number of equations defining the closure relation at the lower bound.
static constexpr ddc::SplineBuilderClosure s_sbc_xmin
The closure relation implemented at the lower bound.
SplineBuilder(std::string label, BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder acting on the interpolation domain contained by batched_interpolation_domain.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
SplineBuilder & operator=(SplineBuilder &&x)=default
Move-assigns.
static constexpr int s_nbe_xmax
The number of equations defining the closure relation at the upper bound.
static constexpr SplineSolver s_spline_solver
The SplineSolver giving the backend used to perform the spline approximation.
static constexpr ddc::SplineBuilderClosure s_sbc_xmax
The closure relation implemented at the upper bound.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
std::tuple< ddc::Chunk< double, ddc::DiscreteDomain< ddc::Deriv< typename InterpolationDDim::continuous_dimension_type > >, ddc::KokkosAllocator< double, OutMemorySpace > >, ddc::Chunk< double, ddc::DiscreteDomain< InterpolationDDim >, ddc::KokkosAllocator< double, OutMemorySpace > >, ddc::Chunk< double, ddc::DiscreteDomain< ddc::Deriv< typename InterpolationDDim::continuous_dimension_type > >, ddc::KokkosAllocator< double, OutMemorySpace > > > quadrature_coefficients() const
Compute the quadrature coefficients associated to the b-splines used by this SplineBuilder.
batched_spline_domain_type< BatchedInterpolationDDom > batched_spline_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which spline coefficients are defined.
SplineBuilder(interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder acting on interpolation_domain.
static constexpr bool s_odd
Indicates if the degree of the splines is odd or even.
batched_derivs_domain_type< BatchedInterpolationDDom > batched_derivs_xmin_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which derivatives on lower boundary are defined.
SplineBuilder(std::string label, interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder acting on interpolation_domain.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type< BatchedInterpolationDDom >, Layout, memory_space > spline, ddc::ChunkSpan< double const, BatchedInterpolationDDom, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > derivs_xmin=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > derivs_xmax=std::nullopt) const
Compute a spline approximation of a function.
SplineBuilder(SplineBuilder &&x)=default
Move-constructs.
static constexpr int s_nbv_xmax
The number of input values defining the closure relation at the upper bound.
~SplineBuilder()=default
Destructs.
static constexpr int s_nbv_xmin
The number of input values defining the closure relation at the lower bound.
SplineBuilder & operator=(SplineBuilder const &x)=delete
Copy-assignment is deleted.
A class to evaluate, differentiate or integrate a 2D spline function.
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) on a mesh.
SplineEvaluator2D(SplineEvaluator2D &&x)=default
Move-constructs.
lower_extrapolation_rule_1_type lower_extrapolation_rule_dim_1() const
Get the lower extrapolation rule along the first dimension.
SplineEvaluator2D & operator=(SplineEvaluator2D const &x)=default
Copy-assigns.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) on a mesh along the dimension...
SplineEvaluator2D(SplineEvaluator2D const &x)=default
Copy-constructs.
~SplineEvaluator2D()=default
Destructs.
KOKKOS_FUNCTION double deriv(DElem const &deriv_order, ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) at a given coordinate along t...
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) on a mesh along the dimension...
void integrate(ddc::ChunkSpan< double, BatchedDDom, Layout1, memory_space > const integrals, ddc::ChunkSpan< double const, BatchedSplineDDom, Layout2, memory_space > const spline_coef) const
Perform batched 2D integrations of a spline function (described by its spline coefficients) along the...
upper_extrapolation_rule_2_type upper_extrapolation_rule_dim_2() const
Get the upper extrapolation rule along the second dimension.
upper_extrapolation_rule_1_type upper_extrapolation_rule_dim_1() const
Get the upper extrapolation rule along the first dimension.
lower_extrapolation_rule_2_type lower_extrapolation_rule_dim_2() const
Get the lower extrapolation rule along the second dimension.
SplineEvaluator2D & operator=(SplineEvaluator2D &&x)=default
Move-assigns.
KOKKOS_FUNCTION double operator()(ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) at a given coordinate.
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) on a mesh.
SplineEvaluator2D(LowerExtrapolationRule1 const &lower_extrap_rule1, UpperExtrapolationRule1 const &upper_extrap_rule1, LowerExtrapolationRule2 const &lower_extrap_rule2, UpperExtrapolationRule2 const &upper_extrap_rule2)
Build a SplineEvaluator2D acting on batched_spline_domain.
A class to evaluate, differentiate or integrate a 3D spline function.
upper_extrapolation_rule_1_type upper_extrapolation_rule_dim_1() const
Get the upper extrapolation rule along the first dimension.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Differentiate 3D spline function (described by its spline coefficients) on a mesh along the dimension...
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Evaluate 3D spline function (described by its spline coefficients) on a mesh.
SplineEvaluator3D & operator=(SplineEvaluator3D &&x)=default
Move-assigns.
upper_extrapolation_rule_3_type upper_extrapolation_rule_dim_3() const
Get the upper extrapolation rule along the third dimension.
SplineEvaluator3D(LowerExtrapolationRule1 const &lower_extrap_rule1, UpperExtrapolationRule1 const &upper_extrap_rule1, LowerExtrapolationRule2 const &lower_extrap_rule2, UpperExtrapolationRule2 const &upper_extrap_rule2, LowerExtrapolationRule3 const &lower_extrap_rule3, UpperExtrapolationRule3 const &upper_extrap_rule3)
Build a SplineEvaluator3D acting on batched_spline_domain.
~SplineEvaluator3D()=default
Destructs.
lower_extrapolation_rule_1_type lower_extrapolation_rule_dim_1() const
Get the lower extrapolation rule along the first dimension.
upper_extrapolation_rule_2_type upper_extrapolation_rule_dim_2() const
Get the upper extrapolation rule along the second dimension.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Differentiate 3D spline function (described by its spline coefficients) on a mesh along the dimension...
KOKKOS_FUNCTION double deriv(DElem const &deriv_order, ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Differentiate 3D spline function (described by its spline coefficients) at a given coordinate along t...
SplineEvaluator3D(SplineEvaluator3D const &x)=default
Copy-constructs.
KOKKOS_FUNCTION double operator()(ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Evaluate 3D spline function (described by its spline coefficients) at a given coordinate.
lower_extrapolation_rule_3_type lower_extrapolation_rule_dim_3() const
Get the lower extrapolation rule along the third dimension.
SplineEvaluator3D(SplineEvaluator3D &&x)=default
Move-constructs.
void integrate(ddc::ChunkSpan< double, BatchedDDom, Layout1, memory_space > const integrals, ddc::ChunkSpan< double const, BatchedSplineDDom, Layout2, memory_space > const spline_coef) const
Perform batched 3D integrations of a spline function (described by its spline coefficients) along the...
lower_extrapolation_rule_2_type lower_extrapolation_rule_dim_2() const
Get the lower extrapolation rule along the second dimension.
SplineEvaluator3D & operator=(SplineEvaluator3D const &x)=default
Copy-assigns.
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Evaluate 3D spline function (described by its spline coefficients) on a mesh.
A class to evaluate, differentiate or integrate a spline function.
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Evaluate spline function (described by its spline coefficients) on a mesh.
upper_extrapolation_rule_type upper_extrapolation_rule() const
Get the upper extrapolation rule.
SplineEvaluator & operator=(SplineEvaluator const &x)=default
Copy-assigns.
SplineEvaluator & operator=(SplineEvaluator &&x)=default
Move-assigns.
SplineEvaluator(LowerExtrapolationRule const &lower_extrap_rule, UpperExtrapolationRule const &upper_extrap_rule)
Build a SplineEvaluator acting on batched_spline_domain.
lower_extrapolation_rule_type lower_extrapolation_rule() const
Get the lower extrapolation rule.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Differentiate 1D spline function (described by its spline coefficients) on a mesh.
KOKKOS_FUNCTION double operator()(ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Evaluate 1D spline function (described by its spline coefficients) at a given coordinate.
KOKKOS_FUNCTION double deriv(DElem const &deriv_order, ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Differentiate 1D spline function (described by its spline coefficients) at a given coordinate.
SplineEvaluator(SplineEvaluator const &x)=default
Copy-constructs.
SplineEvaluator(SplineEvaluator &&x)=default
Move-constructs.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Differentiate 1D spline function (described by its spline coefficients) on a mesh.
void integrate(ddc::ChunkSpan< double, BatchedDDom, Layout1, memory_space > const integrals, ddc::ChunkSpan< double const, BatchedSplineDDom, Layout2, memory_space > const spline_coef) const
Perform batched 1D integrations of a spline function (described by its spline coefficients) along the...
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Evaluate a spline function (described by its spline coefficients) on a mesh.
~SplineEvaluator()=default
Destructs.
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.
ddc::ChunkSpan< double, ddc::DiscreteDomain< DDim >, Layout, MemorySpace > integrals(ExecSpace const &execution_space, ddc::ChunkSpan< double, ddc::DiscreteDomain< DDim >, Layout, MemorySpace > int_vals)
Compute the integrals of the B-splines.
SplineSolver
An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.
@ LAPACK
Enum member to identify the LAPACK-based solver (direct method)
@ GINKGO
Enum member to identify the Ginkgo-based solver (iterative method)
constexpr int n_boundary_equations(ddc::SplineBuilderClosure const sbc, std::size_t const degree)
Return the number of equations needed to describe a given closure relation.
constexpr bool is_non_uniform_bsplines_v
Indicates if a tag corresponds to non-uniform B-splines or not.
SplineBuilderClosure
An enum representing a spline closure relation.
@ HOMOGENEOUS_HERMITE
Homogeneous Hermite closure relation (derivatives are 0)
@ GREVILLE
Use Greville points instead of conditions on derivative for B-Spline interpolation.
@ HERMITE
Hermite closure relation.
@ PERIODIC
Periodic closure relation u(1)=u(n)
A templated struct representing a discrete dimension storing the derivatives of a function along a co...
Definition deriv.hpp:15
If the type DDim is a B-spline, defines type to the discrete dimension of the associated knots.
ConstantExtrapolationRule(ddc::Coordinate< DimI > eval_pos, ddc::Coordinate< DimNI > eval_pos_not_interest_min, ddc::Coordinate< DimNI > eval_pos_not_interest_max)
Instantiate a ConstantExtrapolationRule.
KOKKOS_FUNCTION double operator()(CoordType coord_extrap, ddc::ChunkSpan< double const, ddc::DiscreteDomain< BSplines1, BSplines2 >, Layout, MemorySpace > const spline_coef) const
Get the value of the function on B-splines at a coordinate outside the domain.
ConstantExtrapolationRule(ddc::Coordinate< DimI > eval_pos)
Instantiate a ConstantExtrapolationRule.
KOKKOS_FUNCTION double operator()(CoordType pos, ddc::ChunkSpan< double const, ddc::DiscreteDomain< BSplines >, Layout, MemorySpace > const spline_coef) const
Get the value of the function on B-splines at a coordinate outside the domain.
ConstantExtrapolationRule(ddc::Coordinate< DimI > eval_pos)
Instantiate a ConstantExtrapolationRule.
A functor describing a null extrapolation boundary value for 1D spline evaluator.
KOKKOS_FUNCTION double operator()(CoordType, ChunkSpan) const
Evaluates the spline at a coordinate outside of the domain.
KOKKOS_FUNCTION double operator()(CoordType, ChunkSpan) const