13#include "spline_builder.hpp"
18
19
20
21
22
23
24
42 using exec_space = ExecSpace;
45 using memory_space = MemorySpace;
67 std::conditional_t<std::is_same_v<IDimX, IDimI1>, BSpline1, IDimX>...>;
79 std::is_same_v<IDimX, IDimI2>,
80 typename builder_type2::deriv_type,
84 using continuous_dimension_type1 =
typename builder_type1::continuous_dimension_type;
87 using continuous_dimension_type2 =
typename builder_type2::continuous_dimension_type;
90 using interpolation_discrete_dimension_type1 =
91 typename builder_type1::interpolation_discrete_dimension_type;
94 using interpolation_discrete_dimension_type2 =
95 typename builder_type2::interpolation_discrete_dimension_type;
98 using bsplines_type1 =
typename builder_type1::bsplines_type;
101 using bsplines_type2 =
typename builder_type2::bsplines_type;
104 using deriv_type1 =
typename builder_type1::deriv_type;
107 using deriv_type2 =
typename builder_type2::deriv_type;
110 using interpolation_domain_type1 =
111 typename builder_type1::interpolation_discrete_dimension_type;
114 using interpolation_domain_type2 =
115 typename builder_type2::interpolation_discrete_dimension_type;
119 interpolation_discrete_dimension_type1,
120 interpolation_discrete_dimension_type2>;
126
127
128
129
130
131
132 using batch_domain_type =
ddc::remove_dims_of_t<
133 batched_interpolation_domain_type,
134 interpolation_discrete_dimension_type1,
135 interpolation_discrete_dimension_type2>;
138
139
140
141
142
143
144 using batched_spline_domain_type
145 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
146 ddc::detail::TypeSeq<IDimX...>,
147 ddc::detail::TypeSeq<
148 interpolation_discrete_dimension_type1,
149 interpolation_discrete_dimension_type2>,
150 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
153
154
155
156
157
158
159 using batched_derivs_domain_type1 =
typename builder_type1::batched_derivs_domain_type;
162
163
164
165
166
167
168 using batched_derivs_domain_type2 =
ddc::replace_dim_of_t<
169 batched_interpolation_domain_type,
170 interpolation_discrete_dimension_type2,
174
175
176
177
178
179
180 using batched_derivs_domain_type
181 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
182 ddc::detail::TypeSeq<IDimX...>,
183 ddc::detail::TypeSeq<
184 interpolation_discrete_dimension_type1,
185 interpolation_discrete_dimension_type2>,
186 ddc::detail::TypeSeq<deriv_type1, deriv_type2>>>;
189 builder_type1 m_spline_builder1;
190 builder_deriv_type1 m_spline_builder_deriv1;
191 builder_type2 m_spline_builder2;
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
211 batched_interpolation_domain_type
const& batched_interpolation_domain,
212 std::optional<std::size_t> cols_per_chunk = std::nullopt,
213 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
215 batched_interpolation_domain,
217 preconditioner_max_block_size)
218 , m_spline_builder_deriv1(
219 ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
220 m_spline_builder1.batched_interpolation_domain(),
222 ddc::DiscreteElement<deriv_type2>(1),
225 m_spline_builder1.batched_spline_domain(),
227 preconditioner_max_block_size)
235
236
237
238
248
249
250
251
255
256
257
258
259
260
263 return ddc::
DiscreteDomain<interpolation_domain_type1, interpolation_domain_type2>(
264 m_spline_builder1.interpolation_domain(),
265 m_spline_builder2.interpolation_domain());
269
270
271
272
273
274
275
278 return m_spline_builder1.batched_interpolation_domain();
282
283
284
285
286
287
294
295
296
297
298
299
303 ddc::discrete_space<bsplines_type1>().full_domain(),
304 ddc::discrete_space<bsplines_type2>().full_domain());
308
309
310
311
312
313
316 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
318 interpolation_discrete_dimension_type2,
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359 template <
class Layout>
361 ddc::
ChunkSpan<
double, batched_spline_domain_type, Layout, memory_space> spline,
362 ddc::
ChunkSpan<
double const, batched_interpolation_domain_type, Layout, memory_space>
365 ddc::
ChunkSpan<
double const, batched_derivs_domain_type1, Layout, memory_space>>
369 ddc::
ChunkSpan<
double const, batched_derivs_domain_type1, Layout, memory_space>>
373 ddc::
ChunkSpan<
double const, batched_derivs_domain_type2, Layout, memory_space>>
377 ddc::
ChunkSpan<
double const, batched_derivs_domain_type2, Layout, memory_space>>
381 ddc::
ChunkSpan<
double const, batched_derivs_domain_type, Layout, memory_space>>
382 mixed_derivs_min1_min2
385 ddc::
ChunkSpan<
double const, batched_derivs_domain_type, Layout, memory_space>>
386 mixed_derivs_max1_min2
389 ddc::
ChunkSpan<
double const, batched_derivs_domain_type, Layout, memory_space>>
390 mixed_derivs_min1_max2
393 ddc::
ChunkSpan<
double const, batched_derivs_domain_type, Layout, memory_space>>
394 mixed_derivs_max1_max2
395 = std::nullopt)
const;
412template <
class Layout>
427 ddc::
ChunkSpan<
double, batched_spline_domain_type, Layout, memory_space> spline,
428 ddc::
ChunkSpan<
double const, batched_interpolation_domain_type, Layout, memory_space> vals,
431 batched_derivs_domain_type1,
433 memory_space>>
const derivs_min1,
436 batched_derivs_domain_type1,
438 memory_space>>
const derivs_max1,
441 batched_derivs_domain_type2,
443 memory_space>>
const derivs_min2,
446 batched_derivs_domain_type2,
448 memory_space>>
const derivs_max2,
451 batched_derivs_domain_type,
453 memory_space>>
const mixed_derivs_min1_min2,
456 batched_derivs_domain_type,
458 memory_space>>
const mixed_derivs_max1_min2,
461 batched_derivs_domain_type,
463 memory_space>>
const mixed_derivs_min1_max2,
466 batched_derivs_domain_type,
468 memory_space>>
const mixed_derivs_max1_max2)
const
473 m_spline_builder_deriv1.batched_spline_domain(),
475 auto spline1_deriv_min = spline1_deriv_min_alloc.span_view();
476 auto spline1_deriv_min_opt = std::optional(spline1_deriv_min.span_cview());
478 m_spline_builder_deriv1(
481 mixed_derivs_min1_min2,
482 mixed_derivs_max1_min2);
484 spline1_deriv_min_opt = std::nullopt;
489 m_spline_builder1.batched_spline_domain(),
491 ddc::
ChunkSpan const spline1 = spline1_alloc.span_view();
493 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
497 m_spline_builder_deriv1.batched_spline_domain(),
499 auto spline1_deriv_max = spline1_deriv_max_alloc.span_view();
500 auto spline1_deriv_max_opt = std::optional(spline1_deriv_max.span_cview());
502 m_spline_builder_deriv1(
505 mixed_derivs_min1_max2,
506 mixed_derivs_max1_max2);
508 spline1_deriv_max_opt = std::nullopt;
512 m_spline_builder2(spline, spline1.span_cview(), spline1_deriv_min_opt, spline1_deriv_max_opt);
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
A class for creating a 2D spline approximation of a function.
SplineBuilder2D(SplineBuilder2D const &x)=delete
Copy-constructor is deleted.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2 > spline_domain() const noexcept
Get the 2D domain on which spline coefficients are defined.
SplineBuilder2D(batched_interpolation_domain_type 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 batched_interpolation_domain.
batched_interpolation_domain_type batched_interpolation_domain() const noexcept
Get the whole domain representing interpolation points.
batched_spline_domain_type batched_spline_domain() const noexcept
Get the whole domain on which spline coefficients are defined.
SplineBuilder2D & operator=(SplineBuilder2D const &x)=delete
Copy-assignment is deleted.
void operator()(ddc::ChunkSpan< double, batched_spline_domain_type, Layout, memory_space > spline, ddc::ChunkSpan< double const, batched_interpolation_domain_type, Layout, memory_space > vals, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1, Layout, memory_space > > derivs_min1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type1, Layout, memory_space > > derivs_max1=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2, Layout, memory_space > > derivs_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type2, Layout, memory_space > > derivs_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type, Layout, memory_space > > mixed_derivs_min1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type, Layout, memory_space > > mixed_derivs_max1_min2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type, Layout, memory_space > > mixed_derivs_min1_max2=std::nullopt, std::optional< ddc::ChunkSpan< double const, batched_derivs_domain_type, Layout, memory_space > > mixed_derivs_max1_max2=std::nullopt) const
Compute a 2D spline approximation of a function.
~SplineBuilder2D()=default
Destructs.
interpolation_domain_type interpolation_domain() const noexcept
Get the domain for the 2D interpolation mesh used by this class.
batch_domain_type batch_domain() const noexcept
Get the batch domain.
SplineBuilder2D & operator=(SplineBuilder2D &&x)=default
Move-assigns.
SplineBuilder2D(SplineBuilder2D &&x)=default
Move-constructs.
A class for creating a spline approximation of a function.
The top-level namespace of DDC.
BoundCond
An enum representing a spline boundary condition.
@ HERMITE
Hermite boundary condition.
SplineSolver
An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.