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 = builder_type1::continuous_dimension_type;
72
73 /// @brief The type of the second interpolation continuous dimension.
74 using continuous_dimension_type2 = builder_type_2_3::continuous_dimension_type1;
75
76 /// @brief The type of the third interpolation continuous dimension.
77 using continuous_dimension_type3 = 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 = builder_type1::interpolation_discrete_dimension_type;
82
83 /// @brief The type of the second interpolation discrete dimension.
84 using interpolation_discrete_dimension_type2
85 = 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 = 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 = builder_type1::bsplines_type;
93
94 /// @brief The type of the B-splines in the second dimension.
95 using bsplines_type2 = builder_type_2_3::bsplines_type1;
96
97 /// @brief The type of the B-splines in the third dimension.
98 using bsplines_type3 = 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 = builder_type1::deriv_type;
102
103 /// @brief The type of the Deriv domain on boundaries in the second dimension.
104 using deriv_type2 = 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 = 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 = builder_type1::interpolation_discrete_dimension_type;
111
112 /// @brief The type of the domain for the interpolation mesh in the second dimension.
113 using interpolation_domain_type2 = builder_type_2_3::interpolation_discrete_dimension_type1;
114
115 /// @brief The type of the domain for the interpolation mesh in the third dimension.
116 using interpolation_domain_type3 = builder_type_2_3::interpolation_discrete_dimension_type2;
117
118 /// @brief The type of the domain for the interpolation mesh in the 3D dimension.
119 using interpolation_domain_type = ddc::DiscreteDomain<
120 interpolation_discrete_dimension_type1,
121 interpolation_discrete_dimension_type2,
122 interpolation_discrete_dimension_type3>;
123
124 /**
125 * @brief The type of the whole domain representing interpolation points.
126 *
127 * @tparam The batched discrete domain on which the interpolation points are defined.
128 */
129 template <concepts::discrete_domain BatchedInterpolationDDom>
130 using batched_interpolation_domain_type = BatchedInterpolationDDom;
131
132 /**
133 * @brief The type of the batch domain (obtained by removing the dimensions of interest
134 * from the whole domain).
135 *
136 * @tparam The batched discrete domain on which the interpolation points are defined.
137 *
138 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
139 * this is DiscreteDomain<T>.
140 */
141 template <concepts::discrete_domain BatchedInterpolationDDom>
142 using batch_domain_type = ddc::remove_dims_of_t<
143 BatchedInterpolationDDom,
144 interpolation_discrete_dimension_type1,
145 interpolation_discrete_dimension_type2,
146 interpolation_discrete_dimension_type3>;
147
148 /**
149 * @brief The type of the whole spline domain (cartesian product of 3D spline domain
150 * and batch domain) preserving the order of dimensions.
151 *
152 * @tparam The batched discrete domain on which the interpolation points are defined.
153 *
154 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z
155 * (associated to B-splines tags BSplinesX, BSplinesY and BSplinesZ), this is DiscreteDomain<BSplinesX, BSplinesY, BSplinesZ, T>
156 */
157 template <concepts::discrete_domain BatchedInterpolationDDom>
158 using batched_spline_domain_type
159 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
160 ddc::to_type_seq_t<BatchedInterpolationDDom>,
161 ddc::detail::TypeSeq<
162 interpolation_discrete_dimension_type1,
163 interpolation_discrete_dimension_type2,
164 interpolation_discrete_dimension_type3>,
165 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2, bsplines_type3>>>;
166
167 /**
168 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
169 * and the associated batch domain) in the first dimension, preserving the order of dimensions.
170 *
171 * @tparam The batched discrete domain on which the interpolation points are defined.
172 *
173 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
174 * this is DiscreteDomain<Deriv<X>, Y, Z, T>.
175 */
176 template <concepts::discrete_domain BatchedInterpolationDDom>
177 using batched_derivs_domain_type1 = ddc::replace_dim_of_t<
178 BatchedInterpolationDDom,
179 interpolation_discrete_dimension_type1,
180 deriv_type1>;
181
182 /**
183 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
184 * and the associated batch domain) in the second dimension, preserving the order of dimensions.
185 *
186 * @tparam The batched discrete domain on which the interpolation points are defined.
187 *
188 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
189 * this is DiscreteDomain<X, Deriv<Y>, Z, T>.
190 */
191 template <concepts::discrete_domain BatchedInterpolationDDom>
192 using batched_derivs_domain_type2 = ddc::replace_dim_of_t<
193 BatchedInterpolationDDom,
194 interpolation_discrete_dimension_type2,
195 deriv_type2>;
196
197 /**
198 * @brief The type of the whole Derivs domain (cartesian product of the 1D Deriv domain
199 * and the associated batch domain) in the third dimension, preserving the order of dimensions.
200 *
201 * @tparam The batched discrete domain on which the interpolation points are defined.
202 *
203 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
204 * this is DiscreteDomain<X, Y, Deriv<Z>, T>.
205 */
206 template <concepts::discrete_domain BatchedInterpolationDDom>
207 using batched_derivs_domain_type3 = ddc::replace_dim_of_t<
208 BatchedInterpolationDDom,
209 interpolation_discrete_dimension_type3,
210 deriv_type3>;
211
212 /**
213 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
214 * and the associated batch domain) in the first and second dimensions, preserving the order
215 * of dimensions.
216 *
217 * @tparam The batched discrete domain on which the interpolation points are defined.
218 *
219 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
220 * this is DiscreteDomain<Deriv<X>, Deriv<Y>, Z, T>.
221 */
222 template <concepts::discrete_domain BatchedInterpolationDDom>
223 using batched_derivs_domain_type1_2 = ddc::replace_dim_of_t<
224 ddc::replace_dim_of_t<
225 BatchedInterpolationDDom,
226 interpolation_discrete_dimension_type1,
227 deriv_type1>,
228 interpolation_domain_type2,
229 deriv_type2>;
230
231 /**
232 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
233 * and the associated batch domain) in the second and third dimensions, preserving the order
234 * of dimensions.
235 *
236 * @tparam The batched discrete domain on which the interpolation points are defined.
237 *
238 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
239 * this is DiscreteDomain<X, Deriv<Y>, Deriv<Z>, T>.
240 */
241 template <concepts::discrete_domain BatchedInterpolationDDom>
242 using batched_derivs_domain_type2_3 = ddc::replace_dim_of_t<
243 ddc::replace_dim_of_t<
244 BatchedInterpolationDDom,
245 interpolation_discrete_dimension_type2,
246 deriv_type2>,
247 interpolation_domain_type3,
248 deriv_type3>;
249
250 /**
251 * @brief The type of the whole Derivs domain (cartesian product of the 2D Deriv domain
252 * and the associated batch domain) in the first and third dimensions, preserving the order
253 * of dimensions.
254 *
255 * @tparam The batched discrete domain on which the interpolation points are defined.
256 *
257 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y, and Z
258 * this is DiscreteDomain<Deriv<X>, Y, Deriv<Z>, T>.
259 */
260 template <concepts::discrete_domain BatchedInterpolationDDom>
261 using batched_derivs_domain_type1_3 = ddc::replace_dim_of_t<
262 ddc::replace_dim_of_t<
263 BatchedInterpolationDDom,
264 interpolation_discrete_dimension_type1,
265 deriv_type1>,
266 interpolation_domain_type3,
267 deriv_type3>;
268
269 /**
270 * @brief The type of the whole Derivs domain (cartesian product of the 3D Deriv domain
271 * and the batch domain), preserving the order of dimensions.
272 *
273 * @tparam The batched discrete domain on which the interpolation points are defined.
274 *
275 * Example: For batched_interpolation_domain_type = DiscreteDomain<X,Y,Z,T> and dimensions of interest X, Y and Z,
276 * this is DiscreteDomain<Deriv<X>, Deriv<Y>, Deriv<Z>, T>.
277 */
278 template <concepts::discrete_domain BatchedInterpolationDDom>
279 using batched_derivs_domain_type
280 = ddc::detail::convert_type_seq_to_discrete_domain_t<ddc::type_seq_replace_t<
281 ddc::to_type_seq_t<BatchedInterpolationDDom>,
282 ddc::detail::TypeSeq<
283 interpolation_discrete_dimension_type1,
284 interpolation_discrete_dimension_type2,
285 interpolation_discrete_dimension_type3>,
286 ddc::detail::TypeSeq<deriv_type1, deriv_type2, deriv_type3>>>;
287
288private:
289 builder_type1 m_spline_builder1;
290 builder_type_2_3 m_spline_builder_2_3;
291
292public:
293 /**
294 * @brief Build a SplineBuilder3D acting on interpolation_domain.
295 *
296 * @param interpolation_domain The domain on which the interpolation points are defined, without the batch dimensions.
297 *
298 * @param cols_per_chunk A parameter used by the slicer (internal to the solver) to define the size
299 * of a chunk of right-hand-sides of the linear problem to be computed in parallel (chunks are treated
300 * by the linear solver one-after-the-other).
301 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
302 *
303 * @param preconditioner_max_block_size A parameter used by the slicer (internal to the solver) to
304 * define the size of a block used by the Block-Jacobi preconditioner.
305 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
306 *
307 * @see SplinesLinearProblemSparse
308 */
309 explicit SplineBuilder3D(
310 interpolation_domain_type const& interpolation_domain,
311 std::optional<std::size_t> cols_per_chunk = std::nullopt,
312 std::optional<unsigned int> preconditioner_max_block_size = std::nullopt)
313 : m_spline_builder1(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
314 , m_spline_builder_2_3(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
315 {
316 }
317
318 /**
319 * @brief Build a SplineBuilder3D acting on the interpolation domain contained in batched_interpolation_domain.
320 *
321 * @param batched_interpolation_domain The domain on which the interpolation points are defined.
322 *
323 * @param cols_per_chunk A parameter used by the slicer (internal to the solver) to define the size
324 * of a chunk of right-hand-sides of the linear problem to be computed in parallel (chunks are treated
325 * by the linear solver one-after-the-other).
326 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
327 *
328 * @param preconditioner_max_block_size A parameter used by the slicer (internal to the solver) to
329 * define the size of a block used by the Block-Jacobi preconditioner.
330 * This value is optional. If no value is provided then the default value is chosen by the requested solver.
331 *
332 * @see SplinesLinearProblemSparse
333 */
334 template <concepts::discrete_domain BatchedInterpolationDDom>
335 explicit SplineBuilder3D(
336 BatchedInterpolationDDom const& batched_interpolation_domain,
337 std::optional<std::size_t> cols_per_chunk = std::nullopt,
338 std::optional<unsigned int> preconditioner_max_block_size = std::nullopt)
340 interpolation_domain_type(batched_interpolation_domain),
341 cols_per_chunk,
342 preconditioner_max_block_size)
343 {
344 }
345
346 /// @brief Copy-constructor is deleted.
347 SplineBuilder3D(SplineBuilder3D const& x) = delete;
348
349 /**
350 * @brief Move-constructs.
351 *
352 * @param x An rvalue to another SplineBuilder3D.
353 */
354 SplineBuilder3D(SplineBuilder3D&& x) = default;
355
356 /// @brief Destructs.
357 ~SplineBuilder3D() = default;
358
359 /// @brief Copy-assignment is deleted.
360 SplineBuilder3D& operator=(SplineBuilder3D const& x) = delete;
361
362 /** @brief Move-assigns.
363 *
364 * @param x An rvalue to another SplineBuilder.
365 * @return A reference to this object.
366 */
368
369 /**
370 * @brief Get the domain for the 3D interpolation mesh used by this class.
371 *
372 * This is 3D because it is defined along the dimensions of interest.
373 *
374 * @return The 3D domain for the interpolation mesh.
375 */
376 interpolation_domain_type interpolation_domain() const noexcept
377 {
378 return ddc::DiscreteDomain<
379 interpolation_domain_type1,
380 interpolation_domain_type2,
381 interpolation_domain_type3>(
382 m_spline_builder1.interpolation_domain(),
383 m_spline_builder_2_3.interpolation_domain());
384 }
385
386 /**
387 * @brief Get the whole domain representing interpolation points.
388 *
389 * Values of the function must be provided on this domain in order
390 * to build a spline representation of the function (cartesian product of 3D interpolation_domain and batch_domain).
391 *
392 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
393 *
394 * @return The domain for the interpolation mesh.
395 */
396 template <concepts::discrete_domain BatchedInterpolationDDom>
397 BatchedInterpolationDDom batched_interpolation_domain(
398 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
399 {
400 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
401 return batched_interpolation_domain;
402 }
403
404 /**
405 * @brief Get the batch domain.
406 *
407 * Obtained by removing the dimensions of interest from the whole interpolation domain.
408 *
409 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
410 *
411 * @return The batch domain.
412 */
413 template <concepts::discrete_domain BatchedInterpolationDDom>
414 batch_domain_type<BatchedInterpolationDDom> batch_domain(
415 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
416 {
417 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
418 return ddc::remove_dims_of(batched_interpolation_domain, interpolation_domain());
419 }
420
421 /**
422 * @brief Get the 3D domain on which spline coefficients are defined.
423 *
424 * The 3D spline domain corresponding to the dimensions of interest.
425 *
426 * @return The 3D domain for the spline coefficients.
427 */
428 ddc::DiscreteDomain<bsplines_type1, bsplines_type2, bsplines_type3> spline_domain()
429 const noexcept
430 {
431 return ddc::DiscreteDomain<bsplines_type1, bsplines_type2, bsplines_type3>(
432 ddc::discrete_space<bsplines_type1>().full_domain(),
433 ddc::discrete_space<bsplines_type2>().full_domain(),
434 ddc::discrete_space<bsplines_type3>().full_domain());
435 }
436
437 /**
438 * @brief Get the whole domain on which spline coefficients are defined.
439 *
440 * Spline approximations (spline-transformed functions) are computed on this domain.
441 *
442 * @param batched_interpolation_domain The whole domain on which the interpolation points are defined.
443 *
444 * @return The domain for the spline coefficients.
445 */
446 template <concepts::discrete_domain BatchedInterpolationDDom>
447 batched_spline_domain_type<BatchedInterpolationDDom> batched_spline_domain(
448 BatchedInterpolationDDom const& batched_interpolation_domain) const noexcept
449 {
450 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
451 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
452 ddc::replace_dim_of<interpolation_discrete_dimension_type2, bsplines_type2>(
453 ddc::replace_dim_of<
454 interpolation_discrete_dimension_type3,
455 bsplines_type3>(batched_interpolation_domain, spline_domain()),
458 }
459
460 /**
461 * @brief Compute a 3D spline approximation of a function.
462 *
463 * Use the values of a function (defined on
464 * SplineBuilder3D::batched_interpolation_domain) and the derivatives of the
465 * function at the boundaries (in the case of BoundCond::HERMITE only)
466 * to calculate a 3D spline approximation of this function.
467 *
468 * The spline approximation is stored as a ChunkSpan of coefficients
469 * associated with B-splines.
470 *
471 * @param[out] spline
472 * The coefficients of the spline computed by this SplineBuilder.
473 * @param[in] vals
474 * The values of the function at the interpolation mesh.
475 * @param[in] derivs_min1
476 * The values of the derivatives at the lower boundary in the first dimension.
477 * @param[in] derivs_max1
478 * The values of the derivatives at the upper boundary in the first dimension.
479 * @param[in] derivs_min2
480 * The values of the derivatives at the lower boundary in the second dimension.
481 * @param[in] derivs_max2
482 * The values of the derivatives at the upper boundary in the second dimension.
483 * @param[in] derivs_min3
484 * The values of the derivatives at the lower boundary in the third dimension.
485 * @param[in] derivs_max3
486 * The values of the derivatives at the upper boundary in the third dimension.
487 * @param[in] mixed_derivs_min1_min2
488 * The values of the the cross-derivatives at the lower boundary in the first dimension and the lower boundary in the second dimension.
489 * @param[in] mixed_derivs_max1_min2
490 * The values of the the cross-derivatives at the upper boundary in the first dimension and the lower boundary in the second dimension.
491 * @param[in] mixed_derivs_min1_max2
492 * The values of the the cross-derivatives at the lower boundary in the first dimension and the upper boundary in the second dimension.
493 * @param[in] mixed_derivs_max1_max2
494 * The values of the the cross-derivatives at the upper boundary in the first dimension and the upper boundary in the second dimension.
495 * @param[in] mixed_derivs_min2_min3
496 * The values of the the cross-derivatives at the lower boundary in the second dimension and the lower boundary in the third dimension.
497 * @param[in] mixed_derivs_max2_min3
498 * The values of the the cross-derivatives at the upper boundary in the second dimension and the lower boundary in the third dimension.
499 * @param[in] mixed_derivs_min2_max3
500 * The values of the the cross-derivatives at the lower boundary in the second dimension and the upper boundary in the third dimension.
501 * @param[in] mixed_derivs_max2_max3
502 * The values of the the cross-derivatives at the upper boundary in the second dimension and the upper boundary in the third dimension.
503 * @param[in] mixed_derivs_min1_min3
504 * The values of the the cross-derivatives at the lower boundary in the first dimension and the lower boundary in the third dimension.
505 * @param[in] mixed_derivs_max1_min3
506 * The values of the the cross-derivatives at the upper boundary in the first dimension and the lower boundary in the third dimension.
507 * @param[in] mixed_derivs_min1_max3
508 * The values of the the cross-derivatives at the lower boundary in the first dimension and the upper boundary in the third dimension.
509 * @param[in] mixed_derivs_max1_max3
510 * The values of the the cross-derivatives at the upper boundary in the first dimension and the upper boundary in the third dimension.
511 * @param[in] mixed_derivs_min1_min2_min3
512 * 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.
513 * @param[in] mixed_derivs_max1_min2_min3
514 * 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.
515 * @param[in] mixed_derivs_min1_max2_min3
516 * 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.
517 * @param[in] mixed_derivs_max1_max2_min3
518 * 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.
519 * @param[in] mixed_derivs_min1_min2_max3
520 * 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.
521 * @param[in] mixed_derivs_max1_min2_max3
522 * 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.
523 * @param[in] mixed_derivs_min1_max2_max3
524 * 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.
525 * @param[in] mixed_derivs_max1_max2_max3
526 * 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.
527 */
528 template <class Layout, class BatchedInterpolationDDom>
529 void operator()(
530 ddc::ChunkSpan<
531 double,
532 batched_spline_domain_type<BatchedInterpolationDDom>,
533 Layout,
534 memory_space> spline,
535 ddc::ChunkSpan<double const, BatchedInterpolationDDom, Layout, memory_space> vals,
536 std::optional<ddc::ChunkSpan<
537 double const,
538 batched_derivs_domain_type1<BatchedInterpolationDDom>,
539 Layout,
540 memory_space>> derivs_min1
541 = std::nullopt,
542 std::optional<ddc::ChunkSpan<
543 double const,
544 batched_derivs_domain_type1<BatchedInterpolationDDom>,
545 Layout,
546 memory_space>> derivs_max1
547 = std::nullopt,
548 std::optional<ddc::ChunkSpan<
549 double const,
550 batched_derivs_domain_type2<BatchedInterpolationDDom>,
551 Layout,
552 memory_space>> derivs_min2
553 = std::nullopt,
554 std::optional<ddc::ChunkSpan<
555 double const,
556 batched_derivs_domain_type2<BatchedInterpolationDDom>,
557 Layout,
558 memory_space>> derivs_max2
559 = std::nullopt,
560 std::optional<ddc::ChunkSpan<
561 double const,
562 batched_derivs_domain_type3<BatchedInterpolationDDom>,
563 Layout,
564 memory_space>> derivs_min3
565 = std::nullopt,
566 std::optional<ddc::ChunkSpan<
567 double const,
568 batched_derivs_domain_type3<BatchedInterpolationDDom>,
569 Layout,
570 memory_space>> derivs_max3
571 = std::nullopt,
572 std::optional<ddc::ChunkSpan<
573 double const,
574 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
575 Layout,
576 memory_space>> mixed_derivs_min1_min2
577 = std::nullopt,
578 std::optional<ddc::ChunkSpan<
579 double const,
580 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
581 Layout,
582 memory_space>> mixed_derivs_max1_min2
583 = std::nullopt,
584 std::optional<ddc::ChunkSpan<
585 double const,
586 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
587 Layout,
588 memory_space>> mixed_derivs_min1_max2
589 = std::nullopt,
590 std::optional<ddc::ChunkSpan<
591 double const,
592 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
593 Layout,
594 memory_space>> mixed_derivs_max1_max2
595 = std::nullopt,
596 std::optional<ddc::ChunkSpan<
597 double const,
598 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
599 Layout,
600 memory_space>> mixed_derivs_min2_min3
601 = std::nullopt,
602 std::optional<ddc::ChunkSpan<
603 double const,
604 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
605 Layout,
606 memory_space>> mixed_derivs_max2_min3
607 = std::nullopt,
608 std::optional<ddc::ChunkSpan<
609 double const,
610 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
611 Layout,
612 memory_space>> mixed_derivs_min2_max3
613 = std::nullopt,
614 std::optional<ddc::ChunkSpan<
615 double const,
616 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
617 Layout,
618 memory_space>> mixed_derivs_max2_max3
619 = std::nullopt,
620 std::optional<ddc::ChunkSpan<
621 double const,
622 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
623 Layout,
624 memory_space>> mixed_derivs_min1_min3
625 = std::nullopt,
626 std::optional<ddc::ChunkSpan<
627 double const,
628 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
629 Layout,
630 memory_space>> mixed_derivs_max1_min3
631 = std::nullopt,
632 std::optional<ddc::ChunkSpan<
633 double const,
634 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
635 Layout,
636 memory_space>> mixed_derivs_min1_max3
637 = std::nullopt,
638 std::optional<ddc::ChunkSpan<
639 double const,
640 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
641 Layout,
642 memory_space>> mixed_derivs_max1_max3
643 = std::nullopt,
644 std::optional<ddc::ChunkSpan<
645 double const,
646 batched_derivs_domain_type<BatchedInterpolationDDom>,
647 Layout,
648 memory_space>> mixed_derivs_min1_min2_min3
649 = std::nullopt,
650 std::optional<ddc::ChunkSpan<
651 double const,
652 batched_derivs_domain_type<BatchedInterpolationDDom>,
653 Layout,
654 memory_space>> mixed_derivs_max1_min2_min3
655 = std::nullopt,
656 std::optional<ddc::ChunkSpan<
657 double const,
658 batched_derivs_domain_type<BatchedInterpolationDDom>,
659 Layout,
660 memory_space>> mixed_derivs_min1_max2_min3
661 = std::nullopt,
662 std::optional<ddc::ChunkSpan<
663 double const,
664 batched_derivs_domain_type<BatchedInterpolationDDom>,
665 Layout,
666 memory_space>> mixed_derivs_max1_max2_min3
667 = std::nullopt,
668 std::optional<ddc::ChunkSpan<
669 double const,
670 batched_derivs_domain_type<BatchedInterpolationDDom>,
671 Layout,
672 memory_space>> mixed_derivs_min1_min2_max3
673 = std::nullopt,
674 std::optional<ddc::ChunkSpan<
675 double const,
676 batched_derivs_domain_type<BatchedInterpolationDDom>,
677 Layout,
678 memory_space>> mixed_derivs_max1_min2_max3
679 = std::nullopt,
680 std::optional<ddc::ChunkSpan<
681 double const,
682 batched_derivs_domain_type<BatchedInterpolationDDom>,
683 Layout,
684 memory_space>> mixed_derivs_min1_max2_max3
685 = std::nullopt,
686 std::optional<ddc::ChunkSpan<
687 double const,
688 batched_derivs_domain_type<BatchedInterpolationDDom>,
689 Layout,
690 memory_space>> mixed_derivs_max1_max2_max3
691 = std::nullopt) const;
692};
693
694
695template <
696 class ExecSpace,
697 class MemorySpace,
698 class BSpline1,
699 class BSpline2,
700 class BSpline3,
701 class DDimI1,
702 class DDimI2,
703 class DDimI3,
711template <class Layout, class BatchedInterpolationDDom>
712void SplineBuilder3D<
713 ExecSpace,
714 MemorySpace,
715 BSpline1,
716 BSpline2,
717 BSpline3,
718 DDimI1,
719 DDimI2,
720 DDimI3,
721 BcLower1,
722 BcUpper1,
723 BcLower2,
724 BcUpper2,
725 BcLower3,
726 BcUpper3,
727 Solver>::
728operator()(
729 ddc::ChunkSpan<
730 double,
731 batched_spline_domain_type<BatchedInterpolationDDom>,
732 Layout,
733 memory_space> spline,
734 ddc::ChunkSpan<double const, BatchedInterpolationDDom, Layout, memory_space> vals,
735 std::optional<ddc::ChunkSpan<
736 double const,
737 batched_derivs_domain_type1<BatchedInterpolationDDom>,
738 Layout,
739 memory_space>> derivs_min1,
740 std::optional<ddc::ChunkSpan<
741 double const,
742 batched_derivs_domain_type1<BatchedInterpolationDDom>,
743 Layout,
744 memory_space>> derivs_max1,
745 std::optional<ddc::ChunkSpan<
746 double const,
747 batched_derivs_domain_type2<BatchedInterpolationDDom>,
748 Layout,
749 memory_space>> derivs_min2,
750 std::optional<ddc::ChunkSpan<
751 double const,
752 batched_derivs_domain_type2<BatchedInterpolationDDom>,
753 Layout,
754 memory_space>> derivs_max2,
755 std::optional<ddc::ChunkSpan<
756 double const,
757 batched_derivs_domain_type3<BatchedInterpolationDDom>,
758 Layout,
759 memory_space>> derivs_min3,
760 std::optional<ddc::ChunkSpan<
761 double const,
762 batched_derivs_domain_type3<BatchedInterpolationDDom>,
763 Layout,
764 memory_space>> derivs_max3,
765 std::optional<ddc::ChunkSpan<
766 double const,
767 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
768 Layout,
769 memory_space>> mixed_derivs_min1_min2,
770 std::optional<ddc::ChunkSpan<
771 double const,
772 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
773 Layout,
774 memory_space>> mixed_derivs_max1_min2,
775 std::optional<ddc::ChunkSpan<
776 double const,
777 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
778 Layout,
779 memory_space>> mixed_derivs_min1_max2,
780 std::optional<ddc::ChunkSpan<
781 double const,
782 batched_derivs_domain_type1_2<BatchedInterpolationDDom>,
783 Layout,
784 memory_space>> mixed_derivs_max1_max2,
785 std::optional<ddc::ChunkSpan<
786 double const,
787 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
788 Layout,
789 memory_space>> mixed_derivs_min2_min3,
790 std::optional<ddc::ChunkSpan<
791 double const,
792 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
793 Layout,
794 memory_space>> mixed_derivs_max2_min3,
795 std::optional<ddc::ChunkSpan<
796 double const,
797 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
798 Layout,
799 memory_space>> mixed_derivs_min2_max3,
800 std::optional<ddc::ChunkSpan<
801 double const,
802 batched_derivs_domain_type2_3<BatchedInterpolationDDom>,
803 Layout,
804 memory_space>> mixed_derivs_max2_max3,
805 std::optional<ddc::ChunkSpan<
806 double const,
807 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
808 Layout,
809 memory_space>> mixed_derivs_min1_min3,
810 std::optional<ddc::ChunkSpan<
811 double const,
812 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
813 Layout,
814 memory_space>> mixed_derivs_max1_min3,
815 std::optional<ddc::ChunkSpan<
816 double const,
817 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
818 Layout,
819 memory_space>> mixed_derivs_min1_max3,
820 std::optional<ddc::ChunkSpan<
821 double const,
822 batched_derivs_domain_type1_3<BatchedInterpolationDDom>,
823 Layout,
824 memory_space>> mixed_derivs_max1_max3,
825 std::optional<ddc::ChunkSpan<
826 double const,
827 batched_derivs_domain_type<BatchedInterpolationDDom>,
828 Layout,
829 memory_space>> mixed_derivs_min1_min2_min3,
830 std::optional<ddc::ChunkSpan<
831 double const,
832 batched_derivs_domain_type<BatchedInterpolationDDom>,
833 Layout,
834 memory_space>> mixed_derivs_max1_min2_min3,
835 std::optional<ddc::ChunkSpan<
836 double const,
837 batched_derivs_domain_type<BatchedInterpolationDDom>,
838 Layout,
839 memory_space>> mixed_derivs_min1_max2_min3,
840 std::optional<ddc::ChunkSpan<
841 double const,
842 batched_derivs_domain_type<BatchedInterpolationDDom>,
843 Layout,
844 memory_space>> mixed_derivs_max1_max2_min3,
845 std::optional<ddc::ChunkSpan<
846 double const,
847 batched_derivs_domain_type<BatchedInterpolationDDom>,
848 Layout,
849 memory_space>> mixed_derivs_min1_min2_max3,
850 std::optional<ddc::ChunkSpan<
851 double const,
852 batched_derivs_domain_type<BatchedInterpolationDDom>,
853 Layout,
854 memory_space>> mixed_derivs_max1_min2_max3,
855 std::optional<ddc::ChunkSpan<
856 double const,
857 batched_derivs_domain_type<BatchedInterpolationDDom>,
858 Layout,
859 memory_space>> mixed_derivs_min1_max2_max3,
860 std::optional<ddc::ChunkSpan<
861 double const,
862 batched_derivs_domain_type<BatchedInterpolationDDom>,
863 Layout,
864 memory_space>> mixed_derivs_max1_max2_max3) const
865{
866 auto const batched_interpolation_domain = vals.domain();
867
868 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
869 assert(batch_domain_type<BatchedInterpolationDDom>(batched_interpolation_domain)
870 == batch_domain_type<BatchedInterpolationDDom>(spline.domain()));
871
872 if (batch_domain(batched_interpolation_domain).empty()) {
873 return;
874 }
875
876 // Build the derivatives along the second dimension
877 auto const batched_interpolation_deriv_domain2
878 = ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
879 batched_interpolation_domain,
880 ddc::DiscreteDomain<deriv_type2>(
881 ddc::DiscreteElement<deriv_type2>(BSpline2::degree() % 2),
882 ddc::DiscreteVector<deriv_type2>(bsplines_type2::degree() / 2)));
883
884 ddc::Chunk spline_derivs_min2_alloc(
885 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2),
886 ddc::KokkosAllocator<double, MemorySpace>());
887 auto spline_derivs_min2 = spline_derivs_min2_alloc.span_view();
888 auto spline_derivs_min2_opt = std::optional(spline_derivs_min2.span_cview());
889 if constexpr (BcLower2 == ddc::BoundCond::HERMITE) {
890 m_spline_builder1(
891 spline_derivs_min2,
892 *derivs_min2,
893 mixed_derivs_min1_min2,
894 mixed_derivs_max1_min2);
895 } else {
896 spline_derivs_min2_opt = std::nullopt;
897 }
898
899 ddc::Chunk spline_derivs_max2_alloc(
900 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2),
901 ddc::KokkosAllocator<double, MemorySpace>());
902 auto spline_derivs_max2 = spline_derivs_max2_alloc.span_view();
903 auto spline_derivs_max2_opt = std::optional(spline_derivs_max2.span_cview());
904 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE) {
905 m_spline_builder1(
906 spline_derivs_max2,
907 *derivs_max2,
908 mixed_derivs_min1_max2,
909 mixed_derivs_max1_max2);
910 } else {
911 spline_derivs_max2_opt = std::nullopt;
912 }
913
914 // Build the derivatives along the third dimension
915 auto const batched_interpolation_deriv_domain3
916 = ddc::replace_dim_of<interpolation_discrete_dimension_type3, deriv_type3>(
917 batched_interpolation_domain,
918 ddc::DiscreteDomain<deriv_type3>(
919 ddc::DiscreteElement<deriv_type3>(BSpline3::degree() % 2),
920 ddc::DiscreteVector<deriv_type3>(bsplines_type3::degree() / 2)));
921
922 ddc::Chunk spline_derivs_min3_alloc(
923 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain3),
924 ddc::KokkosAllocator<double, MemorySpace>());
925 auto spline_derivs_min3 = spline_derivs_min3_alloc.span_view();
926 auto spline_derivs_min3_opt = std::optional(spline_derivs_min3.span_cview());
927 if constexpr (BcLower3 == ddc::BoundCond::HERMITE) {
928 m_spline_builder1(
929 spline_derivs_min3,
930 *derivs_min3,
931 mixed_derivs_min1_min3,
932 mixed_derivs_max1_min3);
933 } else {
934 spline_derivs_min3_opt = std::nullopt;
935 }
936
937 ddc::Chunk spline_derivs_max3_alloc(
938 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain3),
939 ddc::KokkosAllocator<double, MemorySpace>());
940 auto spline_derivs_max3 = spline_derivs_max3_alloc.span_view();
941 auto spline_derivs_max3_opt = std::optional(spline_derivs_max3.span_cview());
942 if constexpr (BcUpper3 == ddc::BoundCond::HERMITE) {
943 m_spline_builder1(
944 spline_derivs_max3,
945 *derivs_max3,
946 mixed_derivs_min1_max3,
947 mixed_derivs_max1_max3);
948 } else {
949 spline_derivs_max3_opt = std::nullopt;
950 }
951
952 // Build the cross derivatives along the second and third dimensions
953 auto batched_interpolation_deriv_domain2_3
954 = ddc::replace_dim_of<interpolation_discrete_dimension_type3, deriv_type3>(
955 batched_interpolation_deriv_domain2,
956 ddc::DiscreteDomain<deriv_type3>(
957 ddc::DiscreteElement<deriv_type3>(BSpline3::degree() % 2),
958 ddc::DiscreteVector<deriv_type3>(bsplines_type3::degree() / 2)));
959
960 ddc::Chunk spline_derivs_min2_min3_alloc(
961 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
962 ddc::KokkosAllocator<double, MemorySpace>());
963 auto spline_derivs_min2_min3 = spline_derivs_min2_min3_alloc.span_view();
964 auto spline_derivs_min2_min3_opt = std::optional(spline_derivs_min2_min3.span_cview());
965 if constexpr (BcLower2 == ddc::BoundCond::HERMITE || BcLower3 == ddc::BoundCond::HERMITE) {
966 m_spline_builder1(
967 spline_derivs_min2_min3,
968 *mixed_derivs_min2_min3,
969 mixed_derivs_min1_min2_min3,
970 mixed_derivs_max1_min2_min3);
971 } else {
972 spline_derivs_min2_min3_opt = std::nullopt;
973 }
974
975 ddc::Chunk spline_derivs_min2_max3_alloc(
976 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
977 ddc::KokkosAllocator<double, MemorySpace>());
978 auto spline_derivs_min2_max3 = spline_derivs_min2_max3_alloc.span_view();
979 auto spline_derivs_min2_max3_opt = std::optional(spline_derivs_min2_max3.span_cview());
980 if constexpr (BcLower2 == ddc::BoundCond::HERMITE || BcUpper3 == ddc::BoundCond::HERMITE) {
981 m_spline_builder1(
982 spline_derivs_min2_max3,
983 *mixed_derivs_min2_max3,
984 mixed_derivs_min1_min2_max3,
985 mixed_derivs_max1_min2_max3);
986 } else {
987 spline_derivs_min2_max3_opt = std::nullopt;
988 }
989
990 ddc::Chunk spline_derivs_max2_min3_alloc(
991 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
992 ddc::KokkosAllocator<double, MemorySpace>());
993 auto spline_derivs_max2_min3 = spline_derivs_max2_min3_alloc.span_view();
994 auto spline_derivs_max2_min3_opt = std::optional(spline_derivs_max2_min3.span_cview());
995 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE || BcLower3 == ddc::BoundCond::HERMITE) {
996 m_spline_builder1(
997 spline_derivs_max2_min3,
998 *mixed_derivs_max2_min3,
999 mixed_derivs_min1_max2_min3,
1000 mixed_derivs_max1_max2_min3);
1001 } else {
1002 spline_derivs_max2_min3_opt = std::nullopt;
1003 }
1004
1005 ddc::Chunk spline_derivs_max2_max3_alloc(
1006 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain2_3),
1007 ddc::KokkosAllocator<double, MemorySpace>());
1008 auto spline_derivs_max2_max3 = spline_derivs_max2_max3_alloc.span_view();
1009 auto spline_derivs_max2_max3_opt = std::optional(spline_derivs_max2_max3.span_cview());
1010 if constexpr (BcUpper2 == ddc::BoundCond::HERMITE || BcUpper3 == ddc::BoundCond::HERMITE) {
1011 m_spline_builder1(
1012 spline_derivs_max2_max3,
1013 *mixed_derivs_max2_max3,
1014 mixed_derivs_min1_max2_max3,
1015 mixed_derivs_max1_max2_max3);
1016 } else {
1017 spline_derivs_max2_max3_opt = std::nullopt;
1018 }
1019
1020 // Spline1-approximate vals (to spline1)
1021 ddc::Chunk spline1_alloc(
1022 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
1023 ddc::KokkosAllocator<double, MemorySpace>());
1024 ddc::ChunkSpan const spline1 = spline1_alloc.span_view();
1025
1026 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
1027
1028 m_spline_builder_2_3(
1029 spline,
1030 spline1.span_cview(),
1031 spline_derivs_min2_opt,
1032 spline_derivs_max2_opt,
1033 spline_derivs_min3_opt,
1034 spline_derivs_max3_opt,
1035 spline_derivs_min2_min3_opt,
1036 spline_derivs_max2_min3_opt,
1037 spline_derivs_min2_max3_opt,
1038 spline_derivs_max2_max3_opt);
1039}
1040
1041} // 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