Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SplineBuilder doc #409

Merged
merged 117 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
f60b990
init
blegouix Apr 2, 2024
84a5ca7
missing sed in benchmark
blegouix Apr 3, 2024
5b67b46
Merge branch 'main' into clarify-spline-names
blegouix Apr 3, 2024
1f02beb
Merge branch 'main' into clarify-spline-names
blegouix Apr 15, 2024
96d4fdb
fix
blegouix Apr 15, 2024
b9c4451
Merge branch 'clarify-spline-names' of github.com:Maison-de-la-Simula…
blegouix Apr 15, 2024
077807a
Update include/ddc/kernels/splines/spline_builder.hpp
blegouix Apr 15, 2024
373e034
Merge branch 'main' into clarify-spline-names
blegouix Apr 15, 2024
653bab4
clang-format
blegouix Apr 15, 2024
889b9f9
fix kokkos version change
blegouix Apr 16, 2024
20ca22d
Merge branch 'main' into clarify-spline-names
blegouix Apr 16, 2024
6238ca3
wip
blegouix Apr 16, 2024
6ab4a97
improve consistency
blegouix Apr 16, 2024
64659a7
Merge branch 'main' into clarify-spline-names
blegouix Apr 17, 2024
66ea164
wip
blegouix Apr 17, 2024
2fdb975
wip
blegouix Apr 17, 2024
93ec4a0
spline_builder
blegouix Apr 17, 2024
29367d7
changes from Emiliy's reviw
blegouix Apr 17, 2024
97a042e
format
blegouix Apr 17, 2024
84e76df
minor
blegouix Apr 17, 2024
aa7b594
wip
blegouix Apr 17, 2024
3ea940f
Merge branch 'clarify-spline-names' into splines-doc
blegouix Apr 17, 2024
ffef0b2
wip
blegouix Apr 18, 2024
2a050b0
wip
blegouix Apr 18, 2024
880353b
bsplines
blegouix Apr 18, 2024
39f2d70
init
blegouix Apr 18, 2024
c0ef458
reinit
blegouix Apr 18, 2024
56dbf4e
remove bsplines (not in the scope of this MR anymore)
blegouix Apr 18, 2024
85a2a0f
format
blegouix Apr 18, 2024
17bb0ba
autoreview
blegouix Apr 18, 2024
7e6c05b
wip
blegouix Apr 18, 2024
8c3bb44
Merge branch 'main' into splines-doc2
blegouix Apr 18, 2024
d7472c7
wip
blegouix Apr 19, 2024
d98abe5
Merge branch 'main' into splines-doc2
blegouix Apr 19, 2024
a563f6d
wip
blegouix Apr 19, 2024
7017234
fix for allowing doxygen to keep track of integrals()
blegouix Apr 19, 2024
dcc5c6f
format
blegouix Apr 19, 2024
8f7f760
Revert "fix for allowing doxygen to keep track of integrals()"
blegouix Apr 19, 2024
9d675c9
autoreview
blegouix Apr 19, 2024
51ffa31
Merge branch 'main' into splines-doc2
blegouix Apr 19, 2024
2d0737c
Merge branch 'main' into splines-doc
blegouix Apr 19, 2024
6850ae9
B-splines
blegouix Apr 19, 2024
937d432
Update include/ddc/kernels/splines/bsplines_non_uniform.hpp
blegouix Apr 19, 2024
9ffbe04
emily's review
blegouix Apr 19, 2024
19b1c1e
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 19, 2024
8c5c579
wip
blegouix Apr 19, 2024
0589694
Update include/ddc/kernels/splines/bsplines_non_uniform.hpp
blegouix Apr 22, 2024
ffe161e
wip
blegouix Apr 22, 2024
1649b9a
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 22, 2024
f853bca
reviews
blegouix Apr 22, 2024
fb64952
Merge branch 'main' into splines-doc2
blegouix Apr 22, 2024
7a87e97
typo
blegouix Apr 22, 2024
ccc2163
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 22, 2024
65c221e
fix
blegouix Apr 22, 2024
49b9b01
minor
blegouix Apr 22, 2024
195dc50
more details on uniformity
blegouix Apr 22, 2024
bae41cc
non-uniform constructors
blegouix Apr 22, 2024
e702a5b
minor
blegouix Apr 22, 2024
f31ab4a
non_uniform constructors again
blegouix Apr 22, 2024
f180f4d
wip
blegouix Apr 22, 2024
1484581
wip on CI
blegouix Apr 22, 2024
90ccf09
Merge branch 'main' into splines-doc2
blegouix Apr 22, 2024
792b7f1
wip on CI
blegouix Apr 22, 2024
e516124
CI, integrals doxygen tracking still wrong
blegouix Apr 22, 2024
a0baf93
fix
blegouix Apr 22, 2024
d5f56b5
Update include/ddc/kernels/splines/bsplines_non_uniform.hpp
blegouix Apr 22, 2024
29a9c3c
wip
blegouix Apr 23, 2024
bfa7316
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 23, 2024
f557230
emily's review
blegouix Apr 23, 2024
e3133e5
Merge branch 'main' into splines-doc2
blegouix Apr 23, 2024
a0dc609
minor
blegouix Apr 23, 2024
403a99a
minor
blegouix Apr 23, 2024
bdd529a
the spline coefficients
blegouix Apr 23, 2024
8068c3b
CI
blegouix Apr 23, 2024
ad55555
emily's review
blegouix Apr 23, 2024
45db898
forgot a files save
blegouix Apr 23, 2024
3e9c720
Merge branch 'main' into splines-doc2
blegouix Apr 23, 2024
5f82177
fix doxygen
blegouix Apr 24, 2024
6f3d65c
Merge branch 'splines-doc2' of github.com:Maison-de-la-Simulation/ddc…
blegouix Apr 24, 2024
7dfbed2
clang-format
blegouix Apr 24, 2024
669719e
wip on CI
blegouix Apr 24, 2024
0e27bfe
null_extrap
blegouix Apr 24, 2024
3982b95
CI
blegouix Apr 24, 2024
9e5c166
Merge branch 'splines-doc2' into splines-doc
blegouix Apr 24, 2024
e302ef9
wip
blegouix Apr 24, 2024
b3f4724
Emily's review
blegouix Apr 24, 2024
d6890d9
Merge branch 'main' into splines-doc2
blegouix Apr 25, 2024
995a5df
Merge branch 'splines-doc2' into splines-doc
blegouix Apr 25, 2024
167a36f
wip
blegouix Apr 25, 2024
19e3cc9
Thomas' review
blegouix Apr 25, 2024
bd7420c
Merge branch 'main' into splines-doc2
blegouix Apr 25, 2024
12d32d8
Merge branch 'splines-doc2' into splines-doc
blegouix Apr 25, 2024
a268a08
autoreview
blegouix Apr 25, 2024
74da282
Merge branch 'main' into splines-doc
blegouix Apr 25, 2024
a972961
remove null_extrapolation
blegouix Apr 25, 2024
c116d00
Emily's minireview
blegouix Apr 25, 2024
b247fbc
shorten doxygen comments
blegouix Apr 25, 2024
185ca11
Emily's review
blegouix Apr 26, 2024
89bff3f
ident
blegouix Apr 26, 2024
bdc3ac8
wip
blegouix Apr 30, 2024
515dc8d
Emily's review
blegouix Apr 30, 2024
0a34fca
minor
blegouix Apr 30, 2024
127a22b
ident
blegouix Apr 30, 2024
948259f
ident
blegouix Apr 30, 2024
d734870
minor
blegouix Apr 30, 2024
68b639e
transform -> approximate
blegouix Apr 30, 2024
095635e
Emily's review
blegouix May 3, 2024
dc4d3f6
Update include/ddc/kernels/splines/spline_builder.hpp
blegouix May 3, 2024
9273432
Emily's review
blegouix May 6, 2024
0ddd898
minor
blegouix May 6, 2024
eef77b9
hyperparameter -> parameter
blegouix May 14, 2024
d61deeb
Merge branch 'main' into splines-doc
blegouix May 21, 2024
932620e
Apply suggestions from code review
blegouix May 27, 2024
b3d9c54
privatize transposed-domain functions
blegouix May 27, 2024
bc8ce54
Update include/ddc/kernels/splines/spline_builder.hpp
blegouix May 27, 2024
023e90c
Merge branch 'main' into splines-doc
blegouix Jun 5, 2024
bf1d586
Apply suggestions from code review
tpadioleau Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmarks/splines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ static void characteristics_advection(benchmark::State& state)
DDimY>
spline_evaluator(periodic_extrapolation, periodic_extrapolation);
ddc::Chunk coef_alloc(
spline_builder.spline_domain(),
spline_builder.batched_spline_domain(),
ddc::KokkosAllocator<double, Kokkos::DefaultExecutionSpace::memory_space>());
ddc::ChunkSpan coef = coef_alloc.span_view();
ddc::Chunk feet_coords_alloc(
spline_builder.vals_domain(),
spline_builder.batched_interpolation_domain(),
ddc::KokkosAllocator<
ddc::Coordinate<X, Y>,
Kokkos::DefaultExecutionSpace::memory_space>());
Expand Down
4 changes: 2 additions & 2 deletions examples/characteristics_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ int main(int argc, char** argv)
//! [instantiate intermediate chunks]
// Instantiate chunk of spline coefs to receive output of spline_builder
ddc::Chunk coef_alloc(
spline_builder.spline_domain(),
spline_builder.batched_spline_domain(),
ddc::DeviceAllocator<double>());
ddc::ChunkSpan coef = coef_alloc.span_view();

// Instantiate chunk to receive feet coords
ddc::Chunk feet_coords_alloc(
spline_builder.vals_domain(),
spline_builder.batched_interpolation_domain(),
ddc::DeviceAllocator<ddc::Coordinate<X>>());
ddc::ChunkSpan feet_coords = feet_coords_alloc.span_view();
//! [instantiate intermediate chunks]
Expand Down
6 changes: 6 additions & 0 deletions include/ddc/kernels/splines/bsplines_uniform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ struct UniformBSplinesBase
{
};

/**
* The type of a uniform BSplines 1D basis.
*
* @tparam Tag The tag identifying the continuous dimension which supports the building of the BSplines.
* @tparam D The degree of the BSplines.
*/
template <class Tag, std::size_t D>
class UniformBSplines : UniformBSplinesBase
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace ddc {

/**
* A class which provides helper functions to initialise the Greville points from a B-Spline definition.
* A class which provides helper functions to initialize the Greville points from a B-Spline definition.
*
* @tparam BSplines The bspline class relative to which the Greville points will be calculated.
* @tparam BcXmin The (left) boundary condition that will be used to build the splines.
Expand Down
3 changes: 3 additions & 0 deletions include/ddc/kernels/splines/null_extrapolation_rule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace ddc {

/**
* @brief A functor for describing a spline boundary value by a null extrapolation for 1D evaluator.
*/
struct NullExtrapolationRule
{
template <class CoordType, class ChunkSpan>
Expand Down
127 changes: 90 additions & 37 deletions include/ddc/kernels/splines/spline_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,26 @@
#include "deriv.hpp"

namespace ddc {

/**
* @brief An enum determining the backend solver of a SplineBuilder or SplineBuilder2d.
*
* An enum determining the backend solver of a SplineBuilder or SplineBuilder2d. Only GINKGO available at the moment,
* other solvers will be implemented in the futur.
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
*/
enum class SplineSolver {
GINKGO
}; // Only GINKGO available atm, other solvers will be implemented in the futur
};

/**
* @brief An helper giving the uniform/non_uniform status of a spline interpolation mesh according to its attributes.
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
*
* An helper giving the uniform/non_uniform status of a spline interpolation mesh according to its attributes.
* @param is_uniform A boolean giving the presumed status before considering boundary conditions.
* @param BcXmin The Xmin boundary condition.
* @param BcXmax The Xmax boundary condition.
* @param int The degree of the spline.
*/
constexpr bool is_spline_interpolation_mesh_uniform(
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
bool const is_uniform,
ddc::BoundCond const BcXmin,
Expand All @@ -34,6 +50,14 @@ constexpr bool is_spline_interpolation_mesh_uniform(
* of BSplines. The spline is constructed such that it respects the boundary conditions
* BcXmin and BcXmax, and it interpolates the function at the points on the interpolation_mesh
* associated with interpolation_mesh_type.
* @tparam ExecSpace The Kokkos execution space on which the spline transform is performed.
* @tparam MemorySpace The Kokkos memory space on which the data (interpolation function and splines coefficients) are stored.
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
* @tparam BSplines The BSplines dimension.
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
* @tparam InterpolationMesh The discrete dimension supporting the interpolation points.
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
* @tparam BcXmin The Xmin boundary condition.
* @tparam BcXmax The Xmax boundary condition.
* @tparam Solver The SplineSolver giving the backend used to perform the spline transform.
* @tparam IDimX A variadic template of all the discrete dimensions forming the full space (InterpolationMesh + batched dimensions).
*/
template <
class ExecSpace,
Expand All @@ -57,52 +81,70 @@ class SplineBuilder
using tag_type = typename InterpolationMesh::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 mesh used by this class.
* @brief The type of the interpolation mesh (discrete dimension of interest) used by this class.
*/
using interpolation_mesh_type = InterpolationMesh;

/**
* @brief The type of the BSplines which are compatible with this class.
* @brief The BSplines dimension.
*/
using bsplines_type = BSplines;
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief The deriv dimension at the boundaries.
*/
using deriv_type = ddc::Deriv<tag_type>;
blegouix marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief The type of the domain for the interpolation mesh used by this class.
*/
using interpolation_domain_type = ddc::DiscreteDomain<interpolation_mesh_type>;

using vals_domain_type = ddc::DiscreteDomain<IDimX...>;
/**
* @brief The type of the whole domain representing interpolation points.
*/
using batched_interpolation_domain_type = ddc::DiscreteDomain<IDimX...>;

/**
* @brief The type of the batch domain (obtained by removing dimension of interest from whole space).
*/
using batch_domain_type =
typename ddc::detail::convert_type_seq_to_discrete_domain<ddc::type_seq_remove_t<
ddc::detail::TypeSeq<IDimX...>,
ddc::detail::TypeSeq<interpolation_mesh_type>>>;

/**
* @brief The dimension WIP.
*/
template <typename Tag>
using spline_dim_type
= std::conditional_t<std::is_same_v<Tag, interpolation_mesh_type>, bsplines_type, Tag>;

using spline_domain_type =
using batched_spline_domain_type =
typename ddc::detail::convert_type_seq_to_discrete_domain<ddc::type_seq_replace_t<
ddc::detail::TypeSeq<IDimX...>,
ddc::detail::TypeSeq<interpolation_mesh_type>,
ddc::detail::TypeSeq<bsplines_type>>>;

using spline_tr_domain_type =
using batched_spline_tr_domain_type =
typename ddc::detail::convert_type_seq_to_discrete_domain<ddc::type_seq_merge_t<
ddc::detail::TypeSeq<bsplines_type>,
ddc::type_seq_remove_t<
ddc::detail::TypeSeq<IDimX...>,
ddc::detail::TypeSeq<interpolation_mesh_type>>>>;

using derivs_domain_type =
using batched_derivs_domain_type =
typename ddc::detail::convert_type_seq_to_discrete_domain<ddc::type_seq_replace_t<
ddc::detail::TypeSeq<IDimX...>,
ddc::detail::TypeSeq<interpolation_mesh_type>,
Expand Down Expand Up @@ -152,7 +194,7 @@ class SplineBuilder
static constexpr ddc::BoundCond s_bc_xmax = BcXmax;

private:
vals_domain_type m_vals_domain;
batched_interpolation_domain_type m_batched_interpolation_domain;

int m_offset;

Expand All @@ -165,10 +207,10 @@ class SplineBuilder
int compute_offset(interpolation_domain_type const& interpolation_domain);

explicit SplineBuilder(
vals_domain_type const& vals_domain,
batched_interpolation_domain_type const& batched_interpolation_domain,
std::optional<int> cols_per_chunk = std::nullopt,
std::optional<unsigned int> preconditionner_max_block_size = std::nullopt)
: m_vals_domain(vals_domain)
: m_batched_interpolation_domain(batched_interpolation_domain)
, m_offset(compute_offset(interpolation_domain()))
, m_dx((ddc::discrete_space<BSplines>().rmax() - ddc::discrete_space<BSplines>().rmin())
/ ddc::discrete_space<BSplines>().ncells())
Expand Down Expand Up @@ -212,9 +254,9 @@ class SplineBuilder
*/
SplineBuilder& operator=(SplineBuilder&& x) = default;

vals_domain_type vals_domain() const noexcept
batched_interpolation_domain_type batched_interpolation_domain() const noexcept
{
return m_vals_domain;
return m_batched_interpolation_domain;
}

/**
Expand All @@ -227,15 +269,15 @@ class SplineBuilder
*/
interpolation_domain_type interpolation_domain() const noexcept
{
return interpolation_domain_type(vals_domain());
return interpolation_domain_type(batched_interpolation_domain());
}

batch_domain_type batch_domain() const noexcept
{
return ddc::remove_dims_of(vals_domain(), interpolation_domain());
return ddc::remove_dims_of(batched_interpolation_domain(), interpolation_domain());
}

ddc::DiscreteDomain<bsplines_type> bsplines_domain() const noexcept // TODO : clarify name
ddc::DiscreteDomain<bsplines_type> spline_domain() const noexcept
{
return ddc::discrete_space<bsplines_type>().full_domain();
}
Expand All @@ -248,31 +290,31 @@ class SplineBuilder
*
* @return The domain for the splines.
*/
spline_domain_type spline_domain() const noexcept
batched_spline_domain_type batched_spline_domain() const noexcept
{
return ddc::replace_dim_of<
interpolation_mesh_type,
bsplines_type>(vals_domain(), bsplines_domain());
bsplines_type>(batched_interpolation_domain(), spline_domain());
}

spline_tr_domain_type spline_tr_domain() const noexcept
batched_spline_tr_domain_type spline_tr_domain() const noexcept
{
return spline_tr_domain_type(bsplines_domain(), batch_domain());
return batched_spline_tr_domain_type(spline_domain(), batch_domain());
}

derivs_domain_type derivs_xmin_domain() const noexcept
batched_derivs_domain_type derivs_xmin_domain() const noexcept
{
return ddc::replace_dim_of<interpolation_mesh_type, deriv_type>(
vals_domain(),
batched_interpolation_domain(),
ddc::DiscreteDomain<deriv_type>(
ddc::DiscreteElement<deriv_type>(1),
ddc::DiscreteVector<deriv_type>(s_nbc_xmin)));
}

derivs_domain_type derivs_xmax_domain() const noexcept
batched_derivs_domain_type derivs_xmax_domain() const noexcept
{
return ddc::replace_dim_of<interpolation_mesh_type, deriv_type>(
vals_domain(),
batched_interpolation_domain(),
ddc::DiscreteDomain<deriv_type>(
ddc::DiscreteElement<deriv_type>(1),
ddc::DiscreteVector<deriv_type>(s_nbc_xmax)));
Expand Down Expand Up @@ -309,15 +351,20 @@ class SplineBuilder
*/
template <class Layout>
void operator()(
ddc::ChunkSpan<double, spline_domain_type, Layout, memory_space> spline,
ddc::ChunkSpan<double const, vals_domain_type, Layout, memory_space> vals,
std::optional<
ddc::ChunkSpan<double const, derivs_domain_type, Layout, memory_space>> const
derivs_xmin
ddc::ChunkSpan<double, batched_spline_domain_type, Layout, memory_space> spline,
ddc::ChunkSpan<double const, batched_interpolation_domain_type, Layout, memory_space>
vals,
std::optional<ddc::ChunkSpan<
double const,
batched_derivs_domain_type,
Layout,
memory_space>> const derivs_xmin
= std::nullopt,
std::optional<
ddc::ChunkSpan<double const, derivs_domain_type, Layout, memory_space>> const
derivs_xmax
std::optional<ddc::ChunkSpan<
double const,
batched_derivs_domain_type,
Layout,
memory_space>> const derivs_xmax
= std::nullopt) const;

private:
Expand Down Expand Up @@ -629,12 +676,18 @@ void SplineBuilder<
Solver,
IDimX...>::
operator()(
ddc::ChunkSpan<double, spline_domain_type, Layout, memory_space> spline,
ddc::ChunkSpan<double const, vals_domain_type, Layout, memory_space> vals,
std::optional<ddc::ChunkSpan<double const, derivs_domain_type, Layout, memory_space>> const
derivs_xmin,
std::optional<ddc::ChunkSpan<double const, derivs_domain_type, Layout, memory_space>> const
derivs_xmax) const
ddc::ChunkSpan<double, batched_spline_domain_type, Layout, memory_space> spline,
ddc::ChunkSpan<double const, batched_interpolation_domain_type, Layout, memory_space> vals,
std::optional<ddc::ChunkSpan<
double const,
batched_derivs_domain_type,
Layout,
memory_space>> const derivs_xmin,
std::optional<ddc::ChunkSpan<
double const,
batched_derivs_domain_type,
Layout,
memory_space>> const derivs_xmax) const
{
assert(vals.template extent<interpolation_mesh_type>()
== ddc::discrete_space<bsplines_type>().nbasis() - s_nbe_xmin - s_nbe_xmax);
Expand Down
Loading
Loading