13#include <Kokkos_Core.hpp>
16#include "integrals.hpp"
17#include "periodic_extrapolation_rule.hpp"
93 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
113 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
127 class = std::enable_if_t<ddc::is_discrete_domain_v<BatchedInterpolationDDom>>>
131 ddc::detail::TypeSeq<
134 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>>>;
161 == bsplines_type1::is_periodic()
165 == bsplines_type1::is_periodic()
169 == bsplines_type2::is_periodic()
173 == bsplines_type2::is_periodic(),
174 "PeriodicExtrapolationRule has to be used if and only if dimension is periodic");
176 std::is_invocable_r_v<
183 Kokkos::layout_right,
185 "LowerExtrapolationRule1::operator() has to be callable "
186 "with usual arguments.");
188 std::is_invocable_r_v<
195 Kokkos::layout_right,
197 "UpperExtrapolationRule1::operator() has to be callable "
198 "with usual arguments.");
200 std::is_invocable_r_v<
207 Kokkos::layout_right,
209 "LowerExtrapolationRule2::operator() has to be callable "
210 "with usual arguments.");
212 std::is_invocable_r_v<
219 Kokkos::layout_right,
221 "UpperExtrapolationRule2::operator() has to be callable "
222 "with usual arguments.");
290 return m_lower_extrap_rule_1;
304 return m_upper_extrap_rule_1;
318 return m_lower_extrap_rule_2;
332 return m_upper_extrap_rule_2;
400 "ddc_splines_evaluate_2d",
432 template <
class Layout1,
class Layout2,
class BatchedInterpolationDDom>
446 "ddc_splines_evaluate_2d",
464#if defined(DDC_BUILD_DEPRECATED_CODE)
478 "Use deriv(DiscreteElement<Deriv<Dim1>>(1), ...) instead)")]]
KOKKOS_FUNCTION double
503 "Use deriv(DiscreteElement<Deriv<Dim2>>(1), ...) instead)")]]
KOKKOS_FUNCTION double
528 "Use deriv(DiscreteElement<Deriv<Dim1>, Deriv<Dim2>>(1, 1), ...) "
558 "Use deriv(DiscreteElement<Deriv<InterestDim>>(1), ...) "
571 continuous_dimension_type>) {
573 }
else if constexpr (std::is_same_v<
575 typename evaluation_discrete_dimension_type2::
576 continuous_dimension_type>) {
600 "Use deriv(DiscreteElement<Deriv<InterestDim1, InterestDim2>>(1, 1), ...) "
680 template <
class Layout1,
class Layout2,
class BatchedInterpolationDDom>
754 template <
class Layout1,
class Layout2,
class BatchedInterpolationDDom>
794 [[
deprecated(
"Use deriv(DiscreteElement<Deriv<Dim1>, Deriv<Dim2>>(1, 1), ...) instead)")]]
void
831 template <
class Layout1,
class Layout2,
class BatchedInterpolationDDom>
832 [[
deprecated(
"Use deriv(DiscreteElement<Deriv<Dim1>, Deriv<Dim2>>(1, 1), ...) instead)")]]
void
876 [[
deprecated(
"Use deriv(DiscreteElement<Deriv<InterestDim>>(1), ...) instead)")]]
void deriv(
899 continuous_dimension_type>) {
901 }
else if constexpr (std::is_same_v<
903 typename evaluation_discrete_dimension_type2::
904 continuous_dimension_type>) {
924 template <
class InterestDim,
class Layout1,
class Layout2,
class BatchedInterpolationDDom>
925 [[
deprecated(
"Use deriv(DiscreteElement<Deriv<InterestDim>>(1), ...) instead)")]]
void deriv(
943 continuous_dimension_type>) {
945 }
else if constexpr (std::is_same_v<
947 typename evaluation_discrete_dimension_type2::
948 continuous_dimension_type>) {
986 "Use deriv(DiscreteElement<Deriv<InterestDim1>, Deriv<InterestDim2>>(1, 1), ...) "
1138 "ddc_splines_differentiate_2d",
1173 template <
class DElem,
class Layout1,
class Layout2,
class BatchedInterpolationDDom>
1190 "ddc_splines_differentiate_2d",
1222 template <
class Layout1,
class Layout2,
class BatchedDDom,
class BatchedSplineDDom>
1230 ddc::detail::TypeSeq<bsplines_type1, bsplines_type2>,
1232 "The spline coefficients domain must contain the bsplines dimensions");
1236 std::is_same_v<batch_domain_type, BatchedDDom>,
1237 "The integrals domain must only contain the batch dimensions");
1252 "ddc_splines_integrate_bsplines",
1255 KOKKOS_LAMBDA(
typename batch_domain_type::discrete_element_type
const j) {
1291 if constexpr (bsplines_type1::is_periodic()) {
1302 if constexpr (bsplines_type2::is_periodic()) {
1313 if constexpr (!bsplines_type1::is_periodic()) {
1321 if constexpr (!bsplines_type2::is_periodic()) {
1359 "The only valid dimensions for deriv_order are Deriv<Dim1> and Deriv<Dim2>");
1365 Kokkos::mdspan<
double, Kokkos::extents<std::size_t, bsplines_type1::degree() + 1>>
const
1368 Kokkos::mdspan<
double, Kokkos::extents<std::size_t, bsplines_type2::degree() + 1>>
const
1420 for (std::size_t
i = 0;
i < bsplines_type1::degree() + 1; ++
i) {
1421 for (std::size_t
j = 0;
j < bsplines_type2::degree() + 1; ++
j) {
KOKKOS_FUNCTION constexpr span_type span_view() const
A DiscreteElement identifies an element of the discrete dimension.
A class to evaluate, differentiate or integrate a 2D spline function.
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) on a mesh.
SplineEvaluator2D(SplineEvaluator2D &&x)=default
Move-constructs.
LowerExtrapolationRule2 lower_extrapolation_rule_2_type
The type of the extrapolation rule at the lower boundary along the second dimension.
lower_extrapolation_rule_1_type lower_extrapolation_rule_dim_1() const
Get the lower extrapolation rule along the first dimension.
typename ddc::detail::convert_type_seq_to_discrete_domain_t< ddc::type_seq_replace_t< ddc::to_type_seq_t< BatchedInterpolationDDom >, ddc::detail::TypeSeq< evaluation_discrete_dimension_type1, evaluation_discrete_dimension_type2 >, ddc::detail::TypeSeq< bsplines_type1, bsplines_type2 > > > batched_spline_domain_type
The type of the whole spline domain (cartesian product of 2D spline domain and batch domain) preservi...
BSplines1 bsplines_type1
The discrete dimension representing the B-splines along first dimension.
MemorySpace memory_space
The type of the Kokkos memory space used by this class.
BSplines2 bsplines_type2
The discrete dimension representing the B-splines along second dimension.
UpperExtrapolationRule1 upper_extrapolation_rule_1_type
The type of the extrapolation rule at the upper boundary along the first dimension.
SplineEvaluator2D & operator=(SplineEvaluator2D const &x)=default
Copy-assigns.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) on a mesh along the dimension...
SplineEvaluator2D(SplineEvaluator2D const &x)=default
Copy-constructs.
~SplineEvaluator2D()=default
Destructs.
KOKKOS_FUNCTION double deriv(DElem const &deriv_order, ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) at a given coordinate along t...
typename BSplines2::continuous_dimension_type continuous_dimension_type2
The type of the second evaluation continuous dimension used by this class.
typename ddc::remove_dims_of_t< BatchedInterpolationDDom, evaluation_discrete_dimension_type1, evaluation_discrete_dimension_type2 > batch_domain_type
The type of the batch domain (obtained by removing the dimensions of interest from the whole domain).
LowerExtrapolationRule1 lower_extrapolation_rule_1_type
The type of the extrapolation rule at the lower boundary along the first dimension.
ddc::DiscreteDomain< bsplines_type1, bsplines_type2 > spline_domain_type
The type of the 2D spline domain corresponding to the dimensions of interest.
void deriv(DElem const &deriv_order, ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout2, memory_space > const spline_coef) const
Differentiate 2D spline function (described by its spline coefficients) on a mesh along the dimension...
typename BSplines1::continuous_dimension_type continuous_dimension_type1
The type of the first evaluation continuous dimension used by this class.
EvaluationDDim2 evaluation_discrete_dimension_type2
The type of the second discrete dimension of interest used by this class.
BatchedInterpolationDDom batched_evaluation_domain_type
The type of the whole domain representing evaluation points.
void integrate(ddc::ChunkSpan< double, BatchedDDom, Layout1, memory_space > const integrals, ddc::ChunkSpan< double const, BatchedSplineDDom, Layout2, memory_space > const spline_coef) const
Perform batched 2D integrations of a spline function (described by its spline coefficients) along the...
EvaluationDDim1 evaluation_discrete_dimension_type1
The type of the first discrete dimension of interest used by this class.
upper_extrapolation_rule_2_type upper_extrapolation_rule_dim_2() const
Get the upper extrapolation rule along the second dimension.
upper_extrapolation_rule_1_type upper_extrapolation_rule_dim_1() const
Get the upper extrapolation rule along the first dimension.
lower_extrapolation_rule_2_type lower_extrapolation_rule_dim_2() const
Get the lower extrapolation rule along the second dimension.
SplineEvaluator2D & operator=(SplineEvaluator2D &&x)=default
Move-assigns.
KOKKOS_FUNCTION double operator()(ddc::Coordinate< CoordsDims... > const &coord_eval, ddc::ChunkSpan< double const, spline_domain_type, Layout, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) at a given coordinate.
void operator()(ddc::ChunkSpan< double, BatchedInterpolationDDom, Layout1, memory_space > const spline_eval, ddc::ChunkSpan< ddc::Coordinate< CoordsDims... > const, BatchedInterpolationDDom, Layout2, memory_space > const coords_eval, ddc::ChunkSpan< double const, batched_spline_domain_type< BatchedInterpolationDDom >, Layout3, memory_space > const spline_coef) const
Evaluate 2D spline function (described by its spline coefficients) on a mesh.
ExecSpace exec_space
The type of the Kokkos execution space used by this class.
UpperExtrapolationRule2 upper_extrapolation_rule_2_type
The type of the extrapolation rule at the upper boundary along the second dimension.
SplineEvaluator2D(LowerExtrapolationRule1 const &lower_extrap_rule1, UpperExtrapolationRule1 const &upper_extrap_rule1, LowerExtrapolationRule2 const &lower_extrap_rule2, UpperExtrapolationRule2 const &upper_extrap_rule2)
Build a SplineEvaluator2D acting on batched_spline_domain.
The top-level namespace of DDC.
constexpr bool enable_chunk
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > rmax(DiscreteDomain< DDim > const &d)
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.
decltype(remove_dims_of< DDims... >(std::declval< DDom >())) remove_dims_of_t
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type... > coordinate(DiscreteElement< DDim... > const &c)
KOKKOS_FUNCTION constexpr DiscreteVector< QueryDDims... > extents(DiscreteDomain< DDims... > const &domain) noexcept
KOKKOS_FUNCTION Coordinate< typename DDim::continuous_dimension_type > rmin(DiscreteDomain< DDim > const &d)
detail::TaggedVector< CoordinateElement, CDims... > Coordinate
A Coordinate represents a coordinate in the continuous space.
KOKKOS_FUNCTION detail::ddim_impl_t< DDim, MemorySpace > const & discrete_space()
void parallel_for_each(std::string const &label, ExecSpace const &execution_space, Support const &domain, Functor &&f) noexcept
iterates over a nD domain using a given Kokkos execution space
A templated struct representing a discrete dimension storing the derivatives of a function along a co...