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 = builder_type1::continuous_dimension_type;
63 using continuous_dimension_type2 = builder_type2::continuous_dimension_type;
66 using interpolation_discrete_dimension_type1
67 = builder_type1::interpolation_discrete_dimension_type;
70 using interpolation_discrete_dimension_type2
71 = builder_type2::interpolation_discrete_dimension_type;
74 using bsplines_type1 = builder_type1::bsplines_type;
77 using bsplines_type2 = builder_type2::bsplines_type;
80 using deriv_type1 = builder_type1::deriv_type;
83 using deriv_type2 = builder_type2::deriv_type;
86 using interpolation_domain_type1 = builder_type1::interpolation_discrete_dimension_type;
89 using interpolation_domain_type2 = builder_type2::interpolation_discrete_dimension_type;
93 interpolation_discrete_dimension_type1,
94 interpolation_discrete_dimension_type2>;
97
98
99
100
101 template <concepts::discrete_domain BatchedInterpolationDDom>
102 using batched_interpolation_domain_type = BatchedInterpolationDDom;
105
106
107
108
109
110
111
112
113 template <concepts::discrete_domain BatchedInterpolationDDom>
114 using batch_domain_type =
ddc::remove_dims_of_t<
115 BatchedInterpolationDDom,
116 interpolation_discrete_dimension_type1,
117 interpolation_discrete_dimension_type2>;
120
121
122
123
124
125
126
127
128 template <concepts::discrete_domain BatchedInterpolationDDom>
129 using batched_spline_domain_type
130 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
131 ddc::to_type_seq_t<BatchedInterpolationDDom>,
132 ddc::detail::TypeSeq<
133 interpolation_discrete_dimension_type1,
134 interpolation_discrete_dimension_type2>,
135 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
138
139
140
141
142
143
144
145
146 template <concepts::discrete_domain BatchedInterpolationDDom>
147 using batched_derivs_domain_type1
148 = builder_type1::
template batched_derivs_domain_type<BatchedInterpolationDDom>;
151
152
153
154
155
156
157
158
159 template <concepts::discrete_domain BatchedInterpolationDDom>
160 using batched_derivs_domain_type2 =
ddc::replace_dim_of_t<
161 BatchedInterpolationDDom,
162 interpolation_discrete_dimension_type2,
166
167
168
169
170
171
172
173
174 template <concepts::discrete_domain BatchedInterpolationDDom>
175 using batched_derivs_domain_type
176 =
ddc::detail::convert_type_seq_to_discrete_domain_t<
ddc::type_seq_replace_t<
177 ddc::to_type_seq_t<BatchedInterpolationDDom>,
178 ddc::detail::TypeSeq<
179 interpolation_discrete_dimension_type1,
180 interpolation_discrete_dimension_type2>,
181 ddc::detail::TypeSeq<deriv_type1, deriv_type2>>>;
184 builder_type1 m_spline_builder1;
185 builder_deriv_type1 m_spline_builder_deriv1;
186 builder_type2 m_spline_builder2;
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
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)
209 : m_spline_builder1(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
210 , m_spline_builder_deriv1(interpolation_domain)
211 , m_spline_builder2(interpolation_domain, cols_per_chunk, preconditioner_max_block_size)
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231 template <
concepts::discrete_domain BatchedInterpolationDDom>
233 BatchedInterpolationDDom
const& batched_interpolation_domain,
234 std::optional<std::size_t> cols_per_chunk = std::nullopt,
235 std::optional<
unsigned int> preconditioner_max_block_size = std::nullopt)
237 interpolation_domain_type(batched_interpolation_domain),
239 preconditioner_max_block_size)
247
248
249
250
260
261
262
263
267
268
269
270
271
272
275 return ddc::
DiscreteDomain<interpolation_domain_type1, interpolation_domain_type2>(
276 m_spline_builder1.interpolation_domain(),
277 m_spline_builder2.interpolation_domain());
281
282
283
284
285
286
287
288
289
290 template <
concepts::discrete_domain BatchedInterpolationDDom>
292 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
295 return batched_interpolation_domain;
299
300
301
302
303
304
305
306
307 template <
concepts::discrete_domain BatchedInterpolationDDom>
308 batch_domain_type<BatchedInterpolationDDom>
batch_domain(
309 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
316
317
318
319
320
321
325 ddc::discrete_space<bsplines_type1>().full_domain(),
326 ddc::discrete_space<bsplines_type2>().full_domain());
330
331
332
333
334
335
336
337
338 template <
concepts::discrete_domain BatchedInterpolationDDom>
340 BatchedInterpolationDDom
const& batched_interpolation_domain)
const noexcept
343 return ddc::replace_dim_of<interpolation_discrete_dimension_type1, bsplines_type1>(
345 interpolation_discrete_dimension_type2,
351
352
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 template <
class Layout,
class BatchedInterpolationDDom>
390 batched_spline_domain_type<BatchedInterpolationDDom>,
392 memory_space> spline,
393 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
396 batched_derivs_domain_type1<BatchedInterpolationDDom>,
398 memory_space>> derivs_min1
402 batched_derivs_domain_type1<BatchedInterpolationDDom>,
404 memory_space>> derivs_max1
408 batched_derivs_domain_type2<BatchedInterpolationDDom>,
410 memory_space>> derivs_min2
414 batched_derivs_domain_type2<BatchedInterpolationDDom>,
416 memory_space>> derivs_max2
420 batched_derivs_domain_type<BatchedInterpolationDDom>,
422 memory_space>> mixed_derivs_min1_min2
426 batched_derivs_domain_type<BatchedInterpolationDDom>,
428 memory_space>> mixed_derivs_max1_min2
432 batched_derivs_domain_type<BatchedInterpolationDDom>,
434 memory_space>> mixed_derivs_min1_max2
438 batched_derivs_domain_type<BatchedInterpolationDDom>,
440 memory_space>> mixed_derivs_max1_max2
441 = std::nullopt)
const;
457template <
class Layout,
class BatchedInterpolationDDom>
473 batched_spline_domain_type<BatchedInterpolationDDom>,
475 memory_space> spline,
476 ddc::
ChunkSpan<
double const, BatchedInterpolationDDom, Layout, memory_space> vals,
479 batched_derivs_domain_type1<BatchedInterpolationDDom>,
481 memory_space>>
const derivs_min1,
484 batched_derivs_domain_type1<BatchedInterpolationDDom>,
486 memory_space>>
const derivs_max1,
489 batched_derivs_domain_type2<BatchedInterpolationDDom>,
491 memory_space>>
const derivs_min2,
494 batched_derivs_domain_type2<BatchedInterpolationDDom>,
496 memory_space>>
const derivs_max2,
499 batched_derivs_domain_type<BatchedInterpolationDDom>,
501 memory_space>>
const mixed_derivs_min1_min2,
504 batched_derivs_domain_type<BatchedInterpolationDDom>,
506 memory_space>>
const mixed_derivs_max1_min2,
509 batched_derivs_domain_type<BatchedInterpolationDDom>,
511 memory_space>>
const mixed_derivs_min1_max2,
514 batched_derivs_domain_type<BatchedInterpolationDDom>,
516 memory_space>>
const mixed_derivs_max1_max2)
const
518 auto const batched_interpolation_domain = vals.domain();
521 assert(batch_domain_type<BatchedInterpolationDDom>(batched_interpolation_domain)
522 == batch_domain_type<BatchedInterpolationDDom>(spline.domain()));
524 if (batch_domain(batched_interpolation_domain).empty()) {
531 auto const batched_interpolation_deriv_domain
532 =
ddc::replace_dim_of<interpolation_discrete_dimension_type2, deriv_type2>(
533 batched_interpolation_domain,
535 ddc::DiscreteElement<deriv_type2>(builder_type2::s_odd),
539 m_spline_builder_deriv1.batched_spline_domain(batched_interpolation_deriv_domain),
541 auto spline1_deriv_min = spline1_deriv_min_alloc.span_view();
542 auto spline1_deriv_min_opt = std::optional(spline1_deriv_min.span_cview());
544 m_spline_builder_deriv1(
547 mixed_derivs_min1_min2,
548 mixed_derivs_max1_min2);
550 spline1_deriv_min_opt = std::nullopt;
555 m_spline_builder1.batched_spline_domain(batched_interpolation_domain),
557 ddc::
ChunkSpan const spline1 = spline1_alloc.span_view();
559 m_spline_builder1(spline1, vals, derivs_min1, derivs_max1);
563 m_spline_builder_deriv1.batched_spline_domain(batched_interpolation_deriv_domain),
565 auto spline1_deriv_max = spline1_deriv_max_alloc.span_view();
566 auto spline1_deriv_max_opt = std::optional(spline1_deriv_max.span_cview());
568 m_spline_builder_deriv1(
571 mixed_derivs_min1_max2,
572 mixed_derivs_max1_max2);
574 spline1_deriv_max_opt = std::nullopt;
578 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.