19
20
21
22
23
24
25
42 using exec_space = ExecSpace;
45 using memory_space = MemorySpace;
48 using builder_type1 =
ddc::
49 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
52 using builder_type2 =
ddc::
53 SplineBuilder<ExecSpace, MemorySpace, BSpline2, DDimI2, BcLower2, BcUpper2, Solver>;
56 using builder_deriv_type1 =
ddc::
57 SplineBuilder<ExecSpace, MemorySpace, BSpline1, DDimI1, BcLower1, BcUpper1, Solver>;
60 using continuous_dimension_type1 =
typename builder_type1::continuous_dimension_type;
63 using continuous_dimension_type2 =
typename builder_type2::continuous_dimension_type;
66 using interpolation_discrete_dimension_type1 =
67 typename builder_type1::interpolation_discrete_dimension_type;
70 using interpolation_discrete_dimension_type2 =
71 typename builder_type2::interpolation_discrete_dimension_type;
74 using bsplines_type1 =
typename builder_type1::bsplines_type;
77 using bsplines_type2 =
typename builder_type2::bsplines_type;
80 using deriv_type1 =
typename builder_type1::deriv_type;
83 using deriv_type2 =
typename builder_type2::deriv_type;
86 using interpolation_domain_type1 =
87 typename builder_type1::interpolation_discrete_dimension_type;
90 using interpolation_domain_type2 =
91 typename builder_type2::interpolation_discrete_dimension_type;
95 interpolation_discrete_dimension_type1,
96 interpolation_discrete_dimension_type2>;
99
100
101
102
103 template <concepts::discrete_domain BatchedInterpolationDDom>
104 using batched_interpolation_domain_type = BatchedInterpolationDDom;
107
108
109
110
111
112
113
114
115 template <concepts::discrete_domain BatchedInterpolationDDom>
116 using batch_domain_type =
ddc::remove_dims_of_t<
117 BatchedInterpolationDDom,
118 interpolation_discrete_dimension_type1,
119 interpolation_discrete_dimension_type2>;
122
123
124
125
126
127
128
129
130 template <concepts::discrete_domain BatchedInterpolationDDom>
131 using batched_spline_domain_type
132 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
133 ddc::to_type_seq_t<BatchedInterpolationDDom>,
134 ddc::detail::TypeSeq<
135 interpolation_discrete_dimension_type1,
136 interpolation_discrete_dimension_type2>,
137 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
140
141
142
143
144
145
146
147
148 template <concepts::discrete_domain BatchedInterpolationDDom>
149 using batched_derivs_domain_type1 =
150 typename builder_type1::
template batched_derivs_domain_type<BatchedInterpolationDDom>;
153
154
155
156
157
158
159
160
161 template <concepts::discrete_domain BatchedInterpolationDDom>
162 using batched_derivs_domain_type2 =
ddc::replace_dim_of_t<
163 BatchedInterpolationDDom,
164 interpolation_discrete_dimension_type2,
168
169
170
171
172
173
174
175
176 template <concepts::discrete_domain BatchedInterpolationDDom>
177 using batched_derivs_domain_type
178 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
179 ddc::to_type_seq_t<BatchedInterpolationDDom>,
180 ddc::detail::TypeSeq<
181 interpolation_discrete_dimension_type1,
182 interpolation_discrete_dimension_type2>,
183 ddc::detail::TypeSeq<deriv_type1, deriv_type2>>>;
186 builder_type1 m_spline_builder1;
187 builder_deriv_type1 m_spline_builder_deriv1;
188 builder_type2 m_spline_builder2;
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
208 interpolation_domain_type
const& interpolation_domain,
209 std::optional<std::size_t> cols_per_chunk = std::nullopt,
210 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
211 : m_spline_builder1(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
212 , m_spline_builder_deriv1(interpolation_domain)
213 , m_spline_builder2(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233 template <
concepts::discrete_domain BatchedInterpolationDDom>
235 BatchedInterpolationDDom
const& batched_interpolation_domain,
236 std::optional<std::size_t> cols_per_chunk = std::nullopt,
237 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
239 interpolation_domain_type(batched_interpolation_domain),
241 preconditioner_max_block_size)
249
250
251
252
262
263
264
265
269
270
271
272
273
274
277 return ddc::
DiscreteDomain<interpolation_domain_type1, interpolation_domain_type2>(
278 m_spline_builder1.interpolation_domain(),
279 m_spline_builder2.interpolation_domain());
283
284
285
286
287
288
289
290
291
292 template <
concepts::discrete_domain BatchedInterpolationDDom>
294 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
297 return batched_interpolation_domain;
301
302
303
304
305
306
307
308
309 template <
concepts::discrete_domain BatchedInterpolationDDom>
310 batch_domain_type<BatchedInterpolationDDom>
batch_domain(
311 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
318
319
320
321
322
323
327 ddc::discrete_space<bsplines_type1>().full_domain(),
328 ddc::discrete_space<bsplines_type2>().full_domain());
332
333
334
335
336
337
338
339
340 template <
concepts::discrete_domain BatchedInterpolationDDom>
342 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
345 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
347 interpolation_discrete_dimension_type2,
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388 template <
class Layout,
class BatchedInterpolationDDom>
392 batched_spline_domain_type<BatchedInterpolationDDom>,
394 memory_space> spline,
395 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
398 batched_derivs_domain_type1<BatchedInterpolationDDom>,
400 memory_space>> derivs_min1
404 batched_derivs_domain_type1<BatchedInterpolationDDom>,
406 memory_space>> derivs_max1
410 batched_derivs_domain_type2<BatchedInterpolationDDom>,
412 memory_space>> derivs_min2
416 batched_derivs_domain_type2<BatchedInterpolationDDom>,
418 memory_space>> derivs_max2
422 batched_derivs_domain_type<BatchedInterpolationDDom>,
424 memory_space>> mixed_derivs_min1_min2
428 batched_derivs_domain_type<BatchedInterpolationDDom>,
430 memory_space>> mixed_derivs_max1_min2
434 batched_derivs_domain_type<BatchedInterpolationDDom>,
436 memory_space>> mixed_derivs_min1_max2
440 batched_derivs_domain_type<BatchedInterpolationDDom>,
442 memory_space>> mixed_derivs_max1_max2
443 = std::nullopt)
const;
459template <
class Layout,
class BatchedInterpolationDDom>
475 batched_spline_domain_type<BatchedInterpolationDDom>,
477 memory_space> spline,
478 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
481 batched_derivs_domain_type1<BatchedInterpolationDDom>,
483 memory_space>>
const derivs_min1,
486 batched_derivs_domain_type1<BatchedInterpolationDDom>,
488 memory_space>>
const derivs_max1,
491 batched_derivs_domain_type2<BatchedInterpolationDDom>,
493 memory_space>>
const derivs_min2,
496 batched_derivs_domain_type2<BatchedInterpolationDDom>,
498 memory_space>>
const derivs_max2,
501 batched_derivs_domain_type<BatchedInterpolationDDom>,
503 memory_space>>
const mixed_derivs_min1_min2,
506 batched_derivs_domain_type<BatchedInterpolationDDom>,
508 memory_space>>
const mixed_derivs_max1_min2,
511 batched_derivs_domain_type<BatchedInterpolationDDom>,
513 memory_space>>
const mixed_derivs_min1_max2,
516 batched_derivs_domain_type<BatchedInterpolationDDom>,
518 memory_space>>
const mixed_derivs_max1_max2)
const
520 auto const batched_interpolation_domain = vals.domain();
523 assert(batch_domain_type<BatchedInterpolationDDom>(batched_interpolation_domain)
524 == batch_domain_type<BatchedInterpolationDDom>(spline.domain()));
526 if (batch_domain(batched_interpolation_domain).empty()) {
533 auto const batched_interpolation_deriv_domain
534 =
ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
535 batched_interpolation_domain,
537 ddc::DiscreteElement<deriv_type2>(builder_type2::s_odd),
541 m_spline_builder_deriv1.batched_spline_domain(batched_interpolation_deriv_domain),
543 auto spline1_deriv_min = spline1_deriv_min_alloc.span_view();
544 auto spline1_deriv_min_opt = std::optional(spline1_deriv_min.span_cview());
546 m_spline_builder_deriv1(
549 mixed_derivs_min1_min2,
550 mixed_derivs_max1_min2);
552 spline1_deriv_min_opt = std::nullopt;
557 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
559 ddc::
ChunkSpan const spline1 = spline1_alloc.span_view();
561 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
565 m_spline_builder_deriv1.batched_spline_domain(batched_interpolation_deriv_domain),
567 auto spline1_deriv_max = spline1_deriv_max_alloc.span_view();
568 auto spline1_deriv_max_opt = std::optional(spline1_deriv_max.span_cview());
570 m_spline_builder_deriv1(
573 mixed_derivs_min1_max2,
574 mixed_derivs_max1_max2);
576 spline1_deriv_max_opt = std::nullopt;
580 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.
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 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.
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.