DDC 0.12.0
Loading...
Searching...
No Matches
spline_builder_3d.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
11#include <ddc/ddc.hpp>
12
16
17namespace ddc {
18
19/**
20 * @brief A class for creating a 3D spline approximation of a function.
21 *
22 * A class which contains an operator () which can be used to build a 3D spline approximation
23 * of a function. A 3D spline approximation uses a cross-product between three 1D SplineBuilder.
24 *
25 * @see SplineBuilder
26 */
27template <
28 class ExecSpace,
29 class MemorySpace,
30 class BSpline1,
31 class BSpline2,
32 class BSpline3,
33 class DDimI1,
34 class DDimI2,
35 class DDimI3,
36 ddc::BoundCond BcLower1,
37 ddc::BoundCond BcUpper1,
38 ddc::BoundCond BcLower2,
39 ddc::BoundCond BcUpper2,
40 ddc::BoundCond BcLower3,
41 ddc::BoundCond BcUpper3,
42 ddc::SplineSolver Solver>
44{
45public:
46 /// @brief The type of the Kokkos execution space used by this class.
47 using exec_space = ExecSpace;
48
49 /// @brief The type of the Kokkos memory space used by this class.
50 using memory_space = MemorySpace;
51
52 /// @brief The type of the SplineBuilder used by this class to spline-approximate along first dimension.
53 using builder_type1 = ddc::
54 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
55
56 /// @brief The type of SplineBuilder used by this class to spline-approximate along the second and third dimensions.
57 using builder_type_2_3 = ddc::SplineBuilder2D<
58 ExecSpace,
59 MemorySpace,
60 BSpline2,
61 BSpline3,
62 DDimI2,
63 DDimI3,
64 BcLower2,
65 BcUpper2,
66 BcLower3,
67 BcUpper3,
68 Solver>;
69
70 /// @brief The type of the first interpolation continuous dimension.
71 using continuous_dimension_type1 = typename builder_type1::continuous_dimension_type;
72
73 /// @brief The type of the second interpolation continuous dimension.
74 using continuous_dimension_type2 = typename builder_type_2_3::continuous_dimension_type1;
75
76 /// @brief The type of the third interpolation continuous dimension.
77 using continuous_dimension_type3 = typename builder_type_2_3::continuous_dimension_type2;
78
79 /// @brief The type of the first interpolation discrete dimension.
80 using interpolation_discrete_dimension_type1 =
81 typename builder_type1::interpolation_discrete_dimension_type;
82
83 /// @brief The type of the second interpolation discrete dimension.
84 using interpolation_discrete_dimension_type2 =
85 typename builder_type_2_3::interpolation_discrete_dimension_type1;
86
87 /// @brief The type of the third interpolation discrete dimension.
88 using interpolation_discrete_dimension_type3 =
89 typename builder_type_2_3::interpolation_discrete_dimension_type2;
90
91 /// @brief The type of the B-splines in the first dimension.
92 using bsplines_type1 = typename builder_type1::bsplines_type;
93
94 /// @brief The type of the B-splines in the second dimension.
95 using bsplines_type2 = typename builder_type_2_3::bsplines_type1;
96
97 /// @brief The type of the B-splines in the third dimension.
98 using bsplines_type3 = typename builder_type_2_3::bsplines_type2;
99
100 /// @brief The type of the Deriv domain on boundaries in the first dimension.
101 using deriv_type1 = typename builder_type1::deriv_type;
102
103 /// @brief The type of the Deriv domain on boundaries in the second dimension.
104 using deriv_type2 = typename builder_type_2_3::deriv_type1;
105
106 /// @brief The type of the Deriv domain on boundaries in the third dimension.
107 using deriv_type3 = typename builder_type_2_3::deriv_type2;
108
109 /// @brief The type of the domain for the interpolation mesh in the first dimension.
110 using interpolation_domain_type1 =
111 typename builder_type1::interpolation_discrete_dimension_type;
112
113 /// @brief The type of the domain for the interpolation mesh in the second dimension.
114 using interpolation_domain_type2 =
115 typename builder_type_2_3::interpolation_discrete_dimension_type1;
116
117 /// @brief The type of the domain for the interpolation mesh in the third dimension.
118 using interpolation_domain_type3 =
119 typename builder_type_2_3::interpolation_discrete_dimension_type2;
120
121 /// @brief The type of the domain for the interpolation mesh in the 3D dimension.
122 using interpolation_domain_type = ddc::DiscreteDomain<
123 interpolation_discrete_dimension_type1,
124 interpolation_discrete_dimension_type2,
125 interpolation_discrete_dimension_type3>;
126
127 /**
128 * @brief The type of the whole domain representing interpolation points.
129 *
130 * @tparam The batched discrete domain on which the interpolation points are defined.
131 */
132 template <concepts::discrete_domain BatchedInterpolationDDom>
133 using batched_interpolation_domain_type = BatchedInterpolationDDom;
134
135 /**
136 * @brief The type of the batch domain (obtained by removing the dimensions of interest
137 * from the whole domain).
138 *
139 * @tparam The batched discrete domain on which the interpolation points are defined.
140 *
141 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
142 * this is DiscreteDomain<T>.
143 */
144 template <concepts::discrete_domain BatchedInterpolationDDom>
145 using batch_domain_type = ddc::remove_dims_of_t<
146 BatchedInterpolationDDom,
147 interpolation_discrete_dimension_type1,
148 interpolation_discrete_dimension_type2,
149 interpolation_discrete_dimension_type3>;
150
151 /**
152 * @brief The type of the whole spline domain (cartesian product of 3D spline domain
153 * and batch domain) preserving the order of dimensions.
154 *
155 * @tparam The batched discrete domain on which the interpolation points are defined.
156 *
157 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z
158 * (associated to B-splines tags BSplinesX, BSplinesY and BSplinesZ), this is DiscreteDomain<BSplinesX, BSplinesY, BSplinesZ, T>
159 */
160 template <concepts::discrete_domain BatchedInterpolationDDom>
161 using batched_spline_domain_type
162 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
163 ddc::to_type_seq_t<BatchedInterpolationDDom>,
164 ddc::detail::TypeSeq<
165 interpolation_discrete_dimension_type1,
166 interpolation_discrete_dimension_type2,
167 interpolation_discrete_dimension_type3>,
168 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2, bsplines_type3>>>;
169
170 /**
171 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
172 * and the associated batch domain) in the first dimension, preserving the order of dimensions.
173 *
174 * @tparam The batched discrete domain on which the interpolation points are defined.
175 *
176 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
177 * this is DiscreteDomain<Deriv<X>, Y, Z, T>.
178 */
179 template <concepts::discrete_domain BatchedInterpolationDDom>
180 using batched_derivs_domain_type1 = ddc::replace_dim_of_t<
181 BatchedInterpolationDDom,
182 interpolation_discrete_dimension_type1,
183 deriv_type1>;
184
185 /**
186 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
187 * and the associated batch domain) in the second dimension, preserving the order of dimensions.
188 *
189 * @tparam The batched discrete domain on which the interpolation points are defined.
190 *
191 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
192 * this is DiscreteDomain<X, Deriv<Y>, Z, T>.
193 */
194 template <concepts::discrete_domain BatchedInterpolationDDom>
195 using batched_derivs_domain_type2 = ddc::replace_dim_of_t<
196 BatchedInterpolationDDom,
197 interpolation_discrete_dimension_type2,
198 deriv_type2>;
199
200 /**
201 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
202 * and the associated batch domain) in the third dimension, preserving the order of dimensions.
203 *
204 * @tparam The batched discrete domain on which the interpolation points are defined.
205 *
206 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
207 * this is DiscreteDomain<X, Y, Deriv<Z>, T>.
208 */
209 template <concepts::discrete_domain BatchedInterpolationDDom>
210 using batched_derivs_domain_type3 = ddc::replace_dim_of_t<
211 BatchedInterpolationDDom,
212 interpolation_discrete_dimension_type3,
213 deriv_type3>;
214
215 /**
216 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
217 * and the associated batch domain) in the first and second dimensions, preserving the order
218 * of dimensions.
219 *
220 * @tparam The batched discrete domain on which the interpolation points are defined.
221 *
222 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
223 * this is DiscreteDomain<Deriv<X>, Deriv<Y>, Z, T>.
224 */
225 template <concepts::discrete_domain BatchedInterpolationDDom>
226 using batched_derivs_domain_type1_2 = ddc::replace_dim_of_t<
227 ddc::replace_dim_of_t<
228 BatchedInterpolationDDom,
229 interpolation_discrete_dimension_type1,
230 deriv_type1>,
231 interpolation_domain_type2,
232 deriv_type2>;
233
234 /**
235 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
236 * and the associated batch domain) in the second and third dimensions, preserving the order
237 * of dimensions.
238 *
239 * @tparam The batched discrete domain on which the interpolation points are defined.
240 *
241 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
242 * this is DiscreteDomain<X, Deriv<Y>, Deriv<Z>, T>.
243 */
244 template <concepts::discrete_domain BatchedInterpolationDDom>
245 using batched_derivs_domain_type2_3 = ddc::replace_dim_of_t<
246 ddc::replace_dim_of_t<
247 BatchedInterpolationDDom,
248 interpolation_discrete_dimension_type2,
249 deriv_type2>,
250 interpolation_domain_type3,
251 deriv_type3>;
252
253 /**
254 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
255 * and the associated batch domain) in the first and third dimensions, preserving the order
256 * of dimensions.
257 *
258 * @tparam The batched discrete domain on which the interpolation points are defined.
259 *
260 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
261 * this is DiscreteDomain<Deriv<X>, Y, Deriv<Z>, T>.
262 */
263 template <concepts::discrete_domain BatchedInterpolationDDom>
264 using batched_derivs_domain_type1_3 = ddc::replace_dim_of_t<
265 ddc::replace_dim_of_t<
266 BatchedInterpolationDDom,
267 interpolation_discrete_dimension_type1,
268 deriv_type1>,
269 interpolation_domain_type3,
270 deriv_type3>;
271
272 /**
273 * @brief The type of the whole Derivs domain (cartesian product of the 3D Deriv domain
274 * and the batch domain), preserving the order of dimensions.
275 *
276 * @tparam The batched discrete domain on which the interpolation points are defined.
277 *
278 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
279 * this is DiscreteDomain<Deriv<X>, Deriv<Y>, Deriv<Z>, T>.
280 */
281 template <concepts::discrete_domain BatchedInterpolationDDom>
282 using batched_derivs_domain_type
283 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
284 ddc::to_type_seq_t<BatchedInterpolationDDom>,
285 ddc::detail::TypeSeq<
286 interpolation_discrete_dimension_type1,
287 interpolation_discrete_dimension_type2,
288 interpolation_discrete_dimension_type3>,
289 ddc::detail::TypeSeq<deriv_type1, deriv_type2, deriv_type3>>>;
290
291private:
292 builder_type1 m_spline_builder1;
293 builder_type_2_3 m_spline_builder_2_3;
294
295public:
296 /**
297 * @brief Build a SplineBuilder3D acting on interpolation_domain.
298 *
299 * @param interpolation_domain The domain on which the interpolation points are defined, without the batch dimensions.
300 *
301 * @param cols_per_chunk A parameter used by the slicer (internal to the solver) to define the size
302 * of a chunk of right-hand-sides of the linear problem to be computed in parallel (chunks are treated
303 * by the linear solver one-after-the-other).
304 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
305 *
306 * @param preconditioner_max_block_size A parameter used by the slicer (internal to the solver) to
307 * define the size of a block used by the Block-Jacobi preconditioner.
308 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
309 *
310 * @see SplinesLinearProblemSparse
311 */
312 explicit SplineBuilder3D(
313 interpolation_domain_type const& interpolation_domain,
314 std::optional<std::size_t> cols_per_chunk = std::nullopt,
315 std::optional<unsigned int> preconditioner_max_block_size = std::nullopt)
316 : m_spline_builder1(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
317 , m_spline_builder_2_3(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
318 {
319 }
320
321 /**
322 * @brief Build a SplineBuilder3D acting on the interpolation domain contained in batched_interpolation_domain.
323 *
324 * @param batched_interpolation_domain The domain on which the interpolation points are defined.
325 *
326 * @param cols_per_chunk A parameter used by the slicer (internal to the solver) to define the size
327 * of a chunk of right-hand-sides of the linear problem to be computed in parallel (chunks are treated
328 * by the linear solver one-after-the-other).
329 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
330 *
331 * @param preconditioner_max_block_size A parameter used by the slicer (internal to the solver) to
332 * define the size of a block used by the Block-Jacobi preconditioner.
333 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
334 *
335 * @see SplinesLinearProblemSparse
336 */
337 template <concepts::discrete_domain BatchedInterpolationDDom>
338 explicit SplineBuilder3D(
339 BatchedInterpolationDDom const& batched_interpolation_domain,
340 std::optional<std::size_t> cols_per_chunk = std::nullopt,
341 std::optional<unsigned int> preconditioner_max_block_size = std::nullopt)
343 interpolation_domain_type(batched_interpolation_domain),
344 cols_per_chunk,
345 preconditioner_max_block_size)
346 {
347 }
348
349 /// @brief Copy-constructor is deleted.
350 SplineBuilder3D(SplineBuilder3D const& x) = delete;
351
352 /**
353 * @brief Move-constructs.
354 *
355 * @param x An rvalue to another SplineBuilder3D.
356 */
357 SplineBuilder3D(SplineBuilder3D&& x) = default;
358
359 /// @brief Destructs.
360 ~SplineBuilder3D() = default;
361
362 /// @brief Copy-assignment is deleted.
363 SplineBuilder3D& operator=(SplineBuilder3D const& x) = delete;
364
365 /** @brief Move-assigns.
366 *
367 * @param x An rvalue to another SplineBuilder.
368 * @return A reference to this object.
369 */
371
372 /**
373 * @brief Get the domain for the 3D interpolation mesh used by this class.
374 *
375 * This is 3D because it is defined along the dimensions of interest.
376 *
377 * @return The 3D domain for the interpolation mesh.
378 */
379 interpolation_domain_type interpolation_domain() const noexcept
380 {
381 return ddc::DiscreteDomain<
382 interpolation_domain_type1,
383 interpolation_domain_type2,
384 interpolation_domain_type3>(
385 m_spline_builder1.interpolation_domain(),
386 m_spline_builder_2_3.interpolation_domain());
387 }
388
389 /**
390 * @brief Get the whole domain representing interpolation points.
391 *
392 * Values of the function must be provided on this domain in order
393 * to build a spline representation of the function (cartesian product of 3D interpolation_domain and batch_domain).
394 *
395 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
396 *
397 * @return The domain for the interpolation mesh.
398 */
399 template <concepts::discrete_domain BatchedInterpolationDDom>
400 BatchedInterpolationDDom batched_interpolation_domain(
401 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
402 {
403 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
404 return batched_interpolation_domain;
405 }
406
407 /**
408 * @brief Get the batch domain.
409 *
410 * Obtained by removing the dimensions of interest from the whole interpolation domain.
411 *
412 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
413 *
414 * @return The batch domain.
415 */
416 template <concepts::discrete_domain BatchedInterpolationDDom>
417 batch_domain_type<BatchedInterpolationDDom> batch_domain(
418 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
419 {
420 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
421 return ddc::remove_dims_of(batched_interpolation_domain, interpolation_domain());
422 }
423
424 /**
425 * @brief Get the 3D domain on which spline coefficients are defined.
426 *
427 * The 3D spline domain corresponding to the dimensions of interest.
428 *
429 * @return The 3D domain for the spline coefficients.
430 */
431 ddc::DiscreteDomain<bsplines_type1, bsplines_type2, bsplines_type3> spline_domain()
432 const noexcept
433 {
434 return ddc::DiscreteDomain<bsplines_type1, bsplines_type2, bsplines_type3>(
435 ddc::discrete_space<bsplines_type1>().full_domain(),
436 ddc::discrete_space<bsplines_type2>().full_domain(),
437 ddc::discrete_space<bsplines_type3>().full_domain());
438 }
439
440 /**
441 * @brief Get the whole domain on which spline coefficients are defined.
442 *
443 * Spline approximations (spline-transformed functions) are computed on this domain.
444 *
445 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
446 *
447 * @return The domain for the spline coefficients.
448 */
449 template <concepts::discrete_domain BatchedInterpolationDDom>
450 batched_spline_domain_type<BatchedInterpolationDDom> batched_spline_domain(
451 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
452 {
453 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
454 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
455 ddc::replace_dim_of<interpolation_discrete_dimension_type2, bsplines_type2>(
456 ddc::replace_dim_of<
457 interpolation_discrete_dimension_type3,
458 bsplines_type3>(batched_interpolation_domain, spline_domain()),
461 }
462
463 /**
464 * @brief Compute a 3D spline approximation of a function.
465 *
466 * Use the values of a function (defined on
467 * SplineBuilder3D::batched_interpolation_domain) and the derivatives of the
468 * function at the boundaries (in the case of BoundCond::HERMITE only)
469 * to calculate a 3D spline approximation of this function.
470 *
471 * The spline approximation is stored as a ChunkSpan of coefficients
472 * associated with B-splines.
473 *
474 * @param[out] spline
475 * The coefficients of the spline computed by this SplineBuilder.
476 * @param[in] vals
477 * The values of the function at the interpolation mesh.
478 * @param[in] derivs_min1
479 * The values of the derivatives at the lower boundary in the first dimension.
480 * @param[in] derivs_max1
481 * The values of the derivatives at the upper boundary in the first dimension.
482 * @param[in] derivs_min2
483 * The values of the derivatives at the lower boundary in the second dimension.
484 * @param[in] derivs_max2
485 * The values of the derivatives at the upper boundary in the second dimension.
486 * @param[in] derivs_min3
487 * The values of the derivatives at the lower boundary in the third dimension.
488 * @param[in] derivs_max3
489 * The values of the derivatives at the upper boundary in the third dimension.
490 * @param[in] mixed_derivs_min1_min2
491 * The values of the the cross-derivatives at the lower boundary in the first dimension and the lower boundary in the second dimension.
492 * @param[in] mixed_derivs_max1_min2
493 * The values of the the cross-derivatives at the upper boundary in the first dimension and the lower boundary in the second dimension.
494 * @param[in] mixed_derivs_min1_max2
495 * The values of the the cross-derivatives at the lower boundary in the first dimension and the upper boundary in the second dimension.
496 * @param[in] mixed_derivs_max1_max2
497 * The values of the the cross-derivatives at the upper boundary in the first dimension and the upper boundary in the second dimension.
498 * @param[in] mixed_derivs_min2_min3
499 * The values of the the cross-derivatives at the lower boundary in the second dimension and the lower boundary in the third dimension.
500 * @param[in] mixed_derivs_max2_min3
501 * The values of the the cross-derivatives at the upper boundary in the second dimension and the lower boundary in the third dimension.
502 * @param[in] mixed_derivs_min2_max3
503 * The values of the the cross-derivatives at the lower boundary in the second dimension and the upper boundary in the third dimension.
504 * @param[in] mixed_derivs_max2_max3
505 * The values of the the cross-derivatives at the upper boundary in the second dimension and the upper boundary in the third dimension.
506 * @param[in] mixed_derivs_min1_min3
507 * The values of the the cross-derivatives at the lower boundary in the first dimension and the lower boundary in the third dimension.
508 * @param[in] mixed_derivs_max1_min3
509 * The values of the the cross-derivatives at the upper boundary in the first dimension and the lower boundary in the third dimension.
510 * @param[in] mixed_derivs_min1_max3
511 * The values of the the cross-derivatives at the lower boundary in the first dimension and the upper boundary in the third dimension.
512 * @param[in] mixed_derivs_max1_max3
513 * The values of the the cross-derivatives at the upper boundary in the first dimension and the upper boundary in the third dimension.
514 * @param[in] mixed_derivs_min1_min2_min3
515 * The values of the the cross-derivatives at the lower boundary in the first dimension, the lower boundary in the second dimension and the lower boundary in the third dimension.
516 * @param[in] mixed_derivs_max1_min2_min3
517 * The values of the the cross-derivatives at the upper boundary in the first dimension, the lower boundary in the second dimension and the lower boundary in the third dimension.
518 * @param[in] mixed_derivs_min1_max2_min3
519 * The values of the the cross-derivatives at the lower boundary in the first dimension, the upper boundary in the second dimension and the lower boundary in the third dimension.
520 * @param[in] mixed_derivs_max1_max2_min3
521 * The values of the the cross-derivatives at the upper boundary in the first dimension, the upper boundary in the second dimension and the lower boundary in the third dimension.
522 * @param[in] mixed_derivs_min1_min2_max3
523 * The values of the the cross-derivatives at the lower boundary in the first dimension, the lower boundary in the second dimension and the upper boundary in the third dimension.
524 * @param[in] mixed_derivs_max1_min2_max3
525 * The values of the the cross-derivatives at the upper boundary in the first dimension, the lower boundary in the second dimension and the upper boundary in the third dimension.
526 * @param[in] mixed_derivs_min1_max2_max3
527 * The values of the the cross-derivatives at the lower boundary in the first dimension, the upper boundary in the second dimension and the upper boundary in the third dimension.
528 * @param[in] mixed_derivs_max1_max2_max3
529 * The values of the the cross-derivatives at the upper boundary in the first dimension, the upper boundary in the second dimension and the upper boundary in the third dimension.
530 */
531 template <class Layout, class BatchedInterpolationDDom>
532 void operator()(
533 ddc::ChunkSpan<
534 double,
535 batched_spline_domain_type<BatchedInterpolationDDom>,
536 Layout,
537 memory_space> spline,
538 ddc::ChunkSpan<double const, BatchedInterpolationDDom, Layout, memory_space> vals,
539 std::optional<ddc::ChunkSpan<
540 double const,
541 batched_derivs_domain_type1<BatchedInterpolationDDom>,
542 Layout,
543 memory_space>> derivs_min1
544 = std::nullopt,
545 std::optional<ddc::ChunkSpan<
546 double const,
547 batched_derivs_domain_type1<BatchedInterpolationDDom>,
548 Layout,
549 memory_space>> derivs_max1
550 = std::nullopt,
551 std::optional<ddc::ChunkSpan<
552 double const,
553 batched_derivs_domain_type2<BatchedInterpolationDDom>,
554 Layout,
555 memory_space>> derivs_min2
556 = std::nullopt,
557 std::optional<ddc::ChunkSpan<
558 double const,
559 batched_derivs_domain_type2<BatchedInterpolationDDom>,
560 Layout,
561 memory_space>> derivs_max2
562 = std::nullopt,
563 std::optional<ddc::ChunkSpan<
564 double const,
565 batched_derivs_domain_type3<BatchedInterpolationDDom>,
566 Layout,
567 memory_space>> derivs_min3
568 = std::nullopt,
569 std::optional<ddc::ChunkSpan<
570 double const,
571 batched_derivs_domain_type3<BatchedInterpolationDDom>,
572 Layout,
573 memory_space>> derivs_max3
574 = std::nullopt,
575 std::optional<ddc::ChunkSpan<
576 double const,
577 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
578 Layout,
579 memory_space>> mixed_derivs_min1_min2
580 = std::nullopt,
581 std::optional<ddc::ChunkSpan<
582 double const,
583 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
584 Layout,
585 memory_space>> mixed_derivs_max1_min2
586 = std::nullopt,
587 std::optional<ddc::ChunkSpan<
588 double const,
589 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
590 Layout,
591 memory_space>> mixed_derivs_min1_max2
592 = std::nullopt,
593 std::optional<ddc::ChunkSpan<
594 double const,
595 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
596 Layout,
597 memory_space>> mixed_derivs_max1_max2
598 = std::nullopt,
599 std::optional<ddc::ChunkSpan<
600 double const,
601 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
602 Layout,
603 memory_space>> mixed_derivs_min2_min3
604 = std::nullopt,
605 std::optional<ddc::ChunkSpan<
606 double const,
607 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
608 Layout,
609 memory_space>> mixed_derivs_max2_min3
610 = std::nullopt,
611 std::optional<ddc::ChunkSpan<
612 double const,
613 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
614 Layout,
615 memory_space>> mixed_derivs_min2_max3
616 = std::nullopt,
617 std::optional<ddc::ChunkSpan<
618 double const,
619 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
620 Layout,
621 memory_space>> mixed_derivs_max2_max3
622 = std::nullopt,
623 std::optional<ddc::ChunkSpan<
624 double const,
625 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
626 Layout,
627 memory_space>> mixed_derivs_min1_min3
628 = std::nullopt,
629 std::optional<ddc::ChunkSpan<
630 double const,
631 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
632 Layout,
633 memory_space>> mixed_derivs_max1_min3
634 = std::nullopt,
635 std::optional<ddc::ChunkSpan<
636 double const,
637 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
638 Layout,
639 memory_space>> mixed_derivs_min1_max3
640 = std::nullopt,
641 std::optional<ddc::ChunkSpan<
642 double const,
643 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
644 Layout,
645 memory_space>> mixed_derivs_max1_max3
646 = std::nullopt,
647 std::optional<ddc::ChunkSpan<
648 double const,
649 batched_derivs_domain_type<BatchedInterpolationDDom>,
650 Layout,
651 memory_space>> mixed_derivs_min1_min2_min3
652 = std::nullopt,
653 std::optional<ddc::ChunkSpan<
654 double const,
655 batched_derivs_domain_type<BatchedInterpolationDDom>,
656 Layout,
657 memory_space>> mixed_derivs_max1_min2_min3
658 = std::nullopt,
659 std::optional<ddc::ChunkSpan<
660 double const,
661 batched_derivs_domain_type<BatchedInterpolationDDom>,
662 Layout,
663 memory_space>> mixed_derivs_min1_max2_min3
664 = std::nullopt,
665 std::optional<ddc::ChunkSpan<
666 double const,
667 batched_derivs_domain_type<BatchedInterpolationDDom>,
668 Layout,
669 memory_space>> mixed_derivs_max1_max2_min3
670 = std::nullopt,
671 std::optional<ddc::ChunkSpan<
672 double const,
673 batched_derivs_domain_type<BatchedInterpolationDDom>,
674 Layout,
675 memory_space>> mixed_derivs_min1_min2_max3
676 = std::nullopt,
677 std::optional<ddc::ChunkSpan<
678 double const,
679 batched_derivs_domain_type<BatchedInterpolationDDom>,
680 Layout,
681 memory_space>> mixed_derivs_max1_min2_max3
682 = std::nullopt,
683 std::optional<ddc::ChunkSpan<
684 double const,
685 batched_derivs_domain_type<BatchedInterpolationDDom>,
686 Layout,
687 memory_space>> mixed_derivs_min1_max2_max3
688 = std::nullopt,
689 std::optional<ddc::ChunkSpan<
690 double const,
691 batched_derivs_domain_type<BatchedInterpolationDDom>,
692 Layout,
693 memory_space>> mixed_derivs_max1_max2_max3
694 = std::nullopt) const;
695};
696
697
698template <
699 class ExecSpace,
700 class MemorySpace,
701 class BSpline1,
702 class BSpline2,
703 class BSpline3,
704 class DDimI1,
705 class DDimI2,
706 class DDimI3,
714template <class Layout, class BatchedInterpolationDDom>
715void SplineBuilder3D<
716 ExecSpace,
717 MemorySpace,
718 BSpline1,
719 BSpline2,
720 BSpline3,
721 DDimI1,
722 DDimI2,
723 DDimI3,
724 BcLower1,
725 BcUpper1,
726 BcLower2,
727 BcUpper2,
728 BcLower3,
729 BcUpper3,
730 Solver>::
731operator()(
732 ddc::ChunkSpan<
733 double,
734 batched_spline_domain_type<BatchedInterpolationDDom>,
735 Layout,
736 memory_space> spline,
737 ddc::ChunkSpan<double const, BatchedInterpolationDDom, Layout, memory_space> vals,
738 std::optional<ddc::ChunkSpan<
739 double const,
740 batched_derivs_domain_type1<BatchedInterpolationDDom>,
741 Layout,
742 memory_space>> derivs_min1,
743 std::optional<ddc::ChunkSpan<
744 double const,
745 batched_derivs_domain_type1<BatchedInterpolationDDom>,
746 Layout,
747 memory_space>> derivs_max1,
748 std::optional<ddc::ChunkSpan<
749 double const,
750 batched_derivs_domain_type2<BatchedInterpolationDDom>,
751 Layout,
752 memory_space>> derivs_min2,
753 std::optional<ddc::ChunkSpan<
754 double const,
755 batched_derivs_domain_type2<BatchedInterpolationDDom>,
756 Layout,
757 memory_space>> derivs_max2,
758 std::optional<ddc::ChunkSpan<
759 double const,
760 batched_derivs_domain_type3<BatchedInterpolationDDom>,
761 Layout,
762 memory_space>> derivs_min3,
763 std::optional<ddc::ChunkSpan<
764 double const,
765 batched_derivs_domain_type3<BatchedInterpolationDDom>,
766 Layout,
767 memory_space>> derivs_max3,
768 std::optional<ddc::ChunkSpan<
769 double const,
770 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
771 Layout,
772 memory_space>> mixed_derivs_min1_min2,
773 std::optional<ddc::ChunkSpan<
774 double const,
775 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
776 Layout,
777 memory_space>> mixed_derivs_max1_min2,
778 std::optional<ddc::ChunkSpan<
779 double const,
780 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
781 Layout,
782 memory_space>> mixed_derivs_min1_max2,
783 std::optional<ddc::ChunkSpan<
784 double const,
785 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
786 Layout,
787 memory_space>> mixed_derivs_max1_max2,
788 std::optional<ddc::ChunkSpan<
789 double const,
790 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
791 Layout,
792 memory_space>> mixed_derivs_min2_min3,
793 std::optional<ddc::ChunkSpan<
794 double const,
795 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
796 Layout,
797 memory_space>> mixed_derivs_max2_min3,
798 std::optional<ddc::ChunkSpan<
799 double const,
800 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
801 Layout,
802 memory_space>> mixed_derivs_min2_max3,
803 std::optional<ddc::ChunkSpan<
804 double const,
805 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
806 Layout,
807 memory_space>> mixed_derivs_max2_max3,
808 std::optional<ddc::ChunkSpan<
809 double const,
810 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
811 Layout,
812 memory_space>> mixed_derivs_min1_min3,
813 std::optional<ddc::ChunkSpan<
814 double const,
815 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
816 Layout,
817 memory_space>> mixed_derivs_max1_min3,
818 std::optional<ddc::ChunkSpan<
819 double const,
820 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
821 Layout,
822 memory_space>> mixed_derivs_min1_max3,
823 std::optional<ddc::ChunkSpan<
824 double const,
825 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
826 Layout,
827 memory_space>> mixed_derivs_max1_max3,
828 std::optional<ddc::ChunkSpan<
829 double const,
830 batched_derivs_domain_type<BatchedInterpolationDDom>,
831 Layout,
832 memory_space>> mixed_derivs_min1_min2_min3,
833 std::optional<ddc::ChunkSpan<
834 double const,
835 batched_derivs_domain_type<BatchedInterpolationDDom>,
836 Layout,
837 memory_space>> mixed_derivs_max1_min2_min3,
838 std::optional<ddc::ChunkSpan<
839 double const,
840 batched_derivs_domain_type<BatchedInterpolationDDom>,
841 Layout,
842 memory_space>> mixed_derivs_min1_max2_min3,
843 std::optional<ddc::ChunkSpan<
844 double const,
845 batched_derivs_domain_type<BatchedInterpolationDDom>,
846 Layout,
847 memory_space>> mixed_derivs_max1_max2_min3,
848 std::optional<ddc::ChunkSpan<
849 double const,
850 batched_derivs_domain_type<BatchedInterpolationDDom>,
851 Layout,
852 memory_space>> mixed_derivs_min1_min2_max3,
853 std::optional<ddc::ChunkSpan<
854 double const,
855 batched_derivs_domain_type<BatchedInterpolationDDom>,
856 Layout,
857 memory_space>> mixed_derivs_max1_min2_max3,
858 std::optional<ddc::ChunkSpan<
859 double const,
860 batched_derivs_domain_type<BatchedInterpolationDDom>,
861 Layout,
862 memory_space>> mixed_derivs_min1_max2_max3,
863 std::optional<ddc::ChunkSpan<
864 double const,
865 batched_derivs_domain_type<BatchedInterpolationDDom>,
866 Layout,
867 memory_space>> mixed_derivs_max1_max2_max3) const
868{
869 auto const batched_interpolation_domain = vals.domain();
870
871 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
872 assert(batch_domain_type<BatchedInterpolationDDom>(batched_interpolation_domain)
873 == batch_domain_type<BatchedInterpolationDDom>(spline.domain()));
874
875 if (batch_domain(batched_interpolation_domain).empty()) {
876 return;
877 }
878
879 // Build the derivatives along the second dimension
880 auto const batched_interpolation_deriv_domain2
881 = ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
882 batched_interpolation_domain,
883 ddc::DiscreteDomain<deriv_type2>(
884 ddc::DiscreteElement<deriv_type2>(BSpline2::degree() % 2),
885 ddc::DiscreteVector<deriv_type2>(bsplines_type2::degree() / 2)));
886
887 ddc::Chunk spline_derivs_min2_alloc(
888 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2),
889 ddc::KokkosAllocator<double, MemorySpace>());
890 auto spline_derivs_min2 = spline_derivs_min2_alloc.span_view();
891 auto spline_derivs_min2_opt = std::optional(spline_derivs_min2.span_cview());
892 if constexpr (BcLower2 == ddc::BoundCond::HERMITE) {
893 m_spline_builder1(
894 spline_derivs_min2,
895 *derivs_min2,
896 mixed_derivs_min1_min2,
897 mixed_derivs_max1_min2);
898 } else {
899 spline_derivs_min2_opt = std::nullopt;
900 }
901
902 ddc::Chunk spline_derivs_max2_alloc(
903 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2),
904 ddc::KokkosAllocator<double, MemorySpace>());
905 auto spline_derivs_max2 = spline_derivs_max2_alloc.span_view();
906 auto spline_derivs_max2_opt = std::optional(spline_derivs_max2.span_cview());
907 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE) {
908 m_spline_builder1(
909 spline_derivs_max2,
910 *derivs_max2,
911 mixed_derivs_min1_max2,
912 mixed_derivs_max1_max2);
913 } else {
914 spline_derivs_max2_opt = std::nullopt;
915 }
916
917 // Build the derivatives along the third dimension
918 auto const batched_interpolation_deriv_domain3
919 = ddc::replace_dim_of<interpolation_discrete_dimension_type3, deriv_type3>(
920 batched_interpolation_domain,
921 ddc::DiscreteDomain<deriv_type3>(
922 ddc::DiscreteElement<deriv_type3>(BSpline3::degree() % 2),
923 ddc::DiscreteVector<deriv_type3>(bsplines_type3::degree() / 2)));
924
925 ddc::Chunk spline_derivs_min3_alloc(
926 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain3),
927 ddc::KokkosAllocator<double, MemorySpace>());
928 auto spline_derivs_min3 = spline_derivs_min3_alloc.span_view();
929 auto spline_derivs_min3_opt = std::optional(spline_derivs_min3.span_cview());
930 if constexpr (BcLower3 == ddc::BoundCond::HERMITE) {
931 m_spline_builder1(
932 spline_derivs_min3,
933 *derivs_min3,
934 mixed_derivs_min1_min3,
935 mixed_derivs_max1_min3);
936 } else {
937 spline_derivs_min3_opt = std::nullopt;
938 }
939
940 ddc::Chunk spline_derivs_max3_alloc(
941 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain3),
942 ddc::KokkosAllocator<double, MemorySpace>());
943 auto spline_derivs_max3 = spline_derivs_max3_alloc.span_view();
944 auto spline_derivs_max3_opt = std::optional(spline_derivs_max3.span_cview());
945 if constexpr (BcUpper3 == ddc::BoundCond::HERMITE) {
946 m_spline_builder1(
947 spline_derivs_max3,
948 *derivs_max3,
949 mixed_derivs_min1_max3,
950 mixed_derivs_max1_max3);
951 } else {
952 spline_derivs_max3_opt = std::nullopt;
953 }
954
955 // Build the cross derivatives along the second and third dimensions
956 auto batched_interpolation_deriv_domain2_3
957 = ddc::replace_dim_of<interpolation_discrete_dimension_type3, deriv_type3>(
958 batched_interpolation_deriv_domain2,
959 ddc::DiscreteDomain<deriv_type3>(
960 ddc::DiscreteElement<deriv_type3>(BSpline3::degree() % 2),
961 ddc::DiscreteVector<deriv_type3>(bsplines_type3::degree() / 2)));
962
963 ddc::Chunk spline_derivs_min2_min3_alloc(
964 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
965 ddc::KokkosAllocator<double, MemorySpace>());
966 auto spline_derivs_min2_min3 = spline_derivs_min2_min3_alloc.span_view();
967 auto spline_derivs_min2_min3_opt = std::optional(spline_derivs_min2_min3.span_cview());
968 if constexpr (BcLower2 == ddc::BoundCond::HERMITE || BcLower3 == ddc::BoundCond::HERMITE) {
969 m_spline_builder1(
970 spline_derivs_min2_min3,
971 *mixed_derivs_min2_min3,
972 mixed_derivs_min1_min2_min3,
973 mixed_derivs_max1_min2_min3);
974 } else {
975 spline_derivs_min2_min3_opt = std::nullopt;
976 }
977
978 ddc::Chunk spline_derivs_min2_max3_alloc(
979 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
980 ddc::KokkosAllocator<double, MemorySpace>());
981 auto spline_derivs_min2_max3 = spline_derivs_min2_max3_alloc.span_view();
982 auto spline_derivs_min2_max3_opt = std::optional(spline_derivs_min2_max3.span_cview());
983 if constexpr (BcLower2 == ddc::BoundCond::HERMITE || BcUpper3 == ddc::BoundCond::HERMITE) {
984 m_spline_builder1(
985 spline_derivs_min2_max3,
986 *mixed_derivs_min2_max3,
987 mixed_derivs_min1_min2_max3,
988 mixed_derivs_max1_min2_max3);
989 } else {
990 spline_derivs_min2_max3_opt = std::nullopt;
991 }
992
993 ddc::Chunk spline_derivs_max2_min3_alloc(
994 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
995 ddc::KokkosAllocator<double, MemorySpace>());
996 auto spline_derivs_max2_min3 = spline_derivs_max2_min3_alloc.span_view();
997 auto spline_derivs_max2_min3_opt = std::optional(spline_derivs_max2_min3.span_cview());
998 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE || BcLower3 == ddc::BoundCond::HERMITE) {
999 m_spline_builder1(
1000 spline_derivs_max2_min3,
1001 *mixed_derivs_max2_min3,
1002 mixed_derivs_min1_max2_min3,
1003 mixed_derivs_max1_max2_min3);
1004 } else {
1005 spline_derivs_max2_min3_opt = std::nullopt;
1006 }
1007
1008 ddc::Chunk spline_derivs_max2_max3_alloc(
1009 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
1010 ddc::KokkosAllocator<double, MemorySpace>());
1011 auto spline_derivs_max2_max3 = spline_derivs_max2_max3_alloc.span_view();
1012 auto spline_derivs_max2_max3_opt = std::optional(spline_derivs_max2_max3.span_cview());
1013 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE || BcUpper3 == ddc::BoundCond::HERMITE) {
1014 m_spline_builder1(
1015 spline_derivs_max2_max3,
1016 *mixed_derivs_max2_max3,
1017 mixed_derivs_min1_max2_max3,
1018 mixed_derivs_max1_max2_max3);
1019 } else {
1020 spline_derivs_max2_max3_opt = std::nullopt;
1021 }
1022
1023 // Spline1-approximate vals (to spline1)
1024 ddc::Chunk spline1_alloc(
1025 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
1026 ddc::KokkosAllocator<double, MemorySpace>());
1027 ddc::ChunkSpan const spline1 = spline1_alloc.span_view();
1028
1029 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
1030
1031 m_spline_builder_2_3(
1032 spline,
1033 spline1.span_cview(),
1034 spline_derivs_min2_opt,
1035 spline_derivs_max2_opt,
1036 spline_derivs_min3_opt,
1037 spline_derivs_max3_opt,
1038 spline_derivs_min2_min3_opt,
1039 spline_derivs_max2_min3_opt,
1040 spline_derivs_min2_max3_opt,
1041 spline_derivs_max2_max3_opt);
1042}
1043
1044} // namespace ddc
friend class ChunkSpan
friend class Chunk
Definition chunk.hpp:81
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
A class which provides helper functions to initialise the Greville points from a B-Spline definition.
static ddc::DiscreteDomain< Sampling > get_domain()
Get the domain which gives us access to all of the Greville points.
Helper class for the initialisation of the mesh of interpolation points.
static auto get_sampling()
Get the sampling of interpolation points.
static ddc::DiscreteDomain< Sampling > get_domain()
Get the domain which can be used to access the interpolation points in the sampling.
Storage class of the static attributes of the discrete dimension.
Impl & operator=(Impl &&x)=default
Move-assigns.
Impl(RandomIt breaks_begin, RandomIt breaks_end)
Constructs an Impl by iterating over a range of break points from begin to end.
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmin() const noexcept
Returns the coordinate of the first break point of the domain on which the B-splines are defined.
Impl(std::vector< ddc::Coordinate< CDim > > const &breaks)
Constructs an Impl using a std::vector.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_basis(DSpan1D values, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-splines at a given coordinate.
KOKKOS_INLINE_FUNCTION std::size_t size() const noexcept
Returns the number of elements necessary to construct a spline representation of a function.
Impl(Impl< DDim, OriginMemorySpace > const &impl)
Copy-constructs from another Impl with a different Kokkos memory space.
~Impl()=default
Destructs.
KOKKOS_INLINE_FUNCTION ddc::DiscreteDomain< knot_discrete_dimension_type > break_point_domain() const
Returns the discrete domain which describes the break points.
KOKKOS_INLINE_FUNCTION ddc::DiscreteElement< knot_discrete_dimension_type > get_last_support_knot(discrete_element_type const &ix) const
Returns the coordinate of the last support knot associated to a DiscreteElement identifying a B-splin...
Impl(Impl &&x)=default
Move-constructs.
Impl(std::initializer_list< ddc::Coordinate< CDim > > breaks)
Constructs an Impl using a brace-list, i.e.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_basis_and_n_derivs(ddc::DSpan2D derivs, ddc::Coordinate< CDim > const &x, std::size_t n) const
Evaluates non-zero B-spline values and derivatives at a given coordinate.
KOKKOS_INLINE_FUNCTION std::size_t ncells() const noexcept
Returns the number of cells over which the B-splines are defined.
KOKKOS_INLINE_FUNCTION discrete_domain_type full_domain() const
Returns the discrete domain including eventual additional B-splines in the periodic case.
KOKKOS_INLINE_FUNCTION ddc::DiscreteElement< knot_discrete_dimension_type > get_first_support_knot(discrete_element_type const &ix) const
Returns the coordinate of the first support knot associated to a DiscreteElement identifying a B-spli...
KOKKOS_INLINE_FUNCTION std::size_t npoints() const noexcept
The number of break points.
KOKKOS_INLINE_FUNCTION std::size_t nbasis() const noexcept
Returns the number of basis functions.
Impl(Impl const &x)=default
Copy-constructs.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_deriv(DSpan1D derivs, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-spline derivatives at a given coordinate.
KOKKOS_INLINE_FUNCTION double length() const noexcept
Returns the length of the domain.
Impl & operator=(Impl const &x)=default
Copy-assigns.
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmax() const noexcept
Returns the coordinate of the last break point of the domain on which the B-splines are defined.
The type of a non-uniform 1D spline basis (B-spline).
static constexpr std::size_t degree() noexcept
The degree of B-splines.
static constexpr bool is_periodic() noexcept
Indicates if the B-splines are periodic or not.
static constexpr bool is_uniform() noexcept
Indicates if the B-splines are uniform or not (this is not the case here).
NonUniformPointSampling models a non-uniform discretization of the CDim segment .
A class for creating a 2D spline approximation of a function.
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.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2 > spline_domain() const noexcept
Get the 2D domain on which spline coefficients are defined.
SplineBuilder2D(SplineBuilder2D &&x)=default
Move-constructs.
SplineBuilder2D & operator=(SplineBuilder2D &&x)=default
Move-assigns.
batched_spline_domain_type< BatchedInterpolationDDom > batched_spline_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which spline coefficients are defined.
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(interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder2D acting on interpolation_domain.
~SplineBuilder2D()=default
Destructs.
SplineBuilder2D(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.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
SplineBuilder2D & operator=(SplineBuilder2D const &x)=delete
Copy-assignment is deleted.
A class for creating a 3D spline approximation of a function.
SplineBuilder3D(SplineBuilder3D const &x)=delete
Copy-constructor is deleted.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type< BatchedInterpolationDDom >, Layout, memory_space > spline, ddc::ChunkSpan< double const, BatchedInterpolationDDom, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type3< BatchedInterpolationDDom >, Layout, memory_space > > derivs_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type3< BatchedInterpolationDDom >, Layout, memory_space > > derivs_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_2< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1_3< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2_min3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_min2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_min2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_min1_max2_max3=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > mixed_derivs_max1_max2_max3=std::nullopt) const
Compute a 3D spline approximation of a function.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
~SplineBuilder3D()=default
Destructs.
SplineBuilder3D(BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder3D acting on the interpolation domain contained in batched_interpolation_domain.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2, bsplines_type3 > spline_domain() const noexcept
Get the 3D domain on which spline coefficients are defined.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 3D interpolation mesh used by this class.
SplineBuilder3D & operator=(SplineBuilder3D const &x)=delete
Copy-assignment is deleted.
SplineBuilder3D(interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder3D acting on interpolation_domain.
SplineBuilder3D(SplineBuilder3D &&x)=default
Move-constructs.
SplineBuilder3D & operator=(SplineBuilder3D &&x)=default
Move-assigns.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch 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.
A class for creating a spline approximation of a function.
batched_derivs_domain_type< BatchedInterpolationDDom > batched_derivs_xmax_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which derivatives on upper boundary are defined.
static constexpr SplineSolver s_spline_solver
The SplineSolver giving the backend used to perform the spline approximation.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
std::tuple< ddc::Chunk< double, ddc::DiscreteDomain< ddc::Deriv< typename InterpolationDDim::continuous_dimension_type > >, ddc::KokkosAllocator< double, OutMemorySpace > >, ddc::Chunk< double, ddc::DiscreteDomain< InterpolationDDim >, ddc::KokkosAllocator< double, OutMemorySpace > >, ddc::Chunk< double, ddc::DiscreteDomain< ddc::Deriv< typename InterpolationDDim::continuous_dimension_type > >, ddc::KokkosAllocator< double, OutMemorySpace > > > quadrature_coefficients() const
Compute the quadrature coefficients associated to the b-splines used by this SplineBuilder.
SplineBuilder & operator=(SplineBuilder const &x)=delete
Copy-assignment is deleted.
SplineBuilder(SplineBuilder &&x)=default
Move-constructs.
static constexpr int s_nbe_xmax
The number of equations defining the boundary condition at the upper bound.
SplineBuilder(interpolation_domain_type const &interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder acting on interpolation_domain.
static constexpr ddc::BoundCond s_bc_xmin
The boundary condition implemented at the lower bound.
BatchedInterpolationDDom batched_interpolation_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain representing interpolation points.
SplineBuilder & operator=(SplineBuilder &&x)=default
Move-assigns.
SplineBuilder(SplineBuilder const &x)=delete
Copy-constructor is deleted.
SplineBuilder(BatchedInterpolationDDom const &batched_interpolation_domain, std::optional< std::size_t > cols_per_chunk=std::nullopt, std::optional< unsigned int > preconditioner_max_block_size=std::nullopt)
Build a SplineBuilder acting on the interpolation domain contained by batched_interpolation_domain.
static constexpr int s_nbv_xmax
The number of input values defining the boundary condition at the upper bound.
static constexpr bool s_odd
Indicates if the degree of the splines is odd or even.
static constexpr int s_nbv_xmin
The number of input values defining the boundary condition at the lower bound.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 1D interpolation mesh used by this class.
batched_derivs_domain_type< BatchedInterpolationDDom > batched_derivs_xmin_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which derivatives on lower boundary are defined.
static constexpr ddc::BoundCond s_bc_xmax
The boundary condition implemented at the upper bound.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type< BatchedInterpolationDDom >, Layout, memory_space > spline, ddc::ChunkSpan< double const, BatchedInterpolationDDom, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > derivs_xmin=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type< BatchedInterpolationDDom >, Layout, memory_space > > derivs_xmax=std::nullopt) const
Compute a spline approximation of a function.
batched_spline_domain_type< BatchedInterpolationDDom > batched_spline_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the whole domain on which spline coefficients are defined.
ddc::DiscreteDomain< bsplines_type > spline_domain() const noexcept
Get the 1D domain on which spline coefficients are defined.
~SplineBuilder()=default
Destructs.
static constexpr int s_nbe_xmin
The number of equations defining the boundary condition at the lower bound.
Storage class of the static attributes of the discrete dimension.
KOKKOS_INLINE_FUNCTION ddc::DiscreteElement< knot_discrete_dimension_type > get_last_support_knot(discrete_element_type const &ix) const
Returns the coordinate of the last support knot associated to a DiscreteElement identifying a B-splin...
Impl(ddc::Coordinate< CDim > rmin, ddc::Coordinate< CDim > rmax, std::size_t ncells)
Constructs a spline basis (B-splines) with n equidistant knots over .
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmax() const noexcept
Returns the coordinate of the upper bound of the domain on which the B-splines are defined.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_basis(DSpan1D values, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-splines at a given coordinate.
KOKKOS_INLINE_FUNCTION ddc::DiscreteDomain< knot_discrete_dimension_type > break_point_domain() const
Returns the discrete domain which describes the break points.
KOKKOS_INLINE_FUNCTION ddc::Coordinate< CDim > rmin() const noexcept
Returns the coordinate of the lower bound of the domain on which the B-splines are defined.
~Impl()=default
Destructs.
KOKKOS_INLINE_FUNCTION std::size_t nbasis() const noexcept
Returns the number of basis functions.
Impl(Impl const &x)=default
Copy-constructs.
KOKKOS_INLINE_FUNCTION std::size_t size() const noexcept
Returns the number of elements necessary to construct a spline representation of a function.
Impl(Impl &&x)=default
Move-constructs.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_basis_and_n_derivs(ddc::DSpan2D derivs, ddc::Coordinate< CDim > const &x, std::size_t n) const
Evaluates non-zero B-spline values and derivatives at a given coordinate.
KOKKOS_INLINE_FUNCTION ddc::DiscreteElement< knot_discrete_dimension_type > get_first_support_knot(discrete_element_type const &ix) const
Returns the coordinate of the first support knot associated to a DiscreteElement identifying a B-spli...
KOKKOS_INLINE_FUNCTION double length() const noexcept
Returns the length of the domain.
Impl(Impl< DDim, OriginMemorySpace > const &impl)
Copy-constructs from another Impl with a different Kokkos memory space.
KOKKOS_INLINE_FUNCTION std::size_t ncells() const noexcept
Returns the number of cells over which the B-splines are defined.
KOKKOS_INLINE_FUNCTION discrete_element_type eval_deriv(DSpan1D derivs, ddc::Coordinate< CDim > const &x) const
Evaluates non-zero B-spline derivatives at a given coordinate.
Impl & operator=(Impl &&x)=default
Move-assigns.
KOKKOS_INLINE_FUNCTION discrete_domain_type full_domain() const
Returns the discrete domain including eventual additional B-splines in the periodic case.
Impl & operator=(Impl const &x)=default
Copy-assigns.
The type of a uniform 1D spline basis (B-spline).
static constexpr bool is_uniform() noexcept
Indicates if the B-splines are uniform or not (this is the case here).
static constexpr bool is_periodic() noexcept
Indicates if the B-splines are periodic or not.
static constexpr std::size_t degree() noexcept
The degree of B-splines.
UniformPointSampling models a uniform discretization of the provided continuous dimension.
The top-level namespace of DDC.
constexpr int n_boundary_equations(ddc::BoundCond const bc, std::size_t const degree)
Return the number of equations needed to describe a given boundary condition.
constexpr bool is_uniform_bsplines_v
Indicates if a tag corresponds to uniform B-splines or not.
BoundCond
An enum representing a spline boundary condition.
@ HOMOGENEOUS_HERMITE
Homogeneous Hermite boundary condition (derivatives are 0)
@ GREVILLE
Use Greville points instead of conditions on derivative for B-Spline interpolation.
@ HERMITE
Hermite boundary condition.
@ PERIODIC
Periodic boundary condition u(1)=u(n)
ddc::ChunkSpan< double, ddc::DiscreteDomain< DDim >, Layout, MemorySpace > integrals(ExecSpace const &execution_space, ddc::ChunkSpan< double, ddc::DiscreteDomain< DDim >, Layout, MemorySpace > int_vals)
Compute the integrals of the B-splines.
SplineSolver
An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.
@ LAPACK
Enum member to identify the LAPACK-based solver (direct method)
@ GINKGO
Enum member to identify the Ginkgo-based solver (iterative method)
constexpr bool is_non_uniform_bsplines_v
Indicates if a tag corresponds to non-uniform B-splines or not.
A templated struct representing a discrete dimension storing the derivatives of a function along a co...
Definition deriv.hpp:15
If the type DDim is a B-spline, defines type to the discrete dimension of the associated knots.
ConstantExtrapolationRule(ddc::Coordinate< DimI > eval_pos, ddc::Coordinate< DimNI > eval_pos_not_interest_min, ddc::Coordinate< DimNI > eval_pos_not_interest_max)
Instantiate a ConstantExtrapolationRule.
KOKKOS_FUNCTION double operator()(CoordType coord_extrap, ddc::ChunkSpan< double const, ddc::DiscreteDomain< BSplines1, BSplines2 >, Layout, MemorySpace > const spline_coef) const
Get the value of the function on B-splines at a coordinate outside the domain.
ConstantExtrapolationRule(ddc::Coordinate< DimI > eval_pos)
Instantiate a ConstantExtrapolationRule.
KOKKOS_FUNCTION double operator()(CoordType pos, ddc::ChunkSpan< double const, ddc::DiscreteDomain< BSplines >, Layout, MemorySpace > const spline_coef) const
Get the value of the function on B-splines at a coordinate outside the domain.
ConstantExtrapolationRule(ddc::Coordinate< DimI > eval_pos)
Instantiate a ConstantExtrapolationRule.
A functor describing a null extrapolation boundary value for 1D spline evaluator.
KOKKOS_FUNCTION double operator()(CoordType, ChunkSpan) const
Evaluates the spline at a coordinate outside of the domain.
KOKKOS_FUNCTION double operator()(CoordType, ChunkSpan) const