60 double operator()(ExecutionSpace exec_space, IntegratorFunction integrated_function)
const
63 Kokkos::SpaceAccessibility<ExecutionSpace, MemorySpace>::accessible,
64 "Execution space is not compatible with memory space where coefficients are found");
66 std::is_invocable_v<IntegratorFunction, IdxQuadrature>,
67 "The object passed to Quadrature::operator() is not defined on the quadrature "
70 QuadConstField
const coeff_proxy = m_coefficients;
76 if constexpr (std::is_same_v<ExecutionSpace, Kokkos::DefaultHostExecutionSpace>) {
77 return ddc::transform_reduce(
78 get_idx_range(coeff_proxy),
80 ddc::reducer::sum<double>(),
81 KOKKOS_LAMBDA(IdxQuadrature
const ix) {
82 return coeff_proxy(ix) * integrated_function(ix);
85 return ddc::parallel_transform_reduce(
87 get_idx_range(coeff_proxy),
89 ddc::reducer::sum<double>(),
90 KOKKOS_LAMBDA(IdxQuadrature
const ix) {
91 return coeff_proxy(ix) * integrated_function(ix);
113 ExecutionSpace exec_space,
114 Field<double, BatchIdxRange, MemorySpace>
const result,
115 IntegratorFunction integrated_function)
const
118 Kokkos::SpaceAccessibility<ExecutionSpace, MemorySpace>::accessible,
119 "Execution space is not compatible with memory space where coefficients are found");
121 std::is_same_v<ExecutionSpace, Kokkos::DefaultExecutionSpace>,
122 "Kokkos::TeamPolicy only works with the default execution space. Please use "
123 "DefaultExecutionSpace to call this batched operator.");
124 using ExpectedBatchDims = ddc::type_seq_remove_t<
125 ddc::to_type_seq_t<IdxRangeTotal>,
126 ddc::to_type_seq_t<IdxRangeQuadrature>>;
128 ddc::type_seq_same_v<ddc::to_type_seq_t<BatchIdxRange>, ExpectedBatchDims>,
129 "The batch idx_range deduced from the type of result does not match the class "
130 "template parameters.");
133 using IdxTotal =
typename IdxRangeTotal::discrete_element_type;
134 using IdxBatch =
typename BatchIdxRange::discrete_element_type;
137 std::is_invocable_v<IntegratorFunction, IdxTotal>,
138 "The object passed to Quadrature::operator() is not defined on the total "
142 IdxRangeQuadrature quad_idx_range(get_idx_range(m_coefficients));
143 BatchIdxRange batch_idx_range(get_idx_range(result));
145 QuadConstField
const coeff_proxy = m_coefficients;
147 Kokkos::parallel_for(
148 Kokkos::TeamPolicy<>(exec_space, batch_idx_range.size(), Kokkos::AUTO),
149 KOKKOS_LAMBDA(
const Kokkos::TeamPolicy<>::member_type& team) {
150 const int idx = team.league_rank();
151 IdxBatch ib = to_discrete_element(idx, batch_idx_range);
155 Kokkos::parallel_reduce(
156 Kokkos::TeamThreadRange(team, quad_idx_range.size()),
157 [&](
int const& thread_index,
double& sum) {
159 = to_discrete_element(thread_index, quad_idx_range);
161 sum += coeff_proxy(iq) * integrated_function(it);
164 result(ib) = teamSum;