Skip to content

Commit

Permalink
Clean splines continuous dimension (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegouix authored Jul 16, 2024
1 parent 78c6083 commit 2e705cb
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 50 deletions.
6 changes: 3 additions & 3 deletions include/ddc/kernels/splines/spline_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ class SplineBuilder
|| (!BSplines::is_periodic() && (BcLower != ddc::BoundCond::PERIODIC)
&& (BcUpper != ddc::BoundCond::PERIODIC)));

private:
using continuous_dimension_type = typename InterpolationDDim::continuous_dimension_type;

public:
/// @brief The type of the Kokkos execution space used by this class.
using exec_space = ExecSpace;

/// @brief The type of the Kokkos memory space used by this class.
using memory_space = MemorySpace;

/// @brief The type of the interpolation continuous dimension (continuous dimension of interest) used by this class.
using continuous_dimension_type = typename InterpolationDDim::continuous_dimension_type;

/// @brief The type of the interpolation discrete dimension (discrete dimension of interest) used by this class.
using interpolation_discrete_dimension_type = InterpolationDDim;

Expand Down
28 changes: 12 additions & 16 deletions include/ddc/kernels/splines/spline_builder_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ class SplineBuilder2D
typename builder_type2::deriv_type,
IDimX>...>;

private:
/// @brief The tag of the dimension of the first 1D SplineBuilder.
using continuous_dimension_type1 =
typename builder_type1::bsplines_type::continuous_dimension_type;
/// @brief The type of the first interpolation continuous dimension.
using continuous_dimension_type1 = typename builder_type1::continuous_dimension_type;

/// @brief The tag of the dimension of the second 1D SplineBuilder.
using continuous_dimension_type2 =
typename builder_type2::bsplines_type::continuous_dimension_type;
/// @brief The type of the second interpolation continuous dimension.
using continuous_dimension_type2 = typename builder_type2::continuous_dimension_type;

/// @brief The type of the first interpolation discrete dimension.
using interpolation_discrete_dimension_type1 =
typename builder_type1::interpolation_discrete_dimension_type;

/// @brief The type of the second interpolation discrete dimension.
using interpolation_discrete_dimension_type2 =
typename builder_type2::interpolation_discrete_dimension_type;

public:
/// @brief The type of the B-splines in the first dimension.
using bsplines_type1 = typename builder_type1::bsplines_type;

Expand All @@ -98,14 +102,6 @@ class SplineBuilder2D
/// @brief The type of the Deriv domain on boundaries in the second dimension.
using deriv_type2 = typename builder_type2::deriv_type;

/// @brief The type of the interpolation mesh in the first dimension.
using interpolation_discrete_dimension_type1 =
typename builder_type1::interpolation_discrete_dimension_type;

/// @brief The type of the interpolation mesh in the second dimension.
using interpolation_discrete_dimension_type2 =
typename builder_type2::interpolation_discrete_dimension_type;

/// @brief The type of the domain for the interpolation mesh in the first dimension.
using interpolation_domain_type1 =
typename builder_type1::interpolation_discrete_dimension_type;
Expand Down
17 changes: 7 additions & 10 deletions include/ddc/kernels/splines/spline_evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,16 @@ class SplineEvaluator
{
};

using continuous_dimension_type = typename BSplines::continuous_dimension_type;

public:
/// @brief The type of the Kokkos execution space used by this class.
using exec_space = ExecSpace;

/// @brief The type of the Kokkos memory space used by this class.
using memory_space = MemorySpace;

/// @brief The type of the evaluation continuous dimension (continuous dimension of interest) used by this class.
using continuous_dimension_type = typename BSplines::continuous_dimension_type;

/// @brief The type of the evaluation discrete dimension (discrete dimension of interest) used by this class.
using evaluation_discrete_dimension_type = EvaluationDDim;

Expand Down Expand Up @@ -405,10 +406,8 @@ class SplineEvaluator
ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
spline_coef) const
{
ddc::Coordinate<typename evaluation_discrete_dimension_type::continuous_dimension_type>
coord_eval_interest = ddc::select<
typename evaluation_discrete_dimension_type::continuous_dimension_type>(
coord_eval);
ddc::Coordinate<continuous_dimension_type> coord_eval_interest
= ddc::select<continuous_dimension_type>(coord_eval);
if constexpr (bsplines_type::is_periodic()) {
if (coord_eval_interest < ddc::discrete_space<bsplines_type>().rmin()
|| coord_eval_interest > ddc::discrete_space<bsplines_type>().rmax()) {
Expand Down Expand Up @@ -443,10 +442,8 @@ class SplineEvaluator
double,
std::experimental::extents<std::size_t, bsplines_type::degree() + 1>> const
vals(vals_ptr.data());
ddc::Coordinate<typename evaluation_discrete_dimension_type::continuous_dimension_type>
coord_eval_interest = ddc::select<
typename evaluation_discrete_dimension_type::continuous_dimension_type>(
coord_eval);
ddc::Coordinate<continuous_dimension_type> coord_eval_interest
= ddc::select<continuous_dimension_type>(coord_eval);
if constexpr (std::is_same_v<EvalType, eval_type>) {
jmin = ddc::discrete_space<bsplines_type>().eval_basis(vals, coord_eval_interest);
} else if constexpr (std::is_same_v<EvalType, eval_deriv_type>) {
Expand Down
38 changes: 17 additions & 21 deletions include/ddc/kernels/splines/spline_evaluator_2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ class SplineEvaluator2D
{
};

public:
/// @brief The type of the first evaluation continuous dimension used by this class.
using continuous_dimension_type1 = typename BSplines1::continuous_dimension_type;

/// @brief The type of the second evaluation continuous dimension used by this class.
using continuous_dimension_type2 = typename BSplines2::continuous_dimension_type;

public:
/// @brief The type of the Kokkos execution space used by this class.
using exec_space = ExecSpace;

Expand Down Expand Up @@ -482,8 +485,7 @@ class SplineEvaluator2D
static_assert(
std::is_same_v<
InterestDim,
typename evaluation_discrete_dimension_type1::
continuous_dimension_type> || std::is_same_v<InterestDim, typename evaluation_discrete_dimension_type2::continuous_dimension_type>);
continuous_dimension_type1> || std::is_same_v<InterestDim, continuous_dimension_type2>);
if constexpr (std::is_same_v<
InterestDim,
typename evaluation_discrete_dimension_type1::
Expand Down Expand Up @@ -523,11 +525,11 @@ class SplineEvaluator2D
(std::is_same_v<
InterestDim1,
typename evaluation_discrete_dimension_type1::
continuous_dimension_type> && std::is_same_v<InterestDim2, typename evaluation_discrete_dimension_type2::continuous_dimension_type>)
continuous_dimension_type> && std::is_same_v<InterestDim2, continuous_dimension_type2>)
|| (std::is_same_v<
InterestDim2,
typename evaluation_discrete_dimension_type1::
continuous_dimension_type> && std::is_same_v<InterestDim1, typename evaluation_discrete_dimension_type2::continuous_dimension_type>));
continuous_dimension_type> && std::is_same_v<InterestDim1, continuous_dimension_type2>));
return deriv_1_and_2(coord_eval, spline_coef);
}

Expand Down Expand Up @@ -721,7 +723,7 @@ class SplineEvaluator2D
std::is_same_v<
InterestDim,
typename evaluation_discrete_dimension_type1::
continuous_dimension_type> || std::is_same_v<InterestDim, typename evaluation_discrete_dimension_type2::continuous_dimension_type>);
continuous_dimension_type> || std::is_same_v<InterestDim, continuous_dimension_type2>);
if constexpr (std::is_same_v<
InterestDim,
typename evaluation_discrete_dimension_type1::
Expand Down Expand Up @@ -780,11 +782,11 @@ class SplineEvaluator2D
(std::is_same_v<
InterestDim1,
typename evaluation_discrete_dimension_type1::
continuous_dimension_type> && std::is_same_v<InterestDim2, typename evaluation_discrete_dimension_type2::continuous_dimension_type>)
continuous_dimension_type> && std::is_same_v<InterestDim2, continuous_dimension_type2>)
|| (std::is_same_v<
InterestDim2,
typename evaluation_discrete_dimension_type1::
continuous_dimension_type> && std::is_same_v<InterestDim1, typename evaluation_discrete_dimension_type2::continuous_dimension_type>));
continuous_dimension_type> && std::is_same_v<InterestDim1, continuous_dimension_type2>));
return deriv_1_and_2(spline_eval, coords_eval, spline_coef);
}

Expand Down Expand Up @@ -866,8 +868,8 @@ class SplineEvaluator2D
ddc::ChunkSpan<double const, spline_domain_type, Layout, memory_space> const
spline_coef) const
{
using Dim1 = typename evaluation_discrete_dimension_type1::continuous_dimension_type;
using Dim2 = typename evaluation_discrete_dimension_type2::continuous_dimension_type;
using Dim1 = continuous_dimension_type1;
using Dim2 = continuous_dimension_type2;
if constexpr (bsplines_type1::is_periodic()) {
if (ddc::get<Dim1>(coord_eval) < ddc::discrete_space<bsplines_type1>().rmin()
|| ddc::get<Dim1>(coord_eval) > ddc::discrete_space<bsplines_type1>().rmax()) {
Expand Down Expand Up @@ -907,9 +909,7 @@ class SplineEvaluator2D
}
}
return eval_no_bc<eval_type, eval_type>(
ddc::Coordinate<
typename evaluation_discrete_dimension_type1::continuous_dimension_type,
typename evaluation_discrete_dimension_type2::continuous_dimension_type>(
ddc::Coordinate<continuous_dimension_type1, continuous_dimension_type2>(
ddc::get<Dim1>(coord_eval),
ddc::get<Dim2>(coord_eval)),
spline_coef);
Expand Down Expand Up @@ -952,14 +952,10 @@ class SplineEvaluator2D
double,
std::experimental::extents<std::size_t, bsplines_type2::degree() + 1>> const
vals2(vals2_ptr.data());
ddc::Coordinate<typename evaluation_discrete_dimension_type1::continuous_dimension_type>
coord_eval_interest1 = ddc::select<
typename evaluation_discrete_dimension_type1::continuous_dimension_type>(
coord_eval);
ddc::Coordinate<typename evaluation_discrete_dimension_type2::continuous_dimension_type>
coord_eval_interest2 = ddc::select<
typename evaluation_discrete_dimension_type2::continuous_dimension_type>(
coord_eval);
ddc::Coordinate<continuous_dimension_type1> coord_eval_interest1
= ddc::select<continuous_dimension_type1>(coord_eval);
ddc::Coordinate<continuous_dimension_type2> coord_eval_interest2
= ddc::select<continuous_dimension_type2>(coord_eval);

if constexpr (std::is_same_v<EvalType1, eval_type>) {
jmin1 = ddc::discrete_space<bsplines_type1>().eval_basis(vals1, coord_eval_interest1);
Expand Down

0 comments on commit 2e705cb

Please sign in to comment.