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

SplineEvaluator doc #430

Merged
merged 149 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 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
1e85dd6
init
blegouix Apr 25, 2024
a972961
remove null_extrapolation
blegouix Apr 25, 2024
c116d00
Emily's minireview
blegouix Apr 25, 2024
1f94408
Merge branch 'splines-doc' into splines-doc3
blegouix Apr 25, 2024
b247fbc
shorten doxygen comments
blegouix Apr 25, 2024
1b436c7
Merge branch 'splines-doc' into splines-doc3
blegouix Apr 25, 2024
e10efad
wip
blegouix Apr 25, 2024
185ca11
Emily's review
blegouix Apr 26, 2024
89bff3f
ident
blegouix Apr 26, 2024
cb74298
Merge branch 'splines-doc' into splines-doc3
blegouix Apr 26, 2024
6fc578f
wip
blegouix Apr 26, 2024
48e54ab
wip
blegouix Apr 26, 2024
d881e2f
wip
blegouix Apr 26, 2024
cd554e2
wip
blegouix Apr 29, 2024
08913ba
wip
blegouix Apr 29, 2024
1c46c9e
CI
blegouix Apr 29, 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
384ae1e
wip
blegouix May 2, 2024
1d726c3
Emily's review
blegouix May 2, 2024
721f29c
init
blegouix May 2, 2024
717fb0a
caps
blegouix May 2, 2024
0182a0e
Merge branch 'splines-interpolation-evaluation' into splines-doc3
blegouix May 2, 2024
83c1395
minor
blegouix May 2, 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
9daf4f3
Emily's review
blegouix May 6, 2024
11fbb72
minor
blegouix May 6, 2024
db93125
interest coordinate
blegouix May 6, 2024
7c9d1a0
Merge branch 'splines-interpolation-evaluation' into splines-doc3
blegouix May 6, 2024
6849b72
wip
blegouix May 6, 2024
e20bcc4
wip
blegouix May 7, 2024
539d276
wip
blegouix May 7, 2024
4b1969e
SplineEvaluator2D
blegouix May 7, 2024
e156393
autoreview
blegouix May 7, 2024
ceb6761
ident
blegouix May 7, 2024
eef77b9
hyperparameter -> parameter
blegouix May 14, 2024
a7df1d1
init
blegouix May 2, 2024
5945a76
caps
blegouix May 2, 2024
a3bcb8e
interest coordinate
blegouix May 6, 2024
37e4b2b
Merge branch 'splines-interpolation-evaluation' of github.com:Maison-…
blegouix Jun 17, 2024
52d3404
Merge branch 'main' into splines-interpolation-evaluation
blegouix Jun 17, 2024
a3cde04
Merge branch 'splines-interpolation-evaluation' into splines-doc3
blegouix Jun 17, 2024
bba39c2
Apply suggestions from code review
blegouix Jun 17, 2024
b157845
Merge branch 'main' into splines-doc3
blegouix Jun 24, 2024
05b9c5e
Apply suggestions from code review
blegouix Jun 25, 2024
cc84d35
Merge branch 'main' into splines-doc3
blegouix Jun 25, 2024
95ad985
Merge branch 'main' into splines-doc3
tpadioleau Jun 25, 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
8 changes: 8 additions & 0 deletions include/ddc/kernels/splines/null_extrapolation_rule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@

namespace ddc {

/**
* @brief A functor describing a null extrapolation boundary value for 1D spline evaluator.
*/
struct NullExtrapolationRule
{
/**
* @brief Evaluates the spline at a coordinate outside of the domain.
*
* @return A double with the value of the function outside the domain (here, 0.).
*/
template <class CoordType, class ChunkSpan>
KOKKOS_FUNCTION double operator()(CoordType, ChunkSpan) const
{
Expand Down
175 changes: 167 additions & 8 deletions include/ddc/kernels/splines/spline_evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,93 @@

namespace ddc {

/**
* @brief A class to evaluate, differentiate or integrate a spline function.
*
* A class which contains an operator () which can be used to evaluate, differentiate or integrate a spline function.
*
* @tparam ExecSpace The Kokkos execution space on which the spline evaluation is performed.
* @tparam MemorySpace The Kokkos memory space on which the data (spline coefficients and evaluation) is stored.
* @tparam BSplines The discrete dimension representing the B-splines.
* @tparam EvaluationMesh The discrete dimension on which evaluation points are defined.
* @tparam LeftExtrapolationRule The lower extrapolation rule type.
* @tparam RightExtrapolationRule The upper extrapolation rule type.
blegouix marked this conversation as resolved.
Show resolved Hide resolved
* @tparam IDimX A variadic template of all the discrete dimensions forming the full space (EvaluationMesh + batched dimensions).
*/
template <
class ExecSpace,
class MemorySpace,
class BSplinesType,
class BSplines,
class EvaluationMesh,
class LeftExtrapolationRule,
class RightExtrapolationRule,
class... IDimX>
class SplineEvaluator
{
private:
// Tags to determine what to evaluate
/**
* @brief Tag to indicate that the value of the spline should be evaluated.
*/
struct eval_type
{
};

/**
* @brief Tag to indicate that derivative of the spline should be evaluated.
*/
struct eval_deriv_type
{
};

using tag_type = typename BSplinesType::tag_type;
using tag_type = typename BSplines::tag_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;

using bsplines_type = BSplinesType;

using left_extrapolation_rule_type = LeftExtrapolationRule;
using right_extrapolation_rule_type = RightExtrapolationRule;

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

/// @brief The discrete dimension representing the B-splines.
using bsplines_type = BSplines;

/// @brief The type of the domain for the 1D evaluation mesh used by this class.
using evaluation_domain_type = ddc::DiscreteDomain<evaluation_mesh_type>;

/// @brief The type of the whole domain representing evaluation points.
using batched_evaluation_domain_type = ddc::DiscreteDomain<IDimX...>;

/// @brief The type of the 1D spline domain corresponding to the dimension of interest.
using spline_domain_type = ddc::DiscreteDomain<bsplines_type>;

/**
* @brief The type of the batch domain (obtained by removing the dimension of interest
* from the whole domain).
*/
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<evaluation_mesh_type>>>;

/**
* @brief The type of the whole spline domain (cartesian product of 1D spline domain
* and batch domain) preserving the order of dimensions.
*/
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<evaluation_mesh_type>,
ddc::detail::TypeSeq<bsplines_type>>>;

/// @brief The type of the extrapolation rule at the lower boundary.
using left_extrapolation_rule_type = LeftExtrapolationRule;

/// @brief The type of the extrapolation rule at the upper boundary.
using right_extrapolation_rule_type = RightExtrapolationRule;


private:
LeftExtrapolationRule m_left_extrap_rule;
Expand Down Expand Up @@ -105,6 +141,14 @@ class SplineEvaluator
memory_space>>,
"RightExtrapolationRule::operator() has to be callable with usual arguments.");

/**
* @brief Build a SplineEvaluator acting on batched_spline_domain.
*
* @param left_extrap_rule The extrapolation rule at the lower boundary.
* @param right_extrap_rule The extrapolation rule at the upper boundary.
*
* @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
*/
explicit SplineEvaluator(
LeftExtrapolationRule const& left_extrap_rule,
RightExtrapolationRule const& right_extrap_rule)
Expand All @@ -113,26 +157,79 @@ class SplineEvaluator
{
}

/**
* @brief Copy-constructs.
*
* @param x A reference to another SplineEvaluator.
*/
SplineEvaluator(SplineEvaluator const& x) = default;

/**
* @brief Move-constructs.
*
* @param x An rvalue to another SplineEvaluator.
*/
SplineEvaluator(SplineEvaluator&& x) = default;

/// @brief Destructs
~SplineEvaluator() = default;

/**
* @brief Copy-assigns.
*
* @param x A reference to another SplineEvaluator.
* @return A reference to this object.
*/
SplineEvaluator& operator=(SplineEvaluator const& x) = default;

/**
* @brief Move-assigns.
*
* @param x An rvalue to another SplineEvaluator.
* @return A reference to this object.
*/
SplineEvaluator& operator=(SplineEvaluator&& x) = default;

/**
* @brief Get the lower extrapolation rule.
*
* Extrapolation rules are functors used to define the behavior of the SplineEvaluator out of the domain where the break points of the B-splines are defined.
*
* @return The lower extrapolation rule.
*
* @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
*/
left_extrapolation_rule_type left_extrapolation_rule() const
{
return m_left_extrap_rule;
}

/**
* @brief Get the upper extrapolation rule.
*
* Extrapolation rules are functors used to define the behavior of the SplineEvaluator out of the domain where the break points of the B-splines are defined.
*
* @return The upper extrapolation rule.
*
* @see NullExtrapolationRule ConstantExtrapolationRule PeriodicExtrapolationRule
*/
right_extrapolation_rule_type right_extrapolation_rule() const
{
return m_right_extrap_rule;
}

/**
* @brief Evaluate 1D spline function (described by its spline coefficients) at a given coordinate.
*
* The spline coefficients represent a 1D spline function defined on a B-splines (basis splines). They can be obtained via various methods, such as using a SplineBuilder.
*
* Remark: calling SplineBuilder then SplineEvaluator corresponds to a spline interpolation.
*
* @param coord_eval The coordinate where the spline is evaluated. Note that only the component along the dimension of interest is used.
* @param spline_coef A ChunkSpan storing the 1D spline coefficients.
*
* @return The value of the spline function at the desired coordinate.
*/
template <class Layout, class... CoordsDims>
KOKKOS_FUNCTION double operator()(
ddc::Coordinate<CoordsDims...> const& coord_eval,
Expand All @@ -142,6 +239,26 @@ class SplineEvaluator
return eval(coord_eval, spline_coef);
}

/**
* @brief Evaluate spline function (described by its spline coefficients) on a mesh.
*
* The spline coefficients represent a spline function defined on a cartesian product of batch_domain and B-splines
* (basis splines). They can be obtained via various methods, such as using a SplineBuilder.
*
* This is not a multidimensional evaluation. This is a batched 1D evaluation. This means that for each slice of coordinates
* identified by a batch_domain_type::discrete_element_type, the evaluation is performed with the 1D set of
* spline coefficients identified by the same batch_domain_type::discrete_element_type.
*
* Remark: calling SplineBuilder then SplineEvaluator corresponds to a spline interpolation.
*
* @param[out] spline_eval The values of the spline function at the desired coordinates. For practical reasons those are
* stored in a ChunkSpan defined on a batched_evaluation_domain_type.
* @param[in] coords_eval The coordinates where the spline is evaluated. Those are
* stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
* points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
* the set of 1D spline coefficients retained to perform the evaluation).
* @param[in] spline_coef A ChunkSpan storing the spline coefficients.
*/
template <class Layout1, class Layout2, class Layout3, class... CoordsDims>
void operator()(
ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
Expand Down Expand Up @@ -170,6 +287,17 @@ class SplineEvaluator
});
}

/**
* @brief Differentiate 1D spline function (described by its spline coefficients) at a given coordinate.
*
* The spline coefficients represent a 1D spline function defined on a B-splines (basis splines). They can be
* obtained via various methods, such as using a SplineBuilder.
*
* @param coord_eval The coordinate where the spline is differentiated. Note that only the component along the dimension of interest is used.
* @param spline_coef A ChunkSpan storing the 1D spline coefficients.
*
* @return The derivative of the spline function at the desired coordinate.
*/
template <class Layout, class... CoordsDims>
KOKKOS_FUNCTION double deriv(
ddc::Coordinate<CoordsDims...> const& coord_eval,
Expand All @@ -179,6 +307,24 @@ class SplineEvaluator
return eval_no_bc<eval_deriv_type>(coord_eval, spline_coef);
}

/**
* @brief Differentiate spline function (described by its spline coefficients) on a mesh.
*
* The spline coefficients represent a spline function defined on a cartesian product of batch_domain and B-splines
* (basis splines). They can be obtained via various methods, such as using a SplineBuilder.
*
* The derivation is not performed in a multidimensional way (in any sense). This is a batched 1D derivation.
* This means that for each slice of coordinates identified by a batch_domain_type::discrete_element_type,
* the derivation is performed with the 1D set of spline coefficients identified by the same batch_domain_type::discrete_element_type.
*
* @param[out] spline_eval The derivatives of the spline function at the desired coordinates. For practical reasons those are
* stored in a ChunkSpan defined on a batched_evaluation_domain_type.
* @param[in] coords_eval The coordinates where the spline is differentiated. Those are
* stored in a ChunkSpan defined on a batched_evaluation_domain_type. Note that the coordinates of the
* points represented by this domain are unused and irrelevant (but the points themselves (DiscreteElement) are used to select
* the set of 1D spline coefficients retained to perform the evaluation).
* @param[in] spline_coef A ChunkSpan storing the spline coefficients.
*/
template <class Layout1, class Layout2, class Layout3, class... CoordsDims>
void deriv(
ddc::ChunkSpan<double, batched_evaluation_domain_type, Layout1, memory_space> const
Expand Down Expand Up @@ -208,6 +354,19 @@ class SplineEvaluator
});
}

/** @brief Perform batched 1D integrations of a spline function (described by its spline coefficients) along the dimension of interest and store results on a subdomain of batch_domain.
EmilyBourne marked this conversation as resolved.
Show resolved Hide resolved
*
* The spline coefficients represent a spline function defined on a B-splines (basis splines). They can be obtained via the SplineBuilder.
*
* The integration is not performed in a multidimensional way (in any sense). This is a batched 1D integration.
* This means that for each element of integrals, the integration is performed with the 1D set of
* spline coefficients identified by the same DiscreteElement.
*
* @param[out] integrals The integrals of the spline function on the subdomain of batch_domain. For practical reasons those are
* stored in a ChunkSpan defined on a batch_domain_type. Note that the coordinates of the
* points represented by this domain are unused and irrelevant.
* @param[in] spline_coef A ChunkSpan storing the spline coefficients.
*/
template <class Layout1, class Layout2>
void integrate(
ddc::ChunkSpan<double, batch_domain_type, Layout1, memory_space> const integrals,
Expand Down
Loading
Loading