41#include <domain_decomposition/BlockDataID.h>
51namespace ReactionKernelIndexedSelector {
53template <
typename FloatType =
double, std::
size_t N = 1>
struct KernelTrait {
54 using ReactionKernelIndexed =
55 pystencils::ReactionKernelIndexed_1_double_precision;
58template <>
struct KernelTrait<double, 2> {
59 using ReactionKernelIndexed =
60 pystencils::ReactionKernelIndexed_2_double_precision;
63template <>
struct KernelTrait<double, 3> {
64 using ReactionKernelIndexed =
65 pystencils::ReactionKernelIndexed_3_double_precision;
68template <>
struct KernelTrait<double, 4> {
69 using ReactionKernelIndexed =
70 pystencils::ReactionKernelIndexed_4_double_precision;
73template <>
struct KernelTrait<double, 5> {
74 using ReactionKernelIndexed =
75 pystencils::ReactionKernelIndexed_5_double_precision;
78template <>
struct KernelTrait<float, 1> {
79 using ReactionKernelIndexed =
80 pystencils::ReactionKernelIndexed_1_single_precision;
83template <>
struct KernelTrait<float, 2> {
84 using ReactionKernelIndexed =
85 pystencils::ReactionKernelIndexed_2_single_precision;
88template <>
struct KernelTrait<float, 3> {
89 using ReactionKernelIndexed =
90 pystencils::ReactionKernelIndexed_3_single_precision;
93template <>
struct KernelTrait<float, 4> {
94 using ReactionKernelIndexed =
95 pystencils::ReactionKernelIndexed_4_single_precision;
98template <>
struct KernelTrait<float, 5> {
99 using ReactionKernelIndexed =
100 pystencils::ReactionKernelIndexed_5_single_precision;
103template <
typename FloatType,
class Reactant, std::size_t... ints>
104auto get_kernel_impl(
const std::vector<std::shared_ptr<Reactant>> &reactants,
105 const double coefficient,
const BlockDataID &indexFieldID,
106 std::index_sequence<ints...> int_seq) {
107 auto kernel = std::make_shared<
108 typename KernelTrait<FloatType, int_seq.size()>::ReactionKernelIndexed>(
110 walberla::BlockDataID(
111 reactants[ints]->get_species()->get_density_id())...,
112 numeric_cast<FloatType>(reactants[ints]->get_order())...,
113 numeric_cast<FloatType>(coefficient),
114 numeric_cast<FloatType>(reactants[ints]->get_stoech_coeff())...);
116 std::function<void(IBlock *)> sweep = [kernel](IBlock *b) { kernel->run(b); };
120template <
typename FloatType,
class Reactant,
class... Args>
121auto get_kernel_impl(
const std::vector<std::shared_ptr<Reactant>> &reactants,
123 switch (reactants.size()) {
126 return get_kernel_impl<FloatType>(reactants, args...,
127 std::make_index_sequence<1>{});
130 return get_kernel_impl<FloatType>(reactants, args...,
131 std::make_index_sequence<2>{});
134 return get_kernel_impl<FloatType>(reactants, args...,
135 std::make_index_sequence<3>{});
138 return get_kernel_impl<FloatType>(reactants, args...,
139 std::make_index_sequence<4>{});
142 return get_kernel_impl<FloatType>(reactants, args...,
143 std::make_index_sequence<5>{});
146 throw std::runtime_error(
"reactions of this size are not implemented!");
150template <
class Reactant,
class... Args>
151auto get_kernel(
const std::vector<std::shared_ptr<Reactant>> &reactants,
154 const auto is_double_precision =
155 reactants[0]->get_species()->is_double_precision();
157 if (is_double_precision) {
158 return get_kernel_impl<double>(reactants, args...);
161 return get_kernel_impl<float>(reactants, args...);
\file PackInfoPdfDoublePrecision.cpp \author pystencils