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