13#include "bsplines_non_uniform.hpp"
14#include "bsplines_uniform.hpp"
21
22
23
24
25
26
27template <
class ExecSpace,
class DDim,
class Layout,
class MemorySpace>
28void uniform_bsplines_integrals(
29 ExecSpace
const& execution_space,
32 static_assert(is_uniform_bsplines_v<DDim>);
34 Kokkos::SpaceAccessibility<ExecSpace, MemorySpace>::accessible,
35 "MemorySpace has to be accessible for ExecutionSpace.");
37 assert([&]() ->
bool {
38 if constexpr (DDim::is_periodic()) {
39 return int_vals.size() == ddc::discrete_space<DDim>().nbasis()
40 || int_vals.size() == ddc::discrete_space<DDim>().size();
42 return int_vals.size() == ddc::discrete_space<DDim>().nbasis();
48 if constexpr (DDim::is_periodic()) {
53 int_vals[dom_bsplines],
55 if (int_vals.size() ==
ddc::discrete_space<DDim>().size()) {
58 ddc::parallel_fill(execution_space, int_vals[dom_bsplines_repeated], 0);
67 int_vals[dom_bspline_entirely_in_domain],
70 ddc::DiscreteElement<DDim>
const first_bspline = full_dom_splines.front();
71 ddc::DiscreteElement<DDim>
const last_bspline = full_dom_splines.back();
76 Kokkos::IndexType<std::size_t>>(execution_space, 0, DDim::degree()),
77 KOKKOS_LAMBDA(std::size_t i) {
78 std::array<
double, DDim::degree() + 2> edge_vals_ptr;
79 Kokkos::mdspan<
double, Kokkos::extents<std::size_t, DDim::degree() + 2>>
const
80 edge_vals(edge_vals_ptr.data());
82 ddc::discrete_space<DDim>().eval_basis(
84 ddc::discrete_space<DDim>().rmin(),
87 double const d_eval =
ddc::detail::sum(edge_vals);
89 double const c_eval =
ddc::detail::sum(edge_vals, 0, DDim::degree() - i);
91 double const edge_value
94 int_vals(first_bspline + i) = edge_value;
95 int_vals(last_bspline - i) = edge_value;
101
102
103
104
105
106
107template <
class ExecSpace,
class DDim,
class Layout,
class MemorySpace>
108void non_uniform_bsplines_integrals(
109 ExecSpace
const& execution_space,
112 static_assert(is_non_uniform_bsplines_v<DDim>);
114 Kokkos::SpaceAccessibility<ExecSpace, MemorySpace>::accessible,
115 "MemorySpace has to be accessible for ExecutionSpace.");
117 assert([&]() ->
bool {
118 if constexpr (DDim::is_periodic()) {
119 return int_vals.size() == ddc::discrete_space<DDim>().nbasis()
120 || int_vals.size() == ddc::discrete_space<DDim>().size();
122 return int_vals.size() == ddc::discrete_space<DDim>().nbasis();
128 double const inv_deg = 1.0 / (DDim::degree() + 1);
132 ddc::parallel_for_each(
135 KOKKOS_LAMBDA(
ddc::DiscreteElement<DDim> ix) {
137 = (
ddc::coordinate(
ddc::discrete_space<DDim>().get_last_support_knot(ix))
139 ddc::discrete_space<DDim>().get_first_support_knot(ix)))
143 if constexpr (DDim::is_periodic()) {
144 if (int_vals.size() ==
ddc::discrete_space<DDim>().size()) {
147 ddc::parallel_fill(execution_space, int_vals[dom_bsplines_wrap], 0);
155
156
157
158
159
160
161
162template <
class ExecSpace,
class DDim,
class Layout,
class MemorySpace>
164 ExecSpace
const& execution_space,
167 static_assert(is_uniform_bsplines_v<DDim> || is_non_uniform_bsplines_v<DDim>);
168 if constexpr (is_uniform_bsplines_v<DDim>) {
169 uniform_bsplines_integrals(execution_space, int_vals);
170 }
else if constexpr (is_non_uniform_bsplines_v<DDim>) {
171 non_uniform_bsplines_integrals(execution_space, int_vals);
friend class DiscreteDomain
KOKKOS_FUNCTION constexpr bool operator!=(DiscreteVector< OTags... > const &rhs) const noexcept
The top-level namespace of DDC.
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.