20
21
22
23
24
25
26
43 using exec_space = ExecSpace;
46 using memory_space = MemorySpace;
49 using builder_type1 =
ddc::
50 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
53 using builder_type2 =
ddc::
54 SplineBuilder<ExecSpace, MemorySpace, BSpline2, DDimI2, BcLower2, BcUpper2, Solver>;
57 using continuous_dimension_type1 = builder_type1::continuous_dimension_type;
60 using continuous_dimension_type2 = builder_type2::continuous_dimension_type;
63 using interpolation_discrete_dimension_type1
64 = builder_type1::interpolation_discrete_dimension_type;
67 using interpolation_discrete_dimension_type2
68 = builder_type2::interpolation_discrete_dimension_type;
71 using bsplines_type1 = builder_type1::bsplines_type;
74 using bsplines_type2 = builder_type2::bsplines_type;
77 using deriv_type1 = builder_type1::deriv_type;
80 using deriv_type2 = builder_type2::deriv_type;
83 using interpolation_domain_type1 = builder_type1::interpolation_discrete_dimension_type;
86 using interpolation_domain_type2 = builder_type2::interpolation_discrete_dimension_type;
90 interpolation_discrete_dimension_type1,
91 interpolation_discrete_dimension_type2>;
94
95
96
97
98 template <concepts::discrete_domain BatchedInterpolationDDom>
99 using batched_interpolation_domain_type = BatchedInterpolationDDom;
102
103
104
105
106
107
108
109
110 template <concepts::discrete_domain BatchedInterpolationDDom>
111 using batch_domain_type =
ddc::remove_dims_of_t<
112 BatchedInterpolationDDom,
113 interpolation_discrete_dimension_type1,
114 interpolation_discrete_dimension_type2>;
117
118
119
120
121
122
123
124
125 template <concepts::discrete_domain BatchedInterpolationDDom>
126 using batched_spline_domain_type
127 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
128 ddc::to_type_seq_t<BatchedInterpolationDDom>,
129 ddc::detail::TypeSeq<
130 interpolation_discrete_dimension_type1,
131 interpolation_discrete_dimension_type2>,
132 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
135
136
137
138
139
140
141
142
143 template <concepts::discrete_domain BatchedInterpolationDDom>
144 using batched_derivs_domain_type1
145 = builder_type1::
template batched_derivs_domain_type<BatchedInterpolationDDom>;
148
149
150
151
152
153
154
155
156 template <concepts::discrete_domain BatchedInterpolationDDom>
157 using batched_derivs_domain_type2 =
ddc::replace_dim_of_t<
158 BatchedInterpolationDDom,
159 interpolation_discrete_dimension_type2,
163
164
165
166
167
168
169
170
171 template <concepts::discrete_domain BatchedInterpolationDDom>
172 using batched_derivs_domain_type
173 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
174 ddc::to_type_seq_t<BatchedInterpolationDDom>,
175 ddc::detail::TypeSeq<
176 interpolation_discrete_dimension_type1,
177 interpolation_discrete_dimension_type2>,
178 ddc::detail::TypeSeq<deriv_type1, deriv_type2>>>;
181 builder_type1 m_spline_builder1;
182 builder_type2 m_spline_builder2;
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
205 std::string
const& label,
206 interpolation_domain_type
const& interpolation_domain,
207 std::optional<std::size_t> cols_per_chunk = std::nullopt,
208 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
211 interpolation_domain,
213 preconditioner_max_block_size)
216 interpolation_domain,
218 preconditioner_max_block_size)
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
240 interpolation_domain_type
const& interpolation_domain,
241 std::optional<std::size_t> cols_per_chunk = std::nullopt,
242 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
245 interpolation_domain,
247 preconditioner_max_block_size)
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269 template <
concepts::discrete_domain BatchedInterpolationDDom>
271 std::string
const& label,
272 BatchedInterpolationDDom
const& batched_interpolation_domain,
273 std::optional<std::size_t> cols_per_chunk = std::nullopt,
274 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
277 interpolation_domain_type(batched_interpolation_domain),
279 preconditioner_max_block_size)
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299 template <
concepts::discrete_domain BatchedInterpolationDDom>
301 BatchedInterpolationDDom
const& batched_interpolation_domain,
302 std::optional<std::size_t> cols_per_chunk = std::nullopt,
303 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
306 interpolation_domain_type(batched_interpolation_domain),
308 preconditioner_max_block_size)
316
317
318
319
329
330
331
332
336
337
338
339
340
341
344 return ddc::
DiscreteDomain<interpolation_domain_type1, interpolation_domain_type2>(
345 m_spline_builder1.interpolation_domain(),
346 m_spline_builder2.interpolation_domain());
350
351
352
353
354
355
356
357
358
359 template <
concepts::discrete_domain BatchedInterpolationDDom>
361 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
364 return batched_interpolation_domain;
368
369
370
371
372
373
374
375
376 template <
concepts::discrete_domain BatchedInterpolationDDom>
377 batch_domain_type<BatchedInterpolationDDom>
batch_domain(
378 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
385
386
387
388
389
390
394 ddc::discrete_space<bsplines_type1>().full_domain(),
395 ddc::discrete_space<bsplines_type2>().full_domain());
399
400
401
402
403
404
405
406
407 template <
concepts::discrete_domain BatchedInterpolationDDom>
409 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
412 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
414 interpolation_discrete_dimension_type2,
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455 template <
class Layout,
class BatchedInterpolationDDom>
459 batched_spline_domain_type<BatchedInterpolationDDom>,
461 memory_space> spline,
462 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
465 batched_derivs_domain_type1<BatchedInterpolationDDom>,
467 memory_space>> derivs_min1
471 batched_derivs_domain_type1<BatchedInterpolationDDom>,
473 memory_space>> derivs_max1
477 batched_derivs_domain_type2<BatchedInterpolationDDom>,
479 memory_space>> derivs_min2
483 batched_derivs_domain_type2<BatchedInterpolationDDom>,
485 memory_space>> derivs_max2
489 batched_derivs_domain_type<BatchedInterpolationDDom>,
491 memory_space>> mixed_derivs_min1_min2
495 batched_derivs_domain_type<BatchedInterpolationDDom>,
497 memory_space>> mixed_derivs_max1_min2
501 batched_derivs_domain_type<BatchedInterpolationDDom>,
503 memory_space>> mixed_derivs_min1_max2
507 batched_derivs_domain_type<BatchedInterpolationDDom>,
509 memory_space>> mixed_derivs_max1_max2
510 = std::nullopt)
const;
526template <
class Layout,
class BatchedInterpolationDDom>
542 batched_spline_domain_type<BatchedInterpolationDDom>,
544 memory_space> spline,
545 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
548 batched_derivs_domain_type1<BatchedInterpolationDDom>,
550 memory_space>>
const derivs_min1,
553 batched_derivs_domain_type1<BatchedInterpolationDDom>,
555 memory_space>>
const derivs_max1,
558 batched_derivs_domain_type2<BatchedInterpolationDDom>,
560 memory_space>>
const derivs_min2,
563 batched_derivs_domain_type2<BatchedInterpolationDDom>,
565 memory_space>>
const derivs_max2,
568 batched_derivs_domain_type<BatchedInterpolationDDom>,
570 memory_space>>
const mixed_derivs_min1_min2,
573 batched_derivs_domain_type<BatchedInterpolationDDom>,
575 memory_space>>
const mixed_derivs_max1_min2,
578 batched_derivs_domain_type<BatchedInterpolationDDom>,
580 memory_space>>
const mixed_derivs_min1_max2,
583 batched_derivs_domain_type<BatchedInterpolationDDom>,
585 memory_space>>
const mixed_derivs_max1_max2)
const
587 auto const batched_interpolation_domain = vals.domain();
590 assert(batch_domain_type<BatchedInterpolationDDom>(batched_interpolation_domain)
591 == batch_domain_type<BatchedInterpolationDDom>(spline.domain()));
593 if (batch_domain(batched_interpolation_domain).empty()) {
600 auto const batched_interpolation_deriv_domain
601 =
ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
602 batched_interpolation_domain,
604 ddc::DiscreteElement<deriv_type2>(builder_type2::s_odd),
608 m_label +
" > spline1_deriv_min (ddc::SplineBuilder2D::operator())",
609 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain),
611 auto spline1_deriv_min = spline1_deriv_min_alloc.span_view();
612 auto spline1_deriv_min_opt = std::optional(spline1_deriv_min.span_cview());
617 mixed_derivs_min1_min2,
618 mixed_derivs_max1_min2);
620 spline1_deriv_min_opt = std::nullopt;
625 m_label +
" > spline1 (ddc::SplineBuilder2D::operator())",
626 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
628 ddc::
ChunkSpan const spline1 = spline1_alloc.span_view();
630 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
634 m_label +
" > spline1_deriv_max (ddc::SplineBuilder2D::operator())",
635 m_spline_builder1.batched_spline_domain(batched_interpolation_deriv_domain),
637 auto spline1_deriv_max = spline1_deriv_max_alloc.span_view();
638 auto spline1_deriv_max_opt = std::optional(spline1_deriv_max.span_cview());
643 mixed_derivs_min1_max2,
644 mixed_derivs_max1_max2);
646 spline1_deriv_max_opt = std::nullopt;
650 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 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.
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.
SplineBuilder2D(std::string const &label, 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.
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(std::string const &label, 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(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 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(std::string label, 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.
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.
SplineBuilder(std::string label, 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.
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.
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...
If the type DDim is a B-spline, defines type to the discrete dimension of the associated knots.