DDC 0.15.0
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
155public:
156 static_assert(
157 sizeof...(BSplines) == dimension,
158 "Number of BSpline dims should be equal to the dimension");
159 static_assert(
160 sizeof...(EvaluationDDim) == dimension,
161 "Number of evaluation dims should be equal to the dimensions");
162 static_assert(
163 ddc::type_seq_size_v<lower_extrap_rule_ts> == dimension,
164 "Number of lower extrapolation rules should be equal to the dimension");
165 static_assert(
166 ddc::type_seq_size_v<upper_extrap_rule_ts> == dimension,
167 "Number of upper extrapolation rules should be equal to the dimension");
168
169 static_assert(
170 ((std::is_same_v<
171 ddc::type_seq_element_t<s_idx<BSplines>, lower_extrap_rule_ts>,
172 ddc::PeriodicExtrapolationRule<typename BSplines::continuous_dimension_type>>
173 == BSplines::is_periodic()
174 && std::is_same_v<
175 ddc::type_seq_element_t<s_idx<BSplines>, upper_extrap_rule_ts>,
177 typename BSplines::continuous_dimension_type>>
178 == BSplines::is_periodic())
179 && ...),
180 "PeriodicExtrapolationRule has to be used if and only if dimension is periodic");
181 static_assert(
182 (std::is_invocable_r_v<
183 double,
184 ddc::type_seq_element_t<s_idx<BSplines>, lower_extrap_rule_ts>,
185 ddc::Coordinate<typename BSplines::continuous_dimension_type>,
186 ddc::ChunkSpan<
187 double const,
188 ddc::DiscreteDomain<BSplines>,
189 Kokkos::layout_right,
190 memory_space>>
191 && ...),
192 "LowerExtrapolationRule::operator() has to be callable "
193 "with usual arguments.");
194 static_assert(
195 (std::is_invocable_r_v<
196 double,
197 ddc::type_seq_element_t<s_idx<BSplines>, upper_extrap_rule_ts>,
198 ddc::Coordinate<typename BSplines::continuous_dimension_type>,
199 ddc::ChunkSpan<
200 double const,
201 ddc::DiscreteDomain<BSplines>,
202 Kokkos::layout_right,
203 memory_space>>
204 && ...),
205 "UpperExtrapolationRule::operator() has to be callable "
206 "with usual arguments.");
207
208 /**
209 * @brief Build a SplineEvaluatorND acting on batched_spline_domain.
210 *
211 * @param extrap_rules The extrapolation rules at the lower then upper boundary, for each dimension.
212 *
213 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
214 */
215 template <class... ExtrapRules>
216 explicit SplineEvaluatorND(ExtrapRules const&... extrap_rules)
217 {
218 static_assert(
219 (std::is_same_v<ExtrapRules, ExtrapolationRule> && ...),
220 "The type of the extrapolation rules passed to the constructor should be the same "
221 "as the ones passed as template argument to the class");
222
223 cexa::tuple<ExtrapRules...> extrap_rules_tuple(extrap_rules...);
224 m_lower_extrap_rules
225 = cexa::make_tuple(cexa::get<2 * s_idx<BSplines>>(extrap_rules_tuple)...);
226 m_upper_extrap_rules
227 = cexa::make_tuple(cexa::get<2 * s_idx<BSplines> + 1>(extrap_rules_tuple)...);
228 }
229
230 /**
231 * @brief Copy-constructs.
232 *
233 * @param x A reference to another SplineEvaluator.
234 */
235 SplineEvaluatorND(SplineEvaluatorND const& x) = default;
236
237 /**
238 * @brief Move-constructs.
239 *
240 * @param x An rvalue to another SplineEvaluator.
241 */
242 SplineEvaluatorND(SplineEvaluatorND&& x) = default;
243
244 /// @brief Destructs.
245 ~SplineEvaluatorND() = default;
246
247 /**
248 * @brief Copy-assigns.
249 *
250 * @param x A reference to another SplineEvaluator.
251 * @return A reference to this object.
252 */
253 SplineEvaluatorND& operator=(SplineEvaluatorND const& x) = default;
254
255 /**
256 * @brief Move-assigns.
257 *
258 * @param x An rvalue to another SplineEvaluator.
259 * @return A reference to this object.
260 */
261 SplineEvaluatorND& operator=(SplineEvaluatorND&& x) = default;
262
263 /**
264 * @brief Get the lower extrapolation rule along the Ith dimension.
265 *
266 * 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.
267 *
268 * @return The lower extrapolation rule along the Ith dimension.
269 *
270 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
271 */
272 template <std::size_t I>
273 auto lower_extrapolation_rule() const
274 {
275 return cexa::get<I>(m_lower_extrap_rules);
276 }
277
278 /**
279 * @brief Get the upper extrapolation rule along the Ith dimension.
280 *
281 * 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.
282 *
283 * @return The upper extrapolation rule along the Ith dimension.
284 *
285 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
286 */
287 template <std::size_t I>
288 auto upper_extrapolation_rule() const
289 {
290 return cexa::get<I>(m_upper_extrap_rules);
291 }
292
293 /**
294 * @brief Evaluate ND spline function (described by its spline coefficients) at a given coordinate.
295 *
296 * 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.
297 *
298 * Remark: calling SplineBuilderND then SplineEvaluatorND corresponds to a ND spline interpolation.
299 *
300 * @param coord_eval The coordinate where the spline is evaluated. Note that only the components along the dimensions of interest are used.
301 * @param spline_coef A ChunkSpan storing the ND spline coefficients.
302 *
303 * @return The value of the spline function at the desired coordinate.
304 */
305 template <class Layout, class... CoordsDims>
306 KOKKOS_FUNCTION double operator()(
307 ddc::Coordinate<CoordsDims...> const& coord_eval,
308 ddc::ChunkSpan<
309 double const,
310 ddc::DiscreteDomain<BSplines...>,
311 Layout,
312 memory_space> const spline_coef) const
313 {
314 return eval(coord_eval, spline_coef);
315 }
316
317 /**
318 * @brief Evaluate ND spline function (described by its spline coefficients) on a mesh.
319 *
320 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
321 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
322 *
323 * This is not a nD evaluation. This is a batched ND evaluation. This means that for each slice of coordinates
324 * identified by a batch_domain_type::discrete_element_type, the evaluation is performed with the ND set of
325 * spline coefficients identified by the same batch_domain_type::discrete_element_type.
326 *
327 * Remark: calling SplineBuilderND then SplineEvaluatorND corresponds to a ND spline interpolation.
328 *
329 * @param[out] spline_eval The values of the ND spline function at the desired coordinates. For practical reasons those are
330 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
331 * @param[in] coords_eval The coordinates where the spline is evaluated. Those are
332 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
333 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
334 * the set of ND spline coefficients retained to perform the evaluation).
335 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
336 */
337 template <
338 class Layout1,
339 class Layout2,
340 class Layout3,
341 class BatchedInterpolationDDom,
342 class... CoordsDims>
343 void operator()(
344 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
345 spline_eval,
346 ddc::ChunkSpan<
347 ddc::Coordinate<CoordsDims...> const,
348 BatchedInterpolationDDom,
349 Layout2,
350 memory_space> const coords_eval,
351 ddc::ChunkSpan<
352 double const,
353 batched_spline_domain_type<BatchedInterpolationDDom>,
354 Layout3,
355 memory_space> const spline_coef) const
356 {
357 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
358 evaluation_domain_type const evaluation_domain(spline_eval.domain());
359
360 batch_domain_type<BatchedInterpolationDDom> const batch_domain(coords_eval.domain());
361
362 ddc::parallel_for_each(
363 "ddc_splines_evaluate_Nd",
364 exec_space(),
365 batch_domain,
366 KOKKOS_CLASS_LAMBDA(
367 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
368 j) {
369 auto const spline_eval_ND = spline_eval[j];
370 auto const coords_eval_ND = coords_eval[j];
371 auto const spline_coef_ND = spline_coef[j];
372 ddc::device_for_each(
373 evaluation_domain,
374 [&](evaluation_domain_type::discrete_element_type const i) {
375 spline_eval_ND(i) = eval(coords_eval_ND(i), spline_coef_ND);
376 });
377 });
378 }
379
380 /**
381 * @brief Evaluate ND spline function (described by its spline coefficients) on a mesh.
382 *
383 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
384 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
385 *
386 * This is not a multidimensional evaluation. This is a batched ND evaluation.
387 * This means that for each slice of spline_eval the evaluation is performed with
388 * the ND set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
389 *
390 * Remark: calling SplineBuilderND then SplineEvaluatorND corresponds to a ND spline interpolation.
391 *
392 * @param[out] spline_eval The values of the ND spline function at their coordinates.
393 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
394 */
395 template <class Layout1, class Layout2, class BatchedInterpolationDDom>
396 void operator()(
397 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
398 spline_eval,
399 ddc::ChunkSpan<
400 double const,
401 batched_spline_domain_type<BatchedInterpolationDDom>,
402 Layout2,
403 memory_space> const spline_coef) const
404 {
405 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
406 evaluation_domain_type evaluation_domain(spline_eval.domain());
407
408 batch_domain_type<BatchedInterpolationDDom> const batch_domain(spline_eval.domain());
409
410 ddc::parallel_for_each(
411 "ddc_splines_evaluate_Nd",
412 exec_space(),
413 batch_domain,
414 KOKKOS_CLASS_LAMBDA(
415 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
416 j) {
417 auto const spline_eval_ND = spline_eval[j];
418 auto const spline_coef_ND = spline_coef[j];
419
420 ddc::device_for_each(
421 evaluation_domain,
422 [&](evaluation_domain_type::discrete_element_type const i) {
423 ddc::Coordinate<typename BSplines::continuous_dimension_type...>
424 coord_eval_ND(ddc::coordinate(i));
425 spline_eval_ND(i) = eval(coord_eval_3D(i), spline_coef_ND);
426 });
427 });
428 }
429
430 /**
431 * @brief Differentiate ND spline function (described by its spline coefficients) at a given coordinate along specified dimensions of interest.
432 *
433 * The spline coefficients represent a ND spline function defined on a B-splines (basis splines). They can be
434 * obtained via various methods, such as using a SplineBuilderND.
435 *
436 * @param deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
437 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
438 * @param coord_eval The coordinate where the spline is differentiated. Note that only the components along the dimensions of interest are used.
439 * @param spline_coef A ChunkSpan storing the ND spline coefficients.
440 *
441 * @return The derivative of the spline function at the desired coordinate.
442 */
443 template <class DElem, class Layout, class... CoordsDims>
444 KOKKOS_FUNCTION double deriv(
445 DElem const& deriv_order,
446 ddc::Coordinate<CoordsDims...> const& coord_eval,
447 ddc::ChunkSpan<
448 double const,
449 ddc::DiscreteDomain<BSplines...>,
450 Layout,
451 memory_space> const spline_coef) const
452 {
453 static_assert(ddc::is_discrete_element_v<DElem>);
454
455 return eval_no_bc(deriv_order, coord_eval, spline_coef);
456 }
457
458
459 /**
460 * @brief Differentiate spline function (described by its spline coefficients) on a mesh along specified dimensions of interest.
461 *
462 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
463 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
464 *
465 * This is not a nD evaluation. This is a batched ND differentiation.
466 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
467 * the differentiation is performed with the ND set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
468 *
469 * @param[in] deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
470 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
471 * @param[out] spline_eval The derivatives of the ND spline function at the desired coordinates. For practical reasons those are
472 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
473 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
474 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
475 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
476 * the set of ND spline coefficients retained to perform the evaluation).
477 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
478 */
479 template <
480 class DElem,
481 class Layout1,
482 class Layout2,
483 class Layout3,
484 class BatchedInterpolationDDom,
485 class... CoordsDims>
486 void deriv(
487 DElem const& deriv_order,
488 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
489 spline_eval,
490 ddc::ChunkSpan<
491 ddc::Coordinate<CoordsDims...> const,
492 BatchedInterpolationDDom,
493 Layout2,
494 memory_space> const coords_eval,
495 ddc::ChunkSpan<
496 double const,
497 batched_spline_domain_type<BatchedInterpolationDDom>,
498 Layout3,
499 memory_space> const spline_coef) const
500 {
501 static_assert(ddc::is_discrete_element_v<DElem>);
502
503 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
504 evaluation_domain_type const evaluation_domain(spline_eval.domain());
505
506 batch_domain_type<BatchedInterpolationDDom> const batch_domain(spline_eval.domain());
507
508 ddc::parallel_for_each(
509 "ddc_splines_cross_differentiate_Nd",
510 exec_space(),
511 batch_domain,
512 KOKKOS_CLASS_LAMBDA(
513 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
514 j) {
515 auto const spline_eval_ND = spline_eval[j];
516 auto const coords_eval_ND = coords_eval[j];
517 auto const spline_coef_ND = spline_coef[j];
518 ddc::device_for_each(
519 evaluation_domain,
520 [&](evaluation_domain_type::discrete_element_type const i) {
521 spline_eval_ND(i) = eval_no_bc(
522 deriv_order,
523 coords_eval_ND(i),
524 spline_coef_ND);
525 });
526 });
527 }
528
529 /**
530 * @brief Differentiate spline function (described by its spline coefficients) on a mesh along specified dimensions of interest.
531 *
532 * The spline coefficients represent a ND spline function defined on a cartesian product of batch_domain and B-splines
533 * (basis splines). They can be obtained via various methods, such as using a SplineBuilderND.
534 *
535 * This is not a multidimensional evaluation. This is a batched ND evaluation.
536 * This means that for each slice of spline_eval the evaluation is performed with
537 * the ND set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
538 *
539 * @param[in] deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
540 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
541 * @param[out] spline_eval The derivatives of the ND spline function at the desired coordinates.
542 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
543 */
544 template <class DElem, class Layout1, class Layout2, class BatchedInterpolationDDom>
545 void deriv(
546 DElem const& deriv_order,
547 ddc::ChunkSpan<double, BatchedInterpolationDDom, Layout1, memory_space> const
548 spline_eval,
549 ddc::ChunkSpan<
550 double const,
551 batched_spline_domain_type<BatchedInterpolationDDom>,
552 Layout2,
553 memory_space> const spline_coef) const
554 {
555 static_assert(is_discrete_element_v<DElem>);
556
557 using evaluation_domain_type = ddc::DiscreteDomain<EvaluationDDim...>;
558 evaluation_domain_type evaluation_domain(spline_eval.domain());
559
560 batch_domain_type<BatchedInterpolationDDom> const batch_domain(spline_eval.domain());
561
562 ddc::parallel_for_each(
563 "ddc_splines_cross_differentiate_Nd",
564 exec_space(),
565 batch_domain,
566 KOKKOS_CLASS_LAMBDA(
567 batch_domain_type<BatchedInterpolationDDom>::discrete_element_type const
568 j) {
569 auto const spline_eval_ND = spline_eval[j];
570 auto const spline_coef_ND = spline_coef[j];
571 ddc::device_for_each(
572 evaluation_domain,
573 [&](evaluation_domain_type::discrete_element_type const i) {
574 ddc::Coordinate<typename BSplines::continuous_dimension_type...>
575 coord_eval_ND(ddc::coordinate(i));
576 spline_eval_ND(i)
577 = eval_no_bc(deriv_order, coord_eval_ND, spline_coef_ND);
578 });
579 });
580 }
581
582 /** @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.
583 *
584 * 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.
585 *
586 * This is not a nD integration. This is a batched ND integration.
587 * This means that for each element of integrals, the integration is performed with the ND set of
588 * spline coefficients identified by the same DiscreteElement.
589 *
590 * @param[out] integrals The integrals of the ND spline function on the subdomain of batch_domain. For practical reasons those are
591 * stored in a ChunkSpan defined on a batch_domain_type. Note that the coordinates of the
592 * points represented by this domain are unused and irrelevant.
593 * @param[in] spline_coef A ChunkSpan storing the ND spline coefficients.
594 */
595 template <class Layout1, class Layout2, class BatchedDDom, class BatchedSplineDDom>
596 void integrate(
597 ddc::ChunkSpan<double, BatchedDDom, Layout1, memory_space> const integrals,
598 ddc::ChunkSpan<double const, BatchedSplineDDom, Layout2, memory_space> const
599 spline_coef) const
600 {
601 static_assert(
602 ddc::type_seq_contains_v<bsplines_ts, to_type_seq_t<BatchedSplineDDom>>,
603 "The spline coefficients domain must contain the bsplines dimensions");
604 static_assert(
605 std::is_same_v<batch_domain_type<BatchedDDom>, BatchedDDom>,
606 "The integrals domain must only contain the batch dimensions");
607
608 using bsplines_domain_type = ddc::DiscreteDomain<BSplines...>;
609 bsplines_domain_type const bsplines_domain(spline_coef.domain());
610
611 batch_domain_type<BatchedDDom> const batch_domain(integrals.domain());
612 auto values_alloc = cexa::make_tuple(
613 ddc::
614 Chunk(ddc::DiscreteDomain<BSplines>(spline_coef.domain()),
615 ddc::KokkosAllocator<double, memory_space>())...);
616 auto values = cexa::make_tuple(cexa::get<s_idx<BSplines>>(values_alloc).span_view()...);
617 (ddc::integrals(exec_space(), cexa::get<s_idx<BSplines>>(values)), ...);
618
619 ddc::parallel_for_each(
620 "ddc_splines_integrate_bsplines",
621 exec_space(),
622 batch_domain,
623 KOKKOS_LAMBDA(batch_domain_type<BatchedDDom>::discrete_element_type const j) {
624 integrals(j) = 0;
625 ddc::device_for_each(
626 bsplines_domain,
627 [&](bsplines_domain_type::discrete_element_type const i) {
628 integrals(j) += spline_coef(i, j)
629 * (cexa::get<s_idx<BSplines>>(values)(
630 ddc::DiscreteElement<BSplines>(i))
631 * ...);
632 });
633 });
634 }
635
636private:
637 template <std::size_t I, class... CoordsDims>
638 KOKKOS_INLINE_FUNCTION static void update_coord_eval(ddc::Coordinate<CoordsDims...>& coord_eval)
639 {
640 using Dim = continuous_dimension_type<I>;
641 using bsplines_t = bsplines_type<I>;
642
643 if constexpr (bsplines_t::is_periodic()) {
644 if (ddc::get<Dim>(coord_eval) < ddc::discrete_space<bsplines_t>().rmin()
645 || ddc::get<Dim>(coord_eval) > ddc::discrete_space<bsplines_t>().rmax()) {
646 ddc::get<Dim>(coord_eval) -= Kokkos::floor(
647 (ddc::get<Dim>(coord_eval)
648 - ddc::discrete_space<bsplines_t>().rmin())
649 / ddc::discrete_space<bsplines_t>().length())
650 * ddc::discrete_space<bsplines_t>().length();
651 }
652 }
653 }
654
655 template <std::size_t I, class Layout, class... CoordsDims>
656 KOKKOS_INLINE_FUNCTION bool check_needs_extrapolation(
657 ddc::Coordinate<CoordsDims...> coord_eval,
658 ddc::ChunkSpan<
659 double const,
660 ddc::DiscreteDomain<BSplines...>,
661 Layout,
662 memory_space> const spline_coef,
663 double& res) const
664 {
665 if constexpr (!bsplines_type<I>::is_periodic()) {
666 if (ddc::get<continuous_dimension_type<I>>(coord_eval)
667 < ddc::discrete_space<bsplines_type<I>>().rmin()) {
668 res = cexa::get<I>(m_lower_extrap_rules)(coord_eval, spline_coef);
669 return true;
670 }
671 if (ddc::get<continuous_dimension_type<I>>(coord_eval)
672 > ddc::discrete_space<bsplines_type<I>>().rmax()) {
673 res = cexa::get<I>(m_upper_extrap_rules)(coord_eval, spline_coef);
674 return true;
675 }
676 }
677 return false;
678 }
679
680 /**
681 * @brief Evaluate the function on B-splines at the coordinate given.
682 *
683 * This function firstly deals with the boundary conditions and calls the SplineEvaluatorND::eval_no_bc function
684 * to evaluate.
685 *
686 * @param[in] coord_eval The ND coordinate where we want to evaluate.
687 * @param[in] spline_coef The B-splines coefficients of the function we want to evaluate.
688 * @param[out] vals1 A ChunkSpan with the not-null values of each function of the spline in the first dimension.
689 * @param[out] vals2 A ChunkSpan with the not-null values of each function of the spline in the second dimension.
690 *
691 * @return A double with the value of the function at the coordinate given.
692 *
693 * @see SplineBoundaryValue
694 */
695 template <class Layout, class... CoordsDims>
696 KOKKOS_INLINE_FUNCTION double eval(
697 ddc::Coordinate<CoordsDims...> coord_eval,
698 ddc::ChunkSpan<
699 double const,
700 ddc::DiscreteDomain<BSplines...>,
701 Layout,
702 memory_space> const spline_coef) const
703 {
704 (update_coord_eval<s_idx<BSplines>>(coord_eval), ...);
705
706 double res = 0.;
707 // 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.
708 bool const needs_extrapolation
709 = (... || check_needs_extrapolation<s_idx<BSplines>>(coord_eval, spline_coef, res));
710
711 if (needs_extrapolation) {
712 return res;
713 }
714
715 return eval_no_bc(
716 ddc::DiscreteElement<>(),
717 ddc::Coordinate<typename BSplines::continuous_dimension_type...>(
718 ddc::get<typename BSplines::continuous_dimension_type>(coord_eval)...),
719 spline_coef);
720 }
721
722 template <class BSplinesType, class... DerivDims, class CoordDim>
723 KOKKOS_INLINE_FUNCTION static ddc::DiscreteElement<BSplinesType> get_jmin(
724 ddc::DiscreteElement<DerivDims...> const& deriv_order,
725 Kokkos::mdspan<double, Kokkos::extents<std::size_t, BSplinesType::degree() + 1>> vals,
726 ddc::Coordinate<CoordDim> const& coord_eval)
727 {
728 using deriv_dim = Deriv<typename BSplinesType::continuous_dimension_type>;
729 using deriv_dims = detail::TypeSeq<DerivDims...>;
730 if constexpr (!in_tags_v<deriv_dim, deriv_dims>) {
731 return ddc::discrete_space<BSplinesType>().eval_basis(vals, coord_eval);
732 } else {
733 auto const order = deriv_order.template uid<deriv_dim>();
734 KOKKOS_ASSERT(order > 0 && order <= BSplinesType::degree())
735
736 std::array<double, (BSplinesType::degree() + 1) * (BSplinesType::degree() + 1)>
737 derivs_ptr;
738 Kokkos::mdspan<
739 double,
740 Kokkos::extents<
741 std::size_t,
742 BSplinesType::degree() + 1,
743 Kokkos::dynamic_extent>> const derivs(derivs_ptr.data(), order + 1);
744
745 auto jmin = ddc::discrete_space<BSplinesType>()
746 .eval_basis_and_n_derivs(derivs, coord_eval, order);
747
748 for (std::size_t i = 0; i < BSplinesType::degree() + 1; ++i) {
749 vals[i] = DDC_MDSPAN_ACCESS_OP(derivs, i, order);
750 }
751
752 return jmin;
753 }
754 }
755
756 template <std::size_t N, class Functor, class... Is>
757 KOKKOS_INLINE_FUNCTION static void for_each(
758 std::array<std::size_t, N> const& bounds,
759 Functor const& f,
760 Is... is)
761 {
762 static constexpr std::size_t I = sizeof...(Is);
763 if constexpr (I == N) {
764 f(std::array<std::size_t, N> {is...});
765 } else {
766 for (std::size_t i = 0; i < bounds[I]; ++i) {
767 for_each(bounds, f, is..., i);
768 }
769 }
770 }
771
772 /**
773 * @brief Evaluate the function or its derivative at the coordinate given.
774 *
775 * @param[in] deriv_order A DiscreteElement containing the orders of derivation for each of the dimensions of interest.
776 * If one of the dimensions is not present, its corresponding order of derivation is considered to be 0.
777 * @param[in] coord_eval The coordinate where we want to evaluate.
778 * @param[in] splne_coef The B-splines coefficients of the function we want to evaluate.
779 */
780 template <class... DerivDims, class Layout, class... CoordsDims>
781 KOKKOS_INLINE_FUNCTION double eval_no_bc(
782 ddc::DiscreteElement<DerivDims...> const& deriv_order,
783 ddc::Coordinate<CoordsDims...> const& coord_eval,
784 ddc::ChunkSpan<
785 double const,
786 ddc::DiscreteDomain<BSplines...>,
787 Layout,
788 memory_space> const spline_coef) const
789 {
790 // Check that the tags are valid
791 static_assert(
792 (in_tags_v<
793 DerivDims,
794 ddc::detail::TypeSeq<Deriv<continuous_dimension_type<s_idx<BSplines>>>...>>
795 && ...),
796 "The only valid dimensions for deriv_order are Deriv<Dim1>, Deriv<Dim2>, ..., "
797 "Deriv<DimN>");
798
799 auto vals_ptr = cexa::make_tuple(std::array<double, BSplines::degree() + 1> {}...);
800 auto const vals = cexa::make_tuple(
801 Kokkos::mdspan<double, Kokkos::extents<std::size_t, BSplines::degree() + 1>>(
802 cexa::get<s_idx<BSplines>>(vals_ptr).data())...);
803
804 auto const jmin = cexa::make_tuple(
805 get_jmin<BSplines>(
806 deriv_order,
807 cexa::get<s_idx<BSplines>>(vals),
808 ddc::Coordinate<typename BSplines::continuous_dimension_type>(
809 coord_eval))...);
810
811 double y = 0.0;
812 for_each(
813 std::array<std::size_t, dimension> {(BSplines::degree() + 1)...},
814 [&](std::array<std::size_t, dimension> idx) {
815 y += spline_coef(
816 ddc::DiscreteElement<BSplines...>(
817 (cexa::get<s_idx<BSplines>>(jmin)
818 + idx[s_idx<BSplines>])...))
819 * (cexa::get<s_idx<BSplines>>(vals)[idx[s_idx<BSplines>]] * ...);
820 });
821
822 return y;
823 }
824};
825
826} // 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.
#define DDC_BUILD_DEPRECATED_CODE
Definition config.hpp:7
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