DDC 0.5.2
Loading...
Searching...
No Matches
spline_builder_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 <cassert>
8#include <cstddef>
9#include <optional>
10#include <type_traits>
11
12#include <ddc/ddc.hpp>
13
14#include "spline_builder.hpp"
15
16namespace ddc {
17
18/**
19 * @brief A class for creating a 2D spline approximation of a function.
20 *
21 * A class which contains an operator () which can be used to build a 2D spline approximation
22 * of a function. A 2D spline approximation uses a cross-product between two 1D SplineBuilder.
23 *
24 * @see SplineBuilder
25 */
26template <
27 class ExecSpace,
28 class MemorySpace,
29 class BSpline1,
30 class BSpline2,
31 class DDimI1,
32 class DDimI2,
33 ddc::BoundCond BcLower1,
34 ddc::BoundCond BcUpper1,
35 ddc::BoundCond BcLower2,
36 ddc::BoundCond BcUpper2,
37 ddc::SplineSolver Solver>
39{
40public:
41 /// @brief The type of the Kokkos execution space used by this class.
42 using exec_space = ExecSpace;
43
44 /// @brief The type of the Kokkos memory space used by this class.
45 using memory_space = MemorySpace;
46
47 /// @brief The type of the SplineBuilder used by this class to spline-approximate along first dimension.
48 using builder_type1 = ddc::
49 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
50
51 /// @brief The type of the SplineBuilder used by this class to spline-approximate along second dimension.
52 using builder_type2 = ddc::
53 SplineBuilder<ExecSpace, MemorySpace, BSpline2, DDimI2, BcLower2, BcUpper2, Solver>;
54
55 /// @brief The type of the SplineBuilder used by this class to spline-approximate the second-dimension-derivatives along first dimension.
56 using builder_deriv_type1 = ddc::
57 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
58
59 /// @brief The type of the first interpolation continuous dimension.
60 using continuous_dimension_type1 = typename builder_type1::continuous_dimension_type;
61
62 /// @brief The type of the second interpolation continuous dimension.
63 using continuous_dimension_type2 = typename builder_type2::continuous_dimension_type;
64
65 /// @brief The type of the first interpolation discrete dimension.
66 using interpolation_discrete_dimension_type1 =
67 typename builder_type1::interpolation_discrete_dimension_type;
68
69 /// @brief The type of the second interpolation discrete dimension.
70 using interpolation_discrete_dimension_type2 =
71 typename builder_type2::interpolation_discrete_dimension_type;
72
73 /// @brief The type of the B-splines in the first dimension.
74 using bsplines_type1 = typename builder_type1::bsplines_type;
75
76 /// @brief The type of the B-splines in the second dimension.
77 using bsplines_type2 = typename builder_type2::bsplines_type;
78
79 /// @brief The type of the Deriv domain on boundaries in the first dimension.
80 using deriv_type1 = typename builder_type1::deriv_type;
81
82 /// @brief The type of the Deriv domain on boundaries in the second dimension.
83 using deriv_type2 = typename builder_type2::deriv_type;
84
85 /// @brief The type of the domain for the interpolation mesh in the first dimension.
86 using interpolation_domain_type1 =
87 typename builder_type1::interpolation_discrete_dimension_type;
88
89 /// @brief The type of the domain for the interpolation mesh in the second dimension.
90 using interpolation_domain_type2 =
91 typename builder_type2::interpolation_discrete_dimension_type;
92
93 /// @brief The type of the domain for the interpolation mesh in the 2D dimension.
94 using interpolation_domain_type = ddc::DiscreteDomain<
95 interpolation_discrete_dimension_type1,
96 interpolation_discrete_dimension_type2>;
97
98 /**
99 * @brief The type of the whole domain representing interpolation points.
100 *
101 * @tparam The batched discrete domain on which the interpolation points are defined.
102 */
103 template <
104 class BatchedInterpolationDDom,
105 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
106 using batched_interpolation_domain_type = BatchedInterpolationDDom;
107
108 /**
109 * @brief The type of the batch domain (obtained by removing the dimensions of interest
110 * from the whole domain).
111 *
112 * @tparam The batched discrete domain on which the interpolation points are defined.
113 *
114 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z> and dimensions of interest X and Y,
115 * this is DiscreteDomain<Z>.
116 */
117 template <
118 class BatchedInterpolationDDom,
119 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
120 using batch_domain_type = ddc::remove_dims_of_t<
121 BatchedInterpolationDDom,
122 interpolation_discrete_dimension_type1,
123 interpolation_discrete_dimension_type2>;
124
125 /**
126 * @brief The type of the whole spline domain (cartesian product of 2D spline domain
127 * and batch domain) preserving the order of dimensions.
128 *
129 * @tparam The batched discrete domain on which the interpolation points are defined.
130 *
131 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z> and dimensions of interest X and Y
132 * (associated to B-splines tags BSplinesX and BSplinesY), this is DiscreteDomain<BSplinesX, BSplinesY, Z>
133 */
134 template <
135 class BatchedInterpolationDDom,
136 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
137 using batched_spline_domain_type
138 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
139 ddc::to_type_seq_t<BatchedInterpolationDDom>,
140 ddc::detail::TypeSeq<
141 interpolation_discrete_dimension_type1,
142 interpolation_discrete_dimension_type2>,
143 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
144
145 /**
146 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
147 * and the associated batch domain) in the first dimension, preserving the order of dimensions.
148 *
149 * @tparam The batched discrete domain on which the interpolation points are defined.
150 *
151 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z> and dimensions of interest X and Y,
152 * this is DiscreteDomain<Deriv<X>, Y, Z>.
153 */
154 template <
155 class BatchedInterpolationDDom,
156 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
157 using batched_derivs_domain_type1 =
158 typename builder_type1::template batched_derivs_domain_type<BatchedInterpolationDDom>;
159
160 /**
161 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
162 * and the associated batch domain) in the second dimension, preserving the order of dimensions.
163 *
164 * @tparam The batched discrete domain on which the interpolation points are defined.
165 *
166 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z> and dimensions of interest X and Y,
167 * this is DiscreteDomain<X, Deriv<Y>, Z>.
168 */
169 template <
170 class BatchedInterpolationDDom,
171 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
172 using batched_derivs_domain_type2 = ddc::replace_dim_of_t<
173 BatchedInterpolationDDom,
174 interpolation_discrete_dimension_type2,
175 deriv_type2>;
176
177 /**
178 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
179 * and the batch domain) in the second dimension, preserving the order of dimensions.
180 *
181 * @tparam The batched discrete domain on which the interpolation points are defined.
182 *
183 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z> and dimensions of interest X and Y,
184 * this is DiscreteDomain<Deriv<X>, Deriv<Y>, Z>.
185 */
186 template <
187 class BatchedInterpolationDDom,
188 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
189 using batched_derivs_domain_type
190 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
191 ddc::to_type_seq_t<BatchedInterpolationDDom>,
192 ddc::detail::TypeSeq<
193 interpolation_discrete_dimension_type1,
194 interpolation_discrete_dimension_type2>,
195 ddc::detail::TypeSeq<deriv_type1, deriv_type2>>>;
196
197private:
198 builder_type1 m_spline_builder1;
199 builder_deriv_type1 m_spline_builder_deriv1;
200 builder_type2 m_spline_builder2;
201
202public:
203 /**
204 * @brief Build a SplineBuilder2D acting on interpolation_domain.
205 *
206 * @param interpolation_domain The domain on which the interpolation points are defined, without the batch dimensions.
207 *
208 * @param cols_per_chunk A parameter used by the slicer (internal to the solver) to define the size
209 * of a chunk of right-hand-sides of the linear problem to be computed in parallel (chunks are treated
210 * by the linear solver one-after-the-other).
211 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
212 *
213 * @param preconditioner_max_block_size A parameter used by the slicer (internal to the solver) to
214 * define the size of a block used by the Block-Jacobi preconditioner.
215 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
216 *
217 * @see SplinesLinearProblemSparse
218 */
219 explicit SplineBuilder2D(
220 interpolation_domain_type const& interpolation_domain,
221 std::optional<std::size_t> cols_per_chunk = std::nullopt,
222 std::optional<unsigned int> preconditioner_max_block_size = std::nullopt)
223 : m_spline_builder1(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
224 , m_spline_builder_deriv1(interpolation_domain)
225 , m_spline_builder2(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
226 {
227 }
228
229 /**
230 * @brief Build a SplineBuilder2D acting on the interpolation domain contained in batched_interpolation_domain.
231 *
232 * @param batched_interpolation_domain The domain on which the interpolation points are defined.
233 *
234 * @param cols_per_chunk A parameter used by the slicer (internal to the solver) to define the size
235 * of a chunk of right-hand-sides of the linear problem to be computed in parallel (chunks are treated
236 * by the linear solver one-after-the-other).
237 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
238 *
239 * @param preconditioner_max_block_size A parameter used by the slicer (internal to the solver) to
240 * define the size of a block used by the Block-Jacobi preconditioner.
241 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
242 *
243 * @see SplinesLinearProblemSparse
244 */
245 template <
246 class BatchedInterpolationDDom,
247 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
248 explicit SplineBuilder2D(
249 BatchedInterpolationDDom const& batched_interpolation_domain,
250 std::optional<std::size_t> cols_per_chunk = std::nullopt,
251 std::optional<unsigned int> preconditioner_max_block_size = std::nullopt)
253 interpolation_domain_type(batched_interpolation_domain),
254 cols_per_chunk,
255 preconditioner_max_block_size)
256 {
257 }
258
259 /// @brief Copy-constructor is deleted.
260 SplineBuilder2D(SplineBuilder2D const& x) = delete;
261
262 /**
263 * @brief Move-constructs.
264 *
265 * @param x An rvalue to another SplineBuilder2D.
266 */
267 SplineBuilder2D(SplineBuilder2D&& x) = default;
268
269 /// @brief Destructs.
270 ~SplineBuilder2D() = default;
271
272 /// @brief Copy-assignment is deleted.
273 SplineBuilder2D& operator=(SplineBuilder2D const& x) = delete;
274
275 /** @brief Move-assigns.
276 *
277 * @param x An rvalue to another SplineBuilder.
278 * @return A reference to this object.
279 */
281
282 /**
283 * @brief Get the domain for the 2D interpolation mesh used by this class.
284 *
285 * This is 2D because it is defined along the dimensions of interest.
286 *
287 * @return The 2D domain for the interpolation mesh.
288 */
289 interpolation_domain_type interpolation_domain() const noexcept
290 {
291 return ddc::DiscreteDomain<interpolation_domain_type1, interpolation_domain_type2>(
292 m_spline_builder1.interpolation_domain(),
293 m_spline_builder2.interpolation_domain());
294 }
295
296 /**
297 * @brief Get the whole domain representing interpolation points.
298 *
299 * Values of the function must be provided on this domain in order
300 * to build a spline representation of the function (cartesian product of 2D interpolation_domain and batch_domain).
301 *
302 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
303 *
304 * @return The domain for the interpolation mesh.
305 */
306 template <
307 class BatchedInterpolationDDom,
308 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
309 BatchedInterpolationDDom batched_interpolation_domain(
310 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
311 {
312 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
313 return batched_interpolation_domain;
314 }
315
316 /**
317 * @brief Get the batch domain.
318 *
319 * Obtained by removing the dimensions of interest from the whole interpolation domain.
320 *
321 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
322 *
323 * @return The batch domain.
324 */
325 template <
326 class BatchedInterpolationDDom,
327 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
328 batch_domain_type<BatchedInterpolationDDom> batch_domain(
329 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
330 {
331 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
332 return ddc::remove_dims_of(batched_interpolation_domain, interpolation_domain());
333 }
334
335 /**
336 * @brief Get the 2D domain on which spline coefficients are defined.
337 *
338 * The 2D spline domain corresponding to the dimensions of interest.
339 *
340 * @return The 2D domain for the spline coefficients.
341 */
342 ddc::DiscreteDomain<bsplines_type1, bsplines_type2> spline_domain() const noexcept
343 {
344 return ddc::DiscreteDomain<bsplines_type1, bsplines_type2>(
345 ddc::discrete_space<bsplines_type1>().full_domain(),
346 ddc::discrete_space<bsplines_type2>().full_domain());
347 }
348
349 /**
350 * @brief Get the whole domain on which spline coefficients are defined.
351 *
352 * Spline approximations (spline-transformed functions) are computed on this domain.
353 *
354 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
355 *
356 * @return The domain for the spline coefficients.
357 */
358 template <
359 class BatchedInterpolationDDom,
360 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
361 batched_spline_domain_type<BatchedInterpolationDDom> batched_spline_domain(
362 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
363 {
364 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
365 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
366 ddc::replace_dim_of<
367 interpolation_discrete_dimension_type2,
368 bsplines_type2>(batched_interpolation_domain, spline_domain()),
370 }
371
372 /**
373 * @brief Compute a 2D spline approximation of a function.
374 *
375 * Use the values of a function (defined on
376 * SplineBuilder2D::batched_interpolation_domain) and the derivatives of the
377 * function at the boundaries (in the case of BoundCond::HERMITE only)
378 * to calculate a 2D spline approximation of this function.
379 *
380 * The spline approximation is stored as a ChunkSpan of coefficients
381 * associated with B-splines.
382 *
383 * @param[out] spline
384 * The coefficients of the spline computed by this SplineBuilder.
385 * @param[in] vals
386 * The values of the function at the interpolation mesh.
387 * @param[in] derivs_min1
388 * The values of the derivatives at the lower boundary in the first dimension.
389 * @param[in] derivs_max1
390 * The values of the derivatives at the upper boundary in the first dimension.
391 * @param[in] derivs_min2
392 * The values of the derivatives at the lower boundary in the second dimension.
393 * @param[in] derivs_max2
394 * The values of the derivatives at the upper boundary in the second dimension.
395 * @param[in] mixed_derivs_min1_min2
396 * The values of the the cross-derivatives at the lower boundary in the first dimension
397 * and the lower boundary in the second dimension.
398 * @param[in] mixed_derivs_max1_min2
399 * The values of the the cross-derivatives at the upper boundary in the first dimension
400 * and the lower boundary in the second dimension.
401 * @param[in] mixed_derivs_min1_max2
402 * The values of the the cross-derivatives at the lower boundary in the first dimension
403 * and the upper boundary in the second dimension.
404 * @param[in] mixed_derivs_max1_max2
405 * The values of the the cross-derivatives at the upper boundary in the first dimension
406 * and the upper boundary in the second dimension.
407 */
408 template <class Layout, class BatchedInterpolationDDom>
409 void operator()(
410 ddc::ChunkSpan<
411 double,
412 batched_spline_domain_type<BatchedInterpolationDDom>,
413 Layout,
414 memory_space> spline,
415 ddc::ChunkSpan<double const, BatchedInterpolationDDom, Layout, memory_space> vals,
416 std::optional<ddc::ChunkSpan<
417 double const,
418 batched_derivs_domain_type1<BatchedInterpolationDDom>,
419 Layout,
420 memory_space>> derivs_min1
421 = std::nullopt,
422 std::optional<ddc::ChunkSpan<
423 double const,
424 batched_derivs_domain_type1<BatchedInterpolationDDom>,
425 Layout,
426 memory_space>> derivs_max1
427 = std::nullopt,
428 std::optional<ddc::ChunkSpan<
429 double const,
430 batched_derivs_domain_type2<BatchedInterpolationDDom>,
431 Layout,
432 memory_space>> derivs_min2
433 = std::nullopt,
434 std::optional<ddc::ChunkSpan<
435 double const,
436 batched_derivs_domain_type2<BatchedInterpolationDDom>,
437 Layout,
438 memory_space>> derivs_max2
439 = std::nullopt,
440 std::optional<ddc::ChunkSpan<
441 double const,
442 batched_derivs_domain_type<BatchedInterpolationDDom>,
443 Layout,
444 memory_space>> mixed_derivs_min1_min2
445 = std::nullopt,
446 std::optional<ddc::ChunkSpan<
447 double const,
448 batched_derivs_domain_type<BatchedInterpolationDDom>,
449 Layout,
450 memory_space>> mixed_derivs_max1_min2
451 = std::nullopt,
452 std::optional<ddc::ChunkSpan<
453 double const,
454 batched_derivs_domain_type<BatchedInterpolationDDom>,
455 Layout,
456 memory_space>> mixed_derivs_min1_max2
457 = std::nullopt,
458 std::optional<ddc::ChunkSpan<
459 double const,
460 batched_derivs_domain_type<BatchedInterpolationDDom>,
461 Layout,
462 memory_space>> mixed_derivs_max1_max2
463 = std::nullopt) const;
464};
465
466
467template <
468 class ExecSpace,
469 class MemorySpace,
470 class BSpline1,
471 class BSpline2,
472 class DDimI1,
473 class DDimI2,
479template <class Layout, class BatchedInterpolationDDom>
480void SplineBuilder2D<
481 ExecSpace,
482 MemorySpace,
483 BSpline1,
484 BSpline2,
485 DDimI1,
486 DDimI2,
487 BcLower1,
488 BcUpper1,
489 BcLower2,
490 BcUpper2,
491 Solver>::
492operator()(
493 ddc::ChunkSpan<
494 double,
495 batched_spline_domain_type<BatchedInterpolationDDom>,
496 Layout,
497 memory_space> spline,
498 ddc::ChunkSpan<double const, BatchedInterpolationDDom, Layout, memory_space> vals,
499 std::optional<ddc::ChunkSpan<
500 double const,
501 batched_derivs_domain_type1<BatchedInterpolationDDom>,
502 Layout,
503 memory_space>> const derivs_min1,
504 std::optional<ddc::ChunkSpan<
505 double const,
506 batched_derivs_domain_type1<BatchedInterpolationDDom>,
507 Layout,
508 memory_space>> const derivs_max1,
509 std::optional<ddc::ChunkSpan<
510 double const,
511 batched_derivs_domain_type2<BatchedInterpolationDDom>,
512 Layout,
513 memory_space>> const derivs_min2,
514 std::optional<ddc::ChunkSpan<
515 double const,
516 batched_derivs_domain_type2<BatchedInterpolationDDom>,
517 Layout,
518 memory_space>> const derivs_max2,
519 std::optional<ddc::ChunkSpan<
520 double const,
521 batched_derivs_domain_type<BatchedInterpolationDDom>,
522 Layout,
523 memory_space>> const mixed_derivs_min1_min2,
524 std::optional<ddc::ChunkSpan<
525 double const,
526 batched_derivs_domain_type<BatchedInterpolationDDom>,
527 Layout,
528 memory_space>> const mixed_derivs_max1_min2,
529 std::optional<ddc::ChunkSpan<
530 double const,
531 batched_derivs_domain_type<BatchedInterpolationDDom>,
532 Layout,
533 memory_space>> const mixed_derivs_min1_max2,
534 std::optional<ddc::ChunkSpan<
535 double const,
536 batched_derivs_domain_type<BatchedInterpolationDDom>,
537 Layout,
538 memory_space>> const mixed_derivs_max1_max2) const
539{
540 auto const batched_interpolation_domain = vals.domain();
541
542 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
543
544 // TODO: perform computations along dimension 1 on different streams ?
545 // Spline1-approximate derivs_min2 (to spline1_deriv_min)
546
547 auto const batched_interpolation_deriv_domain
548 = ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
549 batched_interpolation_domain,
550 ddc::DiscreteDomain<deriv_type2>(
551 ddc::DiscreteElement<deriv_type2>(1),
552 ddc::DiscreteVector<deriv_type2>(bsplines_type2::degree() / 2)));
553
554 ddc::Chunk spline1_deriv_min_alloc(
555 m_spline_builder_deriv1.batched_spline_domain(batched_interpolation_deriv_domain),
556 ddc::KokkosAllocator<double, MemorySpace>());
557 auto spline1_deriv_min = spline1_deriv_min_alloc.span_view();
558 auto spline1_deriv_min_opt = std::optional(spline1_deriv_min.span_cview());
559 if constexpr (BcLower2 == ddc::BoundCond::HERMITE) {
560 m_spline_builder_deriv1(
561 spline1_deriv_min,
562 *derivs_min2,
563 mixed_derivs_min1_min2,
564 mixed_derivs_max1_min2);
565 } else {
566 spline1_deriv_min_opt = std::nullopt;
567 }
568
569 // Spline1-approximate vals (to spline1)
570 ddc::Chunk spline1_alloc(
571 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
572 ddc::KokkosAllocator<double, MemorySpace>());
573 ddc::ChunkSpan const spline1 = spline1_alloc.span_view();
574
575 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
576
577 // Spline1-approximate derivs_max2 (to spline1_deriv_max)
578 ddc::Chunk spline1_deriv_max_alloc(
579 m_spline_builder_deriv1.batched_spline_domain(batched_interpolation_deriv_domain),
580 ddc::KokkosAllocator<double, MemorySpace>());
581 auto spline1_deriv_max = spline1_deriv_max_alloc.span_view();
582 auto spline1_deriv_max_opt = std::optional(spline1_deriv_max.span_cview());
583 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE) {
584 m_spline_builder_deriv1(
585 spline1_deriv_max,
586 *derivs_max2,
587 mixed_derivs_min1_max2,
588 mixed_derivs_max1_max2);
589 } else {
590 spline1_deriv_max_opt = std::nullopt;
591 }
592
593 // Spline2-approximate spline1
594 m_spline_builder2(spline, spline1.span_cview(), spline1_deriv_min_opt, spline1_deriv_max_opt);
595}
596
597} // namespace ddc
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
A class for creating a 2D spline approximation of a function.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type< BatchedInterpolationDDom >, Layout, memory_space > spline, ddc::ChunkSpan< double const, BatchedInterpolationDDom, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2=std::nullopt) const
Compute a 2D spline approximation of a function.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2 > spline_domain() const noexcept
Get the 2D domain on which spline coefficients are defined.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
SplineBuilder2D(SplineBuilder2D &&x)=default
Move-constructs.
SplineBuilder2D & operator=(SplineBuilder2D &&x)=default
Move-assigns.
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.
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.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
~SplineBuilder2D()=default
Destructs.
SplineBuilder2D(SplineBuilder2D const &x)=delete
Copy-constructor is deleted.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 2D interpolation mesh used by this class.
SplineBuilder2D(BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder2D acting on the interpolation domain contained in batched_interpolation_domain.
SplineBuilder2D & operator=(SplineBuilder2D const &x)=delete
Copy-assignment is deleted.
A class for creating a spline approximation of a function.
The top-level namespace of DDC.
BoundCond
An enum representing a spline boundary condition.
@ HERMITE
Hermite boundary condition.
SplineSolver
An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.