14#include "spline_builder.hpp"
19
20
21
22
23
24
25
46 using exec_space = ExecSpace;
49 using memory_space = MemorySpace;
52 using builder_type1 =
ddc::
53 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
56 using builder_type2 =
ddc::
57 SplineBuilder<ExecSpace, MemorySpace, BSpline2, DDimI2, BcLower2, BcUpper2, Solver>;
60 using builder_type3 =
ddc::
61 SplineBuilder<ExecSpace, MemorySpace, BSpline3, DDimI3, BcLower3, BcUpper3, Solver>;
64 using builder_deriv_type1 =
ddc::
65 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
68 using builder_deriv_type2 =
ddc::
69 SplineBuilder<ExecSpace, MemorySpace, BSpline2, DDimI2, BcLower2, BcUpper2, Solver>;
72 using continuous_dimension_type1 =
typename builder_type1::continuous_dimension_type;
75 using continuous_dimension_type2 =
typename builder_type2::continuous_dimension_type;
78 using continuous_dimension_type3 =
typename builder_type3::continuous_dimension_type;
81 using interpolation_discrete_dimension_type1 =
82 typename builder_type1::interpolation_discrete_dimension_type;
85 using interpolation_discrete_dimension_type2 =
86 typename builder_type2::interpolation_discrete_dimension_type;
89 using interpolation_discrete_dimension_type3 =
90 typename builder_type3::interpolation_discrete_dimension_type;
93 using bsplines_type1 =
typename builder_type1::bsplines_type;
96 using bsplines_type2 =
typename builder_type2::bsplines_type;
99 using bsplines_type3 =
typename builder_type3::bsplines_type;
102 using deriv_type1 =
typename builder_type1::deriv_type;
105 using deriv_type2 =
typename builder_type2::deriv_type;
108 using deriv_type3 =
typename builder_type3::deriv_type;
111 using interpolation_domain_type1 =
112 typename builder_type1::interpolation_discrete_dimension_type;
115 using interpolation_domain_type2 =
116 typename builder_type2::interpolation_discrete_dimension_type;
119 using interpolation_domain_type3 =
120 typename builder_type3::interpolation_discrete_dimension_type;
124 interpolation_discrete_dimension_type1,
125 interpolation_discrete_dimension_type2,
126 interpolation_discrete_dimension_type3>;
129
130
131
132
134 class BatchedInterpolationDDom,
135 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
136 using batched_interpolation_domain_type = BatchedInterpolationDDom;
139
140
141
142
143
144
145
146
148 class BatchedInterpolationDDom,
149 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
150 using batch_domain_type =
ddc::remove_dims_of_t<
151 BatchedInterpolationDDom,
152 interpolation_discrete_dimension_type1,
153 interpolation_discrete_dimension_type2,
154 interpolation_discrete_dimension_type3>;
157
158
159
160
161
162
163
164
166 class BatchedInterpolationDDom,
167 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
168 using batched_spline_domain_type
169 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
170 ddc::to_type_seq_t<BatchedInterpolationDDom>,
171 ddc::detail::TypeSeq<
172 interpolation_discrete_dimension_type1,
173 interpolation_discrete_dimension_type2,
174 interpolation_discrete_dimension_type3>,
175 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2, bsplines_type3>>>;
178
179
180
181
182
183
184
185
187 class BatchedInterpolationDDom,
188 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
189 using batched_derivs_domain_type1 =
190 typename builder_type1::
template batched_derivs_domain_type<BatchedInterpolationDDom>;
193
194
195
196
197
198
199
200
202 class BatchedInterpolationDDom,
203 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
204 using batched_derivs_domain_type2 =
ddc::replace_dim_of_t<
205 BatchedInterpolationDDom,
206 interpolation_discrete_dimension_type2,
210
211
212
213
214
215
216
217
219 class BatchedInterpolationDDom,
220 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
221 using batched_derivs_domain_type3 =
ddc::replace_dim_of_t<
222 BatchedInterpolationDDom,
223 interpolation_discrete_dimension_type3,
227
228
229
230
231
232
233
234
236 class BatchedInterpolationDDom,
237 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
238 using batched_derivs_domain_type
239 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
240 ddc::to_type_seq_t<BatchedInterpolationDDom>,
241 ddc::detail::TypeSeq<
242 interpolation_discrete_dimension_type1,
243 interpolation_discrete_dimension_type2,
244 interpolation_discrete_dimension_type3>,
245 ddc::detail::TypeSeq<deriv_type1, deriv_type2, deriv_type3>>>;
248 builder_type1 m_spline_builder1;
249 builder_type2 m_spline_builder2;
250 builder_type3 m_spline_builder3;
251 builder_deriv_type1 m_spline_builder_deriv1;
252 builder_deriv_type2 m_spline_builder_deriv2;
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
272 interpolation_domain_type
const& interpolation_domain,
273 std::optional<std::size_t> cols_per_chunk = std::nullopt,
274 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
275 : m_spline_builder1(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
276 , m_spline_builder2(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
277 , m_spline_builder3(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
278 , m_spline_builder_deriv1(interpolation_domain)
279 , m_spline_builder_deriv2(interpolation_domain)
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
300 class BatchedInterpolationDDom,
301 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
303 BatchedInterpolationDDom
const& batched_interpolation_domain,
304 std::optional<std::size_t> cols_per_chunk = std::nullopt,
305 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
307 interpolation_domain_type(batched_interpolation_domain),
309 preconditioner_max_block_size)
317
318
319
320
330
331
332
333
337
338
339
340
341
342
346 interpolation_domain_type1,
347 interpolation_domain_type2,
348 interpolation_domain_type3>(
349 m_spline_builder1.interpolation_domain(),
350 m_spline_builder2.interpolation_domain(),
351 m_spline_builder3.interpolation_domain());
355
356
357
358
359
360
361
362
363
365 class BatchedInterpolationDDom,
366 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
368 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
370 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
371 return batched_interpolation_domain;
375
376
377
378
379
380
381
382
384 class BatchedInterpolationDDom,
385 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
386 batch_domain_type<BatchedInterpolationDDom>
batch_domain(
387 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
389 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
394
395
396
397
398
399
404 ddc::discrete_space<bsplines_type1>().full_domain(),
405 ddc::discrete_space<bsplines_type2>().full_domain(),
406 ddc::discrete_space<bsplines_type3>().full_domain());
410
411
412
413
414
415
416
417
419 class BatchedInterpolationDDom,
420 class = std::enable_if_t<
ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
422 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
424 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
425 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
426 ddc::replace_dim_of<interpolation_discrete_dimension_type2, bsplines_type2>(
428 interpolation_discrete_dimension_type3,
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478 template <
class Layout,
class BatchedInterpolationDDom>
482 batched_spline_domain_type<BatchedInterpolationDDom>,
484 memory_space> spline,
485 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
488 batched_derivs_domain_type1<BatchedInterpolationDDom>,
490 memory_space>> derivs_min1
494 batched_derivs_domain_type1<BatchedInterpolationDDom>,
496 memory_space>> derivs_max1
500 batched_derivs_domain_type2<BatchedInterpolationDDom>,
502 memory_space>> derivs_min2
506 batched_derivs_domain_type2<BatchedInterpolationDDom>,
508 memory_space>> derivs_max2
512 batched_derivs_domain_type3<BatchedInterpolationDDom>,
514 memory_space>> derivs_min3
518 batched_derivs_domain_type3<BatchedInterpolationDDom>,
520 memory_space>> derivs_max3
524 batched_derivs_domain_type<BatchedInterpolationDDom>,
526 memory_space>> mixed_derivs_min1_min2_min3
530 batched_derivs_domain_type<BatchedInterpolationDDom>,
532 memory_space>> mixed_derivs_max1_min2_min3
536 batched_derivs_domain_type<BatchedInterpolationDDom>,
538 memory_space>> mixed_derivs_min1_max2_min3
542 batched_derivs_domain_type<BatchedInterpolationDDom>,
544 memory_space>> mixed_derivs_max1_max2_min3
548 batched_derivs_domain_type<BatchedInterpolationDDom>,
550 memory_space>> mixed_derivs_min1_min2_max3
554 batched_derivs_domain_type<BatchedInterpolationDDom>,
556 memory_space>> mixed_derivs_max1_min2_max3
560 batched_derivs_domain_type<BatchedInterpolationDDom>,
562 memory_space>> mixed_derivs_min1_max2_max3
566 batched_derivs_domain_type<BatchedInterpolationDDom>,
568 memory_space>> mixed_derivs_max1_max2_max3
569 = std::nullopt)
const;
589template <
class Layout,
class BatchedInterpolationDDom>
609 batched_spline_domain_type<BatchedInterpolationDDom>,
611 memory_space> spline,
612 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
615 batched_derivs_domain_type1<BatchedInterpolationDDom>,
617 memory_space>> derivs_min1,
620 batched_derivs_domain_type1<BatchedInterpolationDDom>,
622 memory_space>> derivs_max1,
625 batched_derivs_domain_type2<BatchedInterpolationDDom>,
627 memory_space>> derivs_min2,
630 batched_derivs_domain_type2<BatchedInterpolationDDom>,
632 memory_space>> derivs_max2,
635 batched_derivs_domain_type3<BatchedInterpolationDDom>,
637 memory_space>> derivs_min3,
640 batched_derivs_domain_type3<BatchedInterpolationDDom>,
642 memory_space>> derivs_max3,
645 batched_derivs_domain_type<BatchedInterpolationDDom>,
647 memory_space>> mixed_derivs_min1_min2_min3,
650 batched_derivs_domain_type<BatchedInterpolationDDom>,
652 memory_space>> mixed_derivs_max1_min2_min3,
655 batched_derivs_domain_type<BatchedInterpolationDDom>,
657 memory_space>> mixed_derivs_min1_max2_min3,
660 batched_derivs_domain_type<BatchedInterpolationDDom>,
662 memory_space>> mixed_derivs_max1_max2_min3,
665 batched_derivs_domain_type<BatchedInterpolationDDom>,
667 memory_space>> mixed_derivs_min1_min2_max3,
670 batched_derivs_domain_type<BatchedInterpolationDDom>,
672 memory_space>> mixed_derivs_max1_min2_max3,
675 batched_derivs_domain_type<BatchedInterpolationDDom>,
677 memory_space>> mixed_derivs_min1_max2_max3,
680 batched_derivs_domain_type<BatchedInterpolationDDom>,
682 memory_space>> mixed_derivs_max1_max2_max3)
const
684 auto const batched_interpolation_domain = vals.domain();
686 assert(interpolation_domain() == interpolation_domain_type(batched_interpolation_domain));
690 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
692 ddc::
ChunkSpan const spline1 = spline1_alloc.span_view();
694 m_spline_builder1(spline1, vals);
698 m_spline_builder2.batched_spline_domain(spline1.domain()),
700 ddc::
ChunkSpan const spline2 = spline2_alloc.span_view();
702 m_spline_builder2(spline2, spline1.span_cview());
705 m_spline_builder3(spline, spline2.span_cview());
friend class DiscreteDomain
A class for creating a 3D spline approximation of a function.
SplineBuilder3D(SplineBuilder3D const &x)=delete
Copy-constructor is deleted.
~SplineBuilder3D()=default
Destructs.
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.
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.
batch_domain_type< BatchedInterpolationDDom > batch_domain(BatchedInterpolationDDom const &batched_interpolation_domain) const noexcept
Get the batch domain.
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.
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_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 & operator=(SplineBuilder3D &&x)=default
Move-assigns.
A class for creating a spline approximation of a function.
The top-level namespace of DDC.
BoundCond
An enum representing a spline boundary condition.
SplineSolver
An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.