Gyselalib++
 
Loading...
Searching...
No Matches
quadrature_coeffs_nd.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
6#pragma once
7
8#include <ddc/ddc.hpp>
9
10#include "ddc_aliases.hpp"
11
12
13namespace {
14template <class ExecSpace, class Grid1D>
15using CoefficientFieldMem1D = DFieldMem<IdxRange<Grid1D>, typename ExecSpace::memory_space>;
16template <class ExecSpace, class Grid1D>
17using CoefficientField1D = DField<IdxRange<Grid1D>, typename ExecSpace::memory_space>;
18} // namespace
19
30template <class ExecSpace, class... DDims>
31DFieldMem<IdxRange<DDims...>, typename ExecSpace::memory_space> quadrature_coeffs_nd(
32 IdxRange<DDims...> const& idx_range,
33 std::function<DFieldMem<IdxRange<DDims>, typename ExecSpace::memory_space>(
34 IdxRange<DDims>)>... funcs)
35{
36 DFieldMem<IdxRange<DDims...>, typename ExecSpace::memory_space> coefficients_alloc(idx_range);
37 DField<IdxRange<DDims...>, typename ExecSpace::memory_space> coefficients(
38 get_field(coefficients_alloc));
39 // Get coefficients for each dimension
40 std::tuple<CoefficientFieldMem1D<ExecSpace, DDims>...> current_dim_coeffs_alloc(
41 funcs(ddc::select<DDims>(idx_range))...);
42 std::tuple<CoefficientField1D<ExecSpace, DDims>...> current_dim_coeffs(get_field(
43 std::get<CoefficientFieldMem1D<ExecSpace, DDims>>(current_dim_coeffs_alloc))...);
44
45 ddc::parallel_for_each(
46 ExecSpace(),
47 idx_range,
48 KOKKOS_LAMBDA(Idx<DDims...> const idim) {
49 // multiply the 1D coefficients by one another
50
51 coefficients(idim)
52 = (std::get<CoefficientField1D<ExecSpace, DDims>>(current_dim_coeffs)(
53 ddc::select<DDims>(idim))
54 * ... * 1);
55 });
56 return coefficients_alloc;
57}
DFieldMem< IdxRange< DDims... >, typename ExecSpace::memory_space > quadrature_coeffs_nd(IdxRange< DDims... > const &idx_range, std::function< DFieldMem< IdxRange< DDims >, typename ExecSpace::memory_space >(IdxRange< DDims >)>... funcs)
Helper function which creates ND dimensions from N 1D quadrature coefficient functions.
Definition quadrature_coeffs_nd.hpp:31