DDC 0.1.0
Loading...
Searching...
No Matches
spline_evaluator_2d.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 "integrals.hpp"
16#include "periodic_extrapolation_rule.hpp"
17
18namespace ddc {
19
20/**
21 * @brief A class to evaluate, differentiate or integrate a 2D spline function.
22 *
23 * A class which contains an operator () which can be used to evaluate, differentiate or integrate a 2D spline function.
24 *
25 * @tparam ExecSpace The Kokkos execution space on which the spline evaluation is performed.
26 * @tparam MemorySpace The Kokkos memory space on which the data (spline coefficients and evaluation) is stored.
27 * @tparam BSplines1 The discrete dimension representing the B-splines along the first dimension of interest.
28 * @tparam BSplines2 The discrete dimension representing the B-splines along the second dimension of interest.
29 * @tparam EvaluationDDim1 The first discrete dimension on which evaluation points are defined.
30 * @tparam EvaluationDDim2 The second discrete dimension on which evaluation points are defined.
31 * @tparam LowerExtrapolationRule1 The lower extrapolation rule type along first dimension of interest.
32 * @tparam UpperExtrapolationRule1 The upper extrapolation rule type along first dimension of interest.
33 * @tparam LowerExtrapolationRule2 The lower extrapolation rule type along second dimension of interest.
34 * @tparam UpperExtrapolationRule2 The upper extrapolation rule type along second dimension of interest.
35 * @tparam IDimX A variadic template of all the discrete dimensions forming the full space (EvaluationDDim1 + EvaluationDDim2 + batched dimensions).
36 */
37template <
38 class ExecSpace,
39 class MemorySpace,
40 class BSplines1,
41 class BSplines2,
42 class EvaluationDDim1,
43 class EvaluationDDim2,
44 class LowerExtrapolationRule1,
45 class UpperExtrapolationRule1,
46 class LowerExtrapolationRule2,
47 class UpperExtrapolationRule2,
48 class... IDimX>
50{
51private:
52 /**
53 * @brief Tag to indicate that the value of the spline should be evaluated.
54 */
55 struct eval_type
56 {
57 };
58
59 /**
60 * @brief Tag to indicate that derivative of the spline should be evaluated.
61 */
62 struct eval_deriv_type
63 {
64 };
65
66public:
67 /// @brief The type of the first evaluation continuous dimension used by this class.
68 using continuous_dimension_type1 = typename BSplines1::continuous_dimension_type;
69
70 /// @brief The type of the second evaluation continuous dimension used by this class.
71 using continuous_dimension_type2 = typename BSplines2::continuous_dimension_type;
72
73 /// @brief The type of the Kokkos execution space used by this class.
74 using exec_space = ExecSpace;
75
76 /// @brief The type of the Kokkos memory space used by this class.
77 using memory_space = MemorySpace;
78
79 /// @brief The type of the first discrete dimension of interest used by this class.
80 using evaluation_discrete_dimension_type1 = EvaluationDDim1;
81
82 /// @brief The type of the second discrete dimension of interest used by this class.
83 using evaluation_discrete_dimension_type2 = EvaluationDDim2;
84
85 /// @brief The discrete dimension representing the B-splines along first dimension.
86 using bsplines_type1 = BSplines1;
87
88 /// @brief The discrete dimension representing the B-splines along second dimension.
89 using bsplines_type2 = BSplines2;
90
91 /// @brief The type of the domain for the 1D evaluation mesh along first dimension used by this class.
92 using evaluation_domain_type1 = ddc::DiscreteDomain<evaluation_discrete_dimension_type1>;
93
94 /// @brief The type of the domain for the 1D evaluation mesh along second dimension used by this class.
95 using evaluation_domain_type2 = ddc::DiscreteDomain<evaluation_discrete_dimension_type2>;
96
97 /// @brief The type of the domain for the 2D evaluation mesh used by this class.
98 using evaluation_domain_type = ddc::DiscreteDomain<
99 evaluation_discrete_dimension_type1,
100 evaluation_discrete_dimension_type2>;
101
102 /// @brief The type of the whole domain representing evaluation points.
103 using batched_evaluation_domain_type = ddc::DiscreteDomain<IDimX...>;
104
105 /// @brief The type of the 1D spline domain corresponding to the first dimension of interest.
106 using spline_domain_type1 = ddc::DiscreteDomain<bsplines_type1>;
107
108 /// @brief The type of the 1D spline domain corresponding to the second dimension of interest.
109 using spline_domain_type2 = ddc::DiscreteDomain<bsplines_type2>;
110
111 /// @brief The type of the 2D spline domain corresponding to the dimensions of interest.
112 using spline_domain_type = ddc::DiscreteDomain<bsplines_type1, bsplines_type2>;
113
114 /**
115 * @brief The type of the batch domain (obtained by removing the dimensions of interest
116 * from the whole domain).
117 */
118 using batch_domain_type = typename ddc::remove_dims_of_t<
119 batched_evaluation_domain_type,
120 evaluation_discrete_dimension_type1,
121 evaluation_discrete_dimension_type2>;
122
123 /**
124 * @brief The type of the whole spline domain (cartesian product of 2D spline domain
125 * and batch domain) preserving the underlying memory layout (order of dimensions).
126 */
127 using batched_spline_domain_type =
128 typename ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
129 ddc::detail::TypeSeq<IDimX...>,
130 ddc::detail::TypeSeq<
131 evaluation_discrete_dimension_type1,
132 evaluation_discrete_dimension_type2>,
133 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
134
135 /// @brief The type of the extrapolation rule at the lower boundary along the first dimension.
136 using lower_extrapolation_rule_1_type = LowerExtrapolationRule1;
137
138 /// @brief The type of the extrapolation rule at the upper boundary along the first dimension.
139 using upper_extrapolation_rule_1_type = UpperExtrapolationRule1;
140
141 /// @brief The type of the extrapolation rule at the lower boundary along the second dimension.
142 using lower_extrapolation_rule_2_type = LowerExtrapolationRule2;
143
144 /// @brief The type of the extrapolation rule at the upper boundary along the second dimension.
145 using upper_extrapolation_rule_2_type = UpperExtrapolationRule2;
146
147private:
148 LowerExtrapolationRule1 m_lower_extrap_rule_1;
149
150 UpperExtrapolationRule1 m_upper_extrap_rule_1;
151
152 LowerExtrapolationRule2 m_lower_extrap_rule_2;
153
154 UpperExtrapolationRule2 m_upper_extrap_rule_2;
155
156public:
157 static_assert(
158 std::is_same_v<LowerExtrapolationRule1,
159 typename ddc::PeriodicExtrapolationRule<continuous_dimension_type1>>
160 == bsplines_type1::is_periodic()
161 && std::is_same_v<
162 UpperExtrapolationRule1,
163 typename ddc::PeriodicExtrapolationRule<continuous_dimension_type1>>
164 == bsplines_type1::is_periodic()
165 && std::is_same_v<
166 LowerExtrapolationRule2,
167 typename ddc::PeriodicExtrapolationRule<continuous_dimension_type2>>
168 == bsplines_type2::is_periodic()
169 && std::is_same_v<
170 UpperExtrapolationRule2,
171 typename ddc::PeriodicExtrapolationRule<continuous_dimension_type2>>
172 == bsplines_type2::is_periodic(),
173 "PeriodicExtrapolationRule has to be used if and only if dimension is periodic");
174 static_assert(
175 std::is_invocable_r_v<
176 double,
177 LowerExtrapolationRule1,
178 ddc::Coordinate<continuous_dimension_type1>,
179 ddc::ChunkSpan<
180 double const,
181 spline_domain_type,
182 Kokkos::layout_right,
183 memory_space>>,
184 "LowerExtrapolationRule1::operator() has to be callable "
185 "with usual arguments.");
186 static_assert(
187 std::is_invocable_r_v<
188 double,
189 UpperExtrapolationRule1,
190 ddc::Coordinate<continuous_dimension_type1>,
191 ddc::ChunkSpan<
192 double const,
193 spline_domain_type,
194 Kokkos::layout_right,
195 memory_space>>,
196 "UpperExtrapolationRule1::operator() has to be callable "
197 "with usual arguments.");
198 static_assert(
199 std::is_invocable_r_v<
200 double,
201 LowerExtrapolationRule2,
202 ddc::Coordinate<continuous_dimension_type2>,
203 ddc::ChunkSpan<
204 double const,
205 spline_domain_type,
206 Kokkos::layout_right,
207 memory_space>>,
208 "LowerExtrapolationRule2::operator() has to be callable "
209 "with usual arguments.");
210 static_assert(
211 std::is_invocable_r_v<
212 double,
213 UpperExtrapolationRule2,
214 ddc::Coordinate<continuous_dimension_type2>,
215 ddc::ChunkSpan<
216 double const,
217 spline_domain_type,
218 Kokkos::layout_right,
219 memory_space>>,
220 "UpperExtrapolationRule2::operator() has to be callable "
221 "with usual arguments.");
222
223 /**
224 * @brief Build a SplineEvaluator2D acting on batched_spline_domain.
225 *
226 * @param lower_extrap_rule1 The extrapolation rule at the lower boundary along the first dimension.
227 * @param upper_extrap_rule1 The extrapolation rule at the upper boundary along the first dimension.
228 * @param lower_extrap_rule2 The extrapolation rule at the lower boundary along the second dimension.
229 * @param upper_extrap_rule2 The extrapolation rule at the upper boundary along the second dimension.
230 *
231 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
232 */
233 explicit SplineEvaluator2D(
234 LowerExtrapolationRule1 const& lower_extrap_rule1,
235 UpperExtrapolationRule1 const& upper_extrap_rule1,
236 LowerExtrapolationRule2 const& lower_extrap_rule2,
237 UpperExtrapolationRule2 const& upper_extrap_rule2)
238 : m_lower_extrap_rule_1(lower_extrap_rule1)
239 , m_upper_extrap_rule_1(upper_extrap_rule1)
240 , m_lower_extrap_rule_2(lower_extrap_rule2)
241 , m_upper_extrap_rule_2(upper_extrap_rule2)
242 {
243 }
244
245 /**
246 * @brief Copy-constructs.
247 *
248 * @param x A reference to another SplineEvaluator.
249 */
250 SplineEvaluator2D(SplineEvaluator2D const& x) = default;
251
252 /**
253 * @brief Move-constructs.
254 *
255 * @param x An rvalue to another SplineEvaluator.
256 */
258
259 /// @brief Destructs.
260 ~SplineEvaluator2D() = default;
261
262 /**
263 * @brief Copy-assigns.
264 *
265 * @param x A reference to another SplineEvaluator.
266 * @return A reference to this object.
267 */
268 SplineEvaluator2D& operator=(SplineEvaluator2D const& x) = default;
269
270 /**
271 * @brief Move-assigns.
272 *
273 * @param x An rvalue to another SplineEvaluator.
274 * @return A reference to this object.
275 */
277
278 /**
279 * @brief Get the lower extrapolation rule along the first 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 lower extrapolation rule along the first dimension.
284 *
285 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
286 */
287 lower_extrapolation_rule_1_type lower_extrapolation_rule_dim_1() const
288 {
289 return m_lower_extrap_rule_1;
290 }
291
292 /**
293 * @brief Get the upper extrapolation rule along the first dimension.
294 *
295 * 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.
296 *
297 * @return The upper extrapolation rule along the first dimension.
298 *
299 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
300 */
301 upper_extrapolation_rule_1_type upper_extrapolation_rule_dim_1() const
302 {
303 return m_upper_extrap_rule_1;
304 }
305
306 /**
307 * @brief Get the lower extrapolation rule along the second dimension.
308 *
309 * 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.
310 *
311 * @return The lower extrapolation rule along the second dimension.
312 *
313 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
314 */
315 lower_extrapolation_rule_2_type lower_extrapolation_rule_dim_2() const
316 {
317 return m_lower_extrap_rule_2;
318 }
319
320 /**
321 * @brief Get the upper extrapolation rule along the second dimension.
322 *
323 * 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.
324 *
325 * @return The upper extrapolation rule along the second dimension.
326 *
327 * @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
328 */
329 upper_extrapolation_rule_2_type upper_extrapolation_rule_dim_2() const
330 {
331 return m_upper_extrap_rule_2;
332 }
333
334 /**
335 * @brief Evaluate 2D spline function (described by its spline coefficients) at a given coordinate.
336 *
337 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
338 *
339 * Remark: calling SplineBuilder2D then SplineEvaluator2D corresponds to a 2D spline interpolation.
340 *
341 * @param coord_eval The coordinate where the spline is evaluated. Note that only the components along the dimensions of interest are used.
342 * @param spline_coef A ChunkSpan storing the 2D spline coefficients.
343 *
344 * @return The value of the spline function at the desired coordinate.
345 */
346 template <class Layout, class... CoordsDims>
347 KOKKOS_FUNCTION double operator()(
348 ddc::Coordinate<CoordsDims...> const& coord_eval,
349 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
350 spline_coef) const
351 {
352 return eval(coord_eval, spline_coef);
353 }
354
355 /**
356 * @brief Evaluate 2D spline function (described by its spline coefficients) on a mesh.
357 *
358 * The spline coefficients represent a 2D spline function defined on a cartesian product of batch_domain and B-splines
359 * (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
360 *
361 * This is not a nD evaluation. This is a batched 2D evaluation. This means that for each slice of coordinates
362 * identified by a batch_domain_type::discrete_element_type, the evaluation is performed with the 2D set of
363 * spline coefficients identified by the same batch_domain_type::discrete_element_type.
364 *
365 * Remark: calling SplineBuilder2D then SplineEvaluator2D corresponds to a 2D spline interpolation.
366 *
367 * @param[out] spline_eval The values of the 2D spline function at the desired coordinates. For practical reasons those are
368 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
369 * @param[in] coords_eval The coordinates where the spline is evaluated. Those are
370 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
371 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
372 * the set of 2D spline coefficients retained to perform the evaluation).
373 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
374 */
375 template <class Layout1, class Layout2, class Layout3, class... CoordsDims>
376 void operator()(
377 ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
378 spline_eval,
379 ddc::ChunkSpan<
380 ddc::Coordinate<CoordsDims...> const,
381 batched_evaluation_domain_type,
382 Layout2,
383 memory_space> const coords_eval,
384 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout3, memory_space> const
385 spline_coef) const
386 {
387 batch_domain_type const batch_domain(coords_eval.domain());
388 evaluation_domain_type1 const evaluation_domain1(spline_eval.domain());
389 evaluation_domain_type2 const evaluation_domain2(spline_eval.domain());
390 ddc::parallel_for_each(
391 "ddc_splines_evaluate_2d",
392 exec_space(),
393 batch_domain,
394 KOKKOS_CLASS_LAMBDA(typename batch_domain_type::discrete_element_type const j) {
395 const auto spline_eval_2D = spline_eval[j];
396 const auto coords_eval_2D = coords_eval[j];
397 const auto spline_coef_2D = spline_coef[j];
398 for (auto const i1 : evaluation_domain1) {
399 for (auto const i2 : evaluation_domain2) {
400 spline_eval_2D(i1, i2) = eval(coords_eval_2D(i1, i2), spline_coef_2D);
401 }
402 }
403 });
404 }
405
406 /**
407 * @brief Differentiate 2D spline function (described by its spline coefficients) at a given coordinate along first dimension of interest.
408 *
409 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be
410 * obtained via various methods, such as using a SplineBuilder2D.
411 *
412 * @param coord_eval The coordinate where the spline is differentiated. Note that only the components along the dimensions of interest are used.
413 * @param spline_coef A ChunkSpan storing the 2D spline coefficients.
414 *
415 * @return The derivative of the spline function at the desired coordinate.
416 */
417 template <class Layout, class... CoordsDims>
419 ddc::Coordinate<CoordsDims...> const& coord_eval,
420 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
421 spline_coef) const
422 {
423 return eval_no_bc<eval_deriv_type, eval_type>(coord_eval, spline_coef);
424 }
425
426 /**
427 * @brief Differentiate 2D spline function (described by its spline coefficients) at a given coordinate along second dimension of interest.
428 *
429 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be
430 * obtained via various methods, such as using a SplineBuilder2D.
431 *
432 * @param coord_eval The coordinate where the spline is differentiated. Note that only the components along the dimensions of interest are used.
433 * @param spline_coef A ChunkSpan storing the 2D spline coefficients.
434 *
435 * @return The derivative of the spline function at the desired coordinate.
436 */
437 template <class Layout, class... CoordsDims>
439 ddc::Coordinate<CoordsDims...> const& coord_eval,
440 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
441 spline_coef) const
442 {
443 return eval_no_bc<eval_type, eval_deriv_type>(coord_eval, spline_coef);
444 }
445
446 /**
447 * @brief Cross-differentiate 2D spline function (described by its spline coefficients) at a given coordinate.
448 *
449 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be
450 * obtained via various methods, such as using a SplineBuilder2D.
451 *
452 * @param coord_eval The coordinate where the spline is differentiated. Note that only the components along the dimensions of interest are used.
453 * @param spline_coef A ChunkSpan storing the 2D spline coefficients.
454 *
455 * @return The derivative of the spline function at the desired coordinate.
456 */
457 template <class Layout, class... CoordsDims>
459 ddc::Coordinate<CoordsDims...> const& coord_eval,
460 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
461 spline_coef) const
462 {
463 return eval_no_bc<eval_deriv_type, eval_deriv_type>(coord_eval, spline_coef);
464 }
465
466 /**
467 * @brief Differentiate 2D spline function (described by its spline coefficients) at a given coordinate along a specified dimension of interest.
468 *
469 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be
470 * obtained via various methods, such as using a SplineBuilder2D.
471 *
472 * @tparam InterestDim Dimension along which differentiation is performed.
473 *
474 * @param coord_eval The coordinate where the spline is differentiated. Note that only the components along the dimensions of interest are used.
475 * @param spline_coef A ChunkSpan storing the 2D spline coefficients.
476 *
477 * @return The derivative of the spline function at the desired coordinate.
478 */
479 template <class InterestDim, class Layout, class... CoordsDims>
480 KOKKOS_FUNCTION double deriv(
481 ddc::Coordinate<CoordsDims...> const& coord_eval,
482 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
483 spline_coef) const
484 {
485 static_assert(
486 std::is_same_v<InterestDim, continuous_dimension_type1>
487 || std::is_same_v<InterestDim, continuous_dimension_type2>);
488 if constexpr (std::is_same_v<
489 InterestDim,
490 typename evaluation_discrete_dimension_type1::
491 continuous_dimension_type>) {
492 return deriv_dim_1(coord_eval, spline_coef);
493 } else if constexpr (std::is_same_v<
494 InterestDim,
495 typename evaluation_discrete_dimension_type2::
496 continuous_dimension_type>) {
497 return deriv_dim_2(coord_eval, spline_coef);
498 }
499 }
500
501 /**
502 * @brief Double-differentiate 2D spline function (described by its spline coefficients) at a given coordinate along specified dimensions of interest.
503 *
504 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be
505 * obtained via various methods, such as using a SplineBuilder2D.
506 *
507 * Note: double-differentiation other than cross-differentiation is not supported atm. See #440
508 *
509 * @tparam InterestDim1 First dimension along which differentiation is performed.
510 * @tparam InterestDim2 Second dimension along which differentiation is performed.
511 *
512 * @param coord_eval The coordinate where the spline is double-differentiated. Note that only the components along the dimensions of interest are used.
513 * @param spline_coef A ChunkSpan storing the 2D spline coefficients.
514 *
515 * @return The derivative of the spline function at the desired coordinate.
516 */
517 template <class InterestDim1, class InterestDim2, class Layout, class... CoordsDims>
518 KOKKOS_FUNCTION double deriv2(
519 ddc::Coordinate<CoordsDims...> const& coord_eval,
520 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
521 spline_coef) const
522 {
523 static_assert(
524 (std::is_same_v<
525 InterestDim1,
526 typename evaluation_discrete_dimension_type1::continuous_dimension_type>
527 && std::is_same_v<InterestDim2, continuous_dimension_type2>)
528 || (std::is_same_v<
529 InterestDim2,
530 typename evaluation_discrete_dimension_type1::continuous_dimension_type>
531 && std::is_same_v<InterestDim1, continuous_dimension_type2>));
532 return deriv_1_and_2(coord_eval, spline_coef);
533 }
534
535 /**
536 * @brief Differentiate 2D spline function (described by its spline coefficients) on a mesh along first dimension of interest.
537 *
538 * The spline coefficients represent a 2D spline function defined on a cartesian product of batch_domain and B-splines
539 * (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
540 *
541 * This is not a nD evaluation. This is a batched 2D differentiation.
542 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
543 * the differentiation is performed with the 2D set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
544 *
545 * @param[out] spline_eval The derivatives of the 2D spline function at the desired coordinates. For practical reasons those are
546 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
547 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
548 * the set of 2D spline coefficients retained to perform the evaluation).
549 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
550 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
551 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
552 * the set of 2D spline coefficients retained to perform the evaluation).
553 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
554 */
555 template <class Layout1, class Layout2, class Layout3, class... CoordsDims>
556 void deriv_dim_1(
557 ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
558 spline_eval,
559 ddc::ChunkSpan<
560 ddc::Coordinate<CoordsDims...> const,
561 batched_evaluation_domain_type,
562 Layout2,
563 memory_space> const coords_eval,
564 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout3, memory_space> const
565 spline_coef) const
566 {
567 batch_domain_type const batch_domain(coords_eval.domain());
568 evaluation_domain_type1 const evaluation_domain1(spline_eval.domain());
569 evaluation_domain_type2 const evaluation_domain2(spline_eval.domain());
570 ddc::parallel_for_each(
571 "ddc_splines_differentiate_2d_dim_1",
572 exec_space(),
573 batch_domain,
574 KOKKOS_CLASS_LAMBDA(typename batch_domain_type::discrete_element_type const j) {
575 const auto spline_eval_2D = spline_eval[j];
576 const auto coords_eval_2D = coords_eval[j];
577 const auto spline_coef_2D = spline_coef[j];
578 for (auto const i1 : evaluation_domain1) {
579 for (auto const i2 : evaluation_domain2) {
580 spline_eval_2D(i1, i2) = eval_no_bc<
581 eval_deriv_type,
582 eval_type>(coords_eval_2D(i1, i2), spline_coef_2D);
583 }
584 }
585 });
586 }
587
588 /**
589 * @brief Differentiate 2D spline function (described by its spline coefficients) on a mesh along second dimension of interest.
590 *
591 * The spline coefficients represent a 2D spline function defined on a cartesian product of batch_domain and B-splines
592 * (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
593 *
594 * This is not a nD differentiation. This is a batched 2D differentiation.
595 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
596 * the differentiation is performed with the 2D set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
597 *
598 * @param[out] spline_eval The derivatives of the 2D spline function at the desired coordinates. For practical reasons those are
599 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
600 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
601 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
602 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
603 * the set of 2D spline coefficients retained to perform the evaluation).
604 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
605 */
606 template <class Layout1, class Layout2, class Layout3, class... CoordsDims>
607 void deriv_dim_2(
608 ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
609 spline_eval,
610 ddc::ChunkSpan<
611 ddc::Coordinate<CoordsDims...> const,
612 batched_evaluation_domain_type,
613 Layout2,
614 memory_space> const coords_eval,
615 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout3, memory_space> const
616 spline_coef) const
617 {
618 batch_domain_type const batch_domain(coords_eval.domain());
619 evaluation_domain_type1 const evaluation_domain1(spline_eval.domain());
620 evaluation_domain_type2 const evaluation_domain2(spline_eval.domain());
621 ddc::parallel_for_each(
622 "ddc_splines_differentiate_2d_dim_2",
623 exec_space(),
624 batch_domain,
625 KOKKOS_CLASS_LAMBDA(typename batch_domain_type::discrete_element_type const j) {
626 const auto spline_eval_2D = spline_eval[j];
627 const auto coords_eval_2D = coords_eval[j];
628 const auto spline_coef_2D = spline_coef[j];
629 for (auto const i1 : evaluation_domain1) {
630 for (auto const i2 : evaluation_domain2) {
631 spline_eval_2D(i1, i2) = eval_no_bc<
632 eval_type,
633 eval_deriv_type>(coords_eval_2D(i1, i2), spline_coef_2D);
634 }
635 }
636 });
637 }
638
639 /**
640 * @brief Cross-differentiate 2D spline function (described by its spline coefficients) on a mesh along dimensions of interest.
641 *
642 * The spline coefficients represent a 2D spline function defined on a cartesian product of batch_domain and B-splines
643 * (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
644 *
645 * This is not a nD cross-differentiation. This is a batched 2D cross-differentiation.
646 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
647 * the cross-differentiation is performed with the 2D set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
648 *
649 * @param[out] spline_eval The cross-derivatives of the 2D spline function at the desired coordinates. For practical reasons those are
650 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
651 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
652 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
653 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
654 * the set of 2D spline coefficients retained to perform the evaluation).
655 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
656 */
657 template <class Layout1, class Layout2, class Layout3, class... CoordsDims>
658 void deriv_1_and_2(
659 ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
660 spline_eval,
661 ddc::ChunkSpan<
662 ddc::Coordinate<CoordsDims...> const,
663 batched_evaluation_domain_type,
664 Layout2,
665 memory_space> const coords_eval,
666 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout3, memory_space> const
667 spline_coef) const
668 {
669 batch_domain_type const batch_domain(coords_eval.domain());
670 evaluation_domain_type1 const evaluation_domain1(spline_eval.domain());
671 evaluation_domain_type2 const evaluation_domain2(spline_eval.domain());
672 ddc::parallel_for_each(
673 "ddc_splines_cross_differentiate",
674 exec_space(),
675 batch_domain,
676 KOKKOS_CLASS_LAMBDA(typename batch_domain_type::discrete_element_type const j) {
677 const auto spline_eval_2D = spline_eval[j];
678 const auto coords_eval_2D = coords_eval[j];
679 const auto spline_coef_2D = spline_coef[j];
680 for (auto const i1 : evaluation_domain1) {
681 for (auto const i2 : evaluation_domain2) {
682 spline_eval_2D(i1, i2) = eval_no_bc<
683 eval_deriv_type,
684 eval_deriv_type>(coords_eval_2D(i1, i2), spline_coef_2D);
685 }
686 }
687 });
688 }
689
690 /**
691 * @brief Differentiate spline function (described by its spline coefficients) on a mesh along a specified dimension of interest.
692 *
693 * The spline coefficients represent a 2D spline function defined on a cartesian product of batch_domain and B-splines
694 * (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
695 *
696 * This is not a nD evaluation. This is a batched 2D differentiation.
697 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
698 * the differentiation is performed with the 2D set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
699 *
700 * @tparam InterestDim Dimension along which differentiation is performed.
701 * @param[out] spline_eval The derivatives of the 2D spline function at the desired coordinates. For practical reasons those are
702 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
703 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
704 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
705 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
706 * the set of 2D spline coefficients retained to perform the evaluation).
707 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
708 */
709 template <class InterestDim, class Layout1, class Layout2, class Layout3, class... CoordsDims>
710 void deriv(
711 ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
712 spline_eval,
713 ddc::ChunkSpan<
714 ddc::Coordinate<CoordsDims...> const,
715 batched_evaluation_domain_type,
716 Layout2,
717 memory_space> const coords_eval,
718 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout3, memory_space> const
719 spline_coef) const
720 {
721 static_assert(
722 std::is_same_v<
723 InterestDim,
724 typename evaluation_discrete_dimension_type1::continuous_dimension_type>
725 || std::is_same_v<InterestDim, continuous_dimension_type2>);
726 if constexpr (std::is_same_v<
727 InterestDim,
728 typename evaluation_discrete_dimension_type1::
729 continuous_dimension_type>) {
730 return deriv_dim_1(spline_eval, coords_eval, spline_coef);
731 } else if constexpr (std::is_same_v<
732 InterestDim,
733 typename evaluation_discrete_dimension_type2::
734 continuous_dimension_type>) {
735 return deriv_dim_2(spline_eval, coords_eval, spline_coef);
736 }
737 }
738
739 /**
740 * @brief Double-differentiate 2D spline function (described by its spline coefficients) on a mesh along specified dimensions of interest.
741 *
742 * The spline coefficients represent a 2D spline function defined on a cartesian product of batch_domain and B-splines
743 * (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
744 *
745 * This is not a nD evaluation. This is a batched 2D differentiation.
746 * This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
747 * the differentiation is performed with the 2D set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
748 *
749 * Note: double-differentiation other than cross-differentiation is not supported atm. See #440
750 *
751 * @tparam InterestDim1 First dimension along which differentiation is performed.
752 * @tparam InterestDim2 Second dimension along which differentiation is performed.
753 *
754 * @param[out] spline_eval The derivatives of the 2D spline function at the desired coordinates. For practical reasons those are
755 * stored in a ChunkSpan defined on a batched_evaluation_domain_type.
756 * @param[in] coords_eval The coordinates where the spline is differentiated. Those are
757 * stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
758 * points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
759 * the set of 2D spline coefficients retained to perform the evaluation).
760 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
761 */
762 template <
763 class InterestDim1,
764 class InterestDim2,
765 class Layout1,
766 class Layout2,
767 class Layout3,
768 class... CoordsDims>
769 void deriv2(
770 ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
771 spline_eval,
772 ddc::ChunkSpan<
773 ddc::Coordinate<CoordsDims...> const,
774 batched_evaluation_domain_type,
775 Layout2,
776 memory_space> const coords_eval,
777 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout3, memory_space> const
778 spline_coef) const
779 {
780 static_assert(
781 (std::is_same_v<
782 InterestDim1,
783 typename evaluation_discrete_dimension_type1::continuous_dimension_type>
784 && std::is_same_v<InterestDim2, continuous_dimension_type2>)
785 || (std::is_same_v<
786 InterestDim2,
787 typename evaluation_discrete_dimension_type1::continuous_dimension_type>
788 && std::is_same_v<InterestDim1, continuous_dimension_type2>));
789 return deriv_1_and_2(spline_eval, coords_eval, spline_coef);
790 }
791
792 /** @brief Perform batched 2D integrations of a spline function (described by its spline coefficients) along the dimensions of interest and store results on a subdomain of batch_domain.
793 *
794 * The spline coefficients represent a 2D spline function defined on a B-splines (basis splines). They can be obtained via various methods, such as using a SplineBuilder2D.
795 *
796 * This is not a nD integration. This is a batched 2D integration.
797 * This means that for each element of integrals, the integration is performed with the 2D set of
798 * spline coefficients identified by the same DiscreteElement.
799 *
800 * @param[out] integrals The integrals of the 2D spline function on the subdomain of batch_domain. For practical reasons those are
801 * stored in a ChunkSpan defined on a batch_domain_type. Note that the coordinates of the
802 * points represented by this domain are unused and irrelevant.
803 * @param[in] spline_coef A ChunkSpan storing the 2D spline coefficients.
804 */
805 template <class Layout1, class Layout2>
806 void integrate(
807 ddc::ChunkSpan<double, batch_domain_type, Layout1, memory_space> const integrals,
808 ddc::ChunkSpan<double const, batched_spline_domain_type, Layout2, memory_space> const
809 spline_coef) const
810 {
811 batch_domain_type batch_domain(integrals.domain());
812 ddc::Chunk values1_alloc(
813 ddc::DiscreteDomain<bsplines_type1>(spline_coef.domain()),
814 ddc::KokkosAllocator<double, memory_space>());
815 ddc::ChunkSpan values1 = values1_alloc.span_view();
816 ddc::integrals(exec_space(), values1);
817 ddc::Chunk values2_alloc(
818 ddc::DiscreteDomain<bsplines_type2>(spline_coef.domain()),
819 ddc::KokkosAllocator<double, memory_space>());
820 ddc::ChunkSpan values2 = values2_alloc.span_view();
821 ddc::integrals(exec_space(), values2);
822
823 ddc::parallel_for_each(
824 "ddc_splines_integrate_bsplines",
825 exec_space(),
826 batch_domain,
827 KOKKOS_LAMBDA(typename batch_domain_type::discrete_element_type const j) {
828 integrals(j) = 0;
829 for (typename spline_domain_type1::discrete_element_type const i1 :
830 values1.domain()) {
831 for (typename spline_domain_type2::discrete_element_type const i2 :
832 values2.domain()) {
833 integrals(j) += spline_coef(i1, i2, j) * values1(i1) * values2(i2);
834 }
835 }
836 });
837 }
838
839private:
840 /**
841 * @brief Evaluate the function on B-splines at the coordinate given.
842 *
843 * This function firstly deals with the boundary conditions and calls the SplineEvaluator2D::eval_no_bc function
844 * to evaluate.
845 *
846 * @param[in] coord_eval
847 * The 2D coordinate where we want to evaluate.
848 * @param[in] spline_coef
849 * The B-splines coefficients of the function we want to evaluate.
850 * @param[out] vals1
851 * A ChunkSpan with the not-null values of each function of the spline in the first dimension.
852 * @param[out] vals2
853 * A ChunkSpan with the not-null values of each function of the spline in the second dimension.
854 *
855 * @return A double with the value of the function at the coordinate given.
856 *
857 * @see SplineBoundaryValue
858 */
859 template <class Layout, class... CoordsDims>
860 KOKKOS_INLINE_FUNCTION double eval(
861 ddc::Coordinate<CoordsDims...> coord_eval,
862 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
863 spline_coef) const
864 {
865 using Dim1 = continuous_dimension_type1;
866 using Dim2 = continuous_dimension_type2;
867 if constexpr (bsplines_type1::is_periodic()) {
868 if (ddc::get<Dim1>(coord_eval) < ddc::discrete_space<bsplines_type1>().rmin()
869 || ddc::get<Dim1>(coord_eval) > ddc::discrete_space<bsplines_type1>().rmax()) {
870 ddc::get<Dim1>(coord_eval)
871 -= Kokkos::floor(
872 (ddc::get<Dim1>(coord_eval)
873 - ddc::discrete_space<bsplines_type1>().rmin())
874 / ddc::discrete_space<bsplines_type1>().length())
875 * ddc::discrete_space<bsplines_type1>().length();
876 }
877 }
878 if constexpr (bsplines_type2::is_periodic()) {
879 if (ddc::get<Dim2>(coord_eval) < ddc::discrete_space<bsplines_type2>().rmin()
880 || ddc::get<Dim2>(coord_eval) > ddc::discrete_space<bsplines_type2>().rmax()) {
881 ddc::get<Dim2>(coord_eval)
882 -= Kokkos::floor(
883 (ddc::get<Dim2>(coord_eval)
884 - ddc::discrete_space<bsplines_type2>().rmin())
885 / ddc::discrete_space<bsplines_type2>().length())
886 * ddc::discrete_space<bsplines_type2>().length();
887 }
888 }
889 if constexpr (!bsplines_type1::is_periodic()) {
890 if (ddc::get<Dim1>(coord_eval) < ddc::discrete_space<bsplines_type1>().rmin()) {
891 return m_lower_extrap_rule_1(coord_eval, spline_coef);
892 }
893 if (ddc::get<Dim1>(coord_eval) > ddc::discrete_space<bsplines_type1>().rmax()) {
894 return m_upper_extrap_rule_1(coord_eval, spline_coef);
895 }
896 }
897 if constexpr (!bsplines_type2::is_periodic()) {
898 if (ddc::get<Dim2>(coord_eval) < ddc::discrete_space<bsplines_type2>().rmin()) {
899 return m_lower_extrap_rule_2(coord_eval, spline_coef);
900 }
901 if (ddc::get<Dim2>(coord_eval) > ddc::discrete_space<bsplines_type2>().rmax()) {
902 return m_upper_extrap_rule_2(coord_eval, spline_coef);
903 }
904 }
905 return eval_no_bc<eval_type, eval_type>(
906 ddc::Coordinate<continuous_dimension_type1, continuous_dimension_type2>(
907 ddc::get<Dim1>(coord_eval),
908 ddc::get<Dim2>(coord_eval)),
909 spline_coef);
910 }
911
912 /**
913 * @brief Evaluate the function or its derivative at the coordinate given.
914 *
915 * @param[in] coord_eval
916 * The coordinate where we want to evaluate.
917 * @param[in] splne_coef
918 * The B-splines coefficients of the function we want to evaluate.
919 * @tparam EvalType1
920 * A flag indicating if we evaluate the function or its derivative in the first dimension.
921 * The type of this object is either `eval_type` or `eval_deriv_type`.
922 * @tparam EvalType2
923 * A flag indicating if we evaluate the function or its derivative in the second dimension.
924 * The type of this object is either `eval_type` or `eval_deriv_type`.
925 */
926 template <class EvalType1, class EvalType2, class Layout, class... CoordsDims>
927 KOKKOS_INLINE_FUNCTION double eval_no_bc(
928 ddc::Coordinate<CoordsDims...> const& coord_eval,
929 ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
930 spline_coef) const
931 {
932 static_assert(
933 std::is_same_v<EvalType1, eval_type> || std::is_same_v<EvalType1, eval_deriv_type>);
934 static_assert(
935 std::is_same_v<EvalType2, eval_type> || std::is_same_v<EvalType2, eval_deriv_type>);
936 ddc::DiscreteElement<bsplines_type1> jmin1;
937 ddc::DiscreteElement<bsplines_type2> jmin2;
938
939 std::array<double, bsplines_type1::degree() + 1> vals1_ptr;
940 Kokkos::mdspan<double, Kokkos::extents<std::size_t, bsplines_type1::degree() + 1>> const
941 vals1(vals1_ptr.data());
942 std::array<double, bsplines_type2::degree() + 1> vals2_ptr;
943 Kokkos::mdspan<double, Kokkos::extents<std::size_t, bsplines_type2::degree() + 1>> const
944 vals2(vals2_ptr.data());
945 ddc::Coordinate<continuous_dimension_type1> const coord_eval_interest1
946 = ddc::select<continuous_dimension_type1>(coord_eval);
947 ddc::Coordinate<continuous_dimension_type2> const coord_eval_interest2
948 = ddc::select<continuous_dimension_type2>(coord_eval);
949
950 if constexpr (std::is_same_v<EvalType1, eval_type>) {
951 jmin1 = ddc::discrete_space<bsplines_type1>().eval_basis(vals1, coord_eval_interest1);
952 } else if constexpr (std::is_same_v<EvalType1, eval_deriv_type>) {
953 jmin1 = ddc::discrete_space<bsplines_type1>().eval_deriv(vals1, coord_eval_interest1);
954 }
955 if constexpr (std::is_same_v<EvalType2, eval_type>) {
956 jmin2 = ddc::discrete_space<bsplines_type2>().eval_basis(vals2, coord_eval_interest2);
957 } else if constexpr (std::is_same_v<EvalType2, eval_deriv_type>) {
958 jmin2 = ddc::discrete_space<bsplines_type2>().eval_deriv(vals2, coord_eval_interest2);
959 }
960
961 double y = 0.0;
962 for (std::size_t i = 0; i < bsplines_type1::degree() + 1; ++i) {
963 for (std::size_t j = 0; j < bsplines_type2::degree() + 1; ++j) {
964 y += spline_coef(ddc::DiscreteElement<
965 bsplines_type1,
966 bsplines_type2>(jmin1 + i, jmin2 + j))
967 * vals1[i] * vals2[j];
968 }
969 }
970 return y;
971 }
972};
973
974} // namespace ddc
friend class DiscreteDomain
A class to evaluate, differentiate or integrate a 2D spline function.
void deriv_dim_1(ddc::ChunkSpan< double, batched_evaluation_domain_type, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, batched_evaluation_domain_type, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout3, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) on a mesh along first dimensi...
void deriv(ddc::ChunkSpan< double, batched_evaluation_domain_type, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, batched_evaluation_domain_type, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout3, memory_space > const spline_coef) const
Differentiate spline function (described by its spline coefficients) on a mesh along a specified dime...
KOKKOS_FUNCTION double deriv_dim_2(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 s...
void deriv_dim_2(ddc::ChunkSpan< double, batched_evaluation_domain_type, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, batched_evaluation_domain_type, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout3, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) on a mesh along second dimens...
KOKKOS_FUNCTION double deriv_1_and_2(ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Cross-differentiate 2D spline function (described by its spline coefficients) at a given coordinate.
SplineEvaluator2D(SplineEvaluator2D const &x)=default
Copy-constructs.
SplineEvaluator2D & operator=(SplineEvaluator2D const &x)=default
Copy-assigns.
void deriv2(ddc::ChunkSpan< double, batched_evaluation_domain_type, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, batched_evaluation_domain_type, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout3, memory_space > const spline_coef) const
Double-differentiate 2D spline function (described by its spline coefficients) on a mesh along specif...
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.
void deriv_1_and_2(ddc::ChunkSpan< double, batched_evaluation_domain_type, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, batched_evaluation_domain_type, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout3, memory_space > const spline_coef) const
Cross-differentiate 2D spline function (described by its spline coefficients) on a mesh along dimensi...
KOKKOS_FUNCTION double deriv(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 a...
~SplineEvaluator2D()=default
Destructs.
upper_extrapolation_rule_2_type upper_extrapolation_rule_dim_2() const
Get the upper extrapolation rule along the second dimension.
lower_extrapolation_rule_2_type lower_extrapolation_rule_dim_2() const
Get the lower 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.
void integrate(ddc::ChunkSpan< double, batch_domain_type, Layout1, memory_space > const integrals, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout2, memory_space > const spline_coef) const
Perform batched 2D integrations of a spline function (described by its spline coefficients) along the...
void operator()(ddc::ChunkSpan< double, batched_evaluation_domain_type, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, batched_evaluation_domain_type, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type, Layout3, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) on a mesh.
SplineEvaluator2D(SplineEvaluator2D &&x)=default
Move-constructs.
KOKKOS_FUNCTION double deriv2(ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Double-differentiate 2D spline function (described by its spline coefficients) at a given coordinate ...
lower_extrapolation_rule_1_type lower_extrapolation_rule_dim_1() const
Get the lower extrapolation rule along the first dimension.
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.
KOKKOS_FUNCTION double deriv_dim_1(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 f...
SplineEvaluator2D & operator=(SplineEvaluator2D &&x)=default
Move-assigns.
The top-level namespace of DDC.