13#include <Kokkos_Core.hpp>
25
26
27
28
29
30
31template <
class ExecSpace,
class DDim,
class Layout,
class MemorySpace>
32void uniform_bsplines_integrals(
33 ExecSpace
const& execution_space,
36 static_assert(
ddc::
concepts::uniform_bsplines<DDim>);
38 Kokkos::SpaceAccessibility<ExecSpace, MemorySpace>::accessible,
39 "MemorySpace has to be accessible for ExecutionSpace.");
41 assert([&]() ->
bool {
42 if constexpr (DDim::is_periodic()) {
43 return int_vals.size() ==
ddc::discrete_space<DDim>().nbasis()
44 || int_vals.size() ==
ddc::discrete_space<DDim>().size();
46 return int_vals.size() ==
ddc::discrete_space<DDim>().nbasis();
52 if constexpr (DDim::is_periodic()) {
57 int_vals[dom_bsplines],
59 if (int_vals.size() ==
ddc::discrete_space<DDim>().size()) {
62 ddc::parallel_fill(execution_space, int_vals[dom_bsplines_repeated], 0);
71 int_vals[dom_bspline_entirely_in_domain],
74 ddc::DiscreteElement<DDim>
const first_bspline = full_dom_splines.front();
75 ddc::DiscreteElement<DDim>
const last_bspline = full_dom_splines.back();
80 Kokkos::IndexType<std::size_t>>(execution_space, 0, DDim::degree()),
81 KOKKOS_LAMBDA(std::size_t i) {
82 std::array<Real, DDim::degree() + 2> edge_vals_ptr;
83 Kokkos::mdspan<Real, Kokkos::extents<std::size_t, DDim::degree() + 2>>
const
84 edge_vals(edge_vals_ptr.data());
86 ddc::discrete_space<DDim>().eval_basis(
88 ddc::discrete_space<DDim>().rmin(),
91 Real
const d_eval =
ddc::detail::sum(edge_vals);
93 Real
const c_eval =
ddc::detail::sum(edge_vals, 0, DDim::degree() - i);
98 int_vals(first_bspline + i) = edge_value;
99 int_vals(last_bspline - i) = edge_value;
105
106
107
108
109
110
111template <
class ExecSpace,
class DDim,
class Layout,
class MemorySpace>
112void non_uniform_bsplines_integrals(
113 ExecSpace
const& execution_space,
116 static_assert(
ddc::
concepts::non_uniform_bsplines<DDim>);
118 Kokkos::SpaceAccessibility<ExecSpace, MemorySpace>::accessible,
119 "MemorySpace has to be accessible for ExecutionSpace.");
121 assert([&]() ->
bool {
122 if constexpr (DDim::is_periodic()) {
123 return int_vals.size() ==
ddc::discrete_space<DDim>().nbasis()
124 || int_vals.size() ==
ddc::discrete_space<DDim>().size();
126 return int_vals.size() ==
ddc::discrete_space<DDim>().nbasis();
132 Real
const inv_deg = 1.0 / (DDim::degree() + 1);
136 ddc::parallel_for_each(
139 KOKKOS_LAMBDA(
ddc::DiscreteElement<DDim> ix) {
141 = (
ddc::coordinate(
ddc::discrete_space<DDim>().get_last_support_knot(ix))
143 ddc::discrete_space<DDim>().get_first_support_knot(ix)))
147 if constexpr (DDim::is_periodic()) {
148 if (int_vals.size() ==
ddc::discrete_space<DDim>().size()) {
151 ddc::parallel_fill(execution_space, int_vals[dom_bsplines_wrap], 0);
159
160
161
162
163
164
165
166template <
class ExecSpace,
concepts::bsplines DDim,
class Layout,
class MemorySpace>
168 ExecSpace
const& execution_space,
171 if constexpr (is_uniform_bsplines_v<DDim>) {
172 uniform_bsplines_integrals(execution_space, int_vals);
173 }
else if constexpr (is_non_uniform_bsplines_v<DDim>) {
174 non_uniform_bsplines_integrals(execution_space, int_vals);
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.
The top-level namespace of DDC.
constexpr bool is_uniform_bsplines_v
Indicates if a tag corresponds to uniform B-splines or not.
constexpr int n_boundary_equations(ddc::SplineBuilderClosure const sbc, std::size_t const degree)
Return the number of equations needed to describe a given closure relation.
ddc::ChunkSpan< Real, ddc::DiscreteDomain< DDim >, Layout, MemorySpace > integrals(ExecSpace const &execution_space, ddc::ChunkSpan< Real, ddc::DiscreteDomain< DDim >, Layout, MemorySpace > int_vals)
Compute the integrals of the B-splines.
constexpr bool is_non_uniform_bsplines_v
Indicates if a tag corresponds to non-uniform B-splines or not.
SplineBuilderClosure
An enum representing a spline closure relation.
@ HOMOGENEOUS_HERMITE
Homogeneous Hermite closure relation (derivatives are 0)
@ GREVILLE
Use Greville points instead of conditions on derivative for B-Spline interpolation.
@ HERMITE
Hermite closure relation.
@ PERIODIC
Periodic closure relation u(1)=u(n)
A compile-time sequence of types.
A templated struct representing a discrete dimension storing the derivatives of a function along a co...