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