/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/integration/abstract_integrator.hh Source File#

DiFfRG: /home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/physics/integration/abstract_integrator.hh Source File
DiFfRG
Discretization Framework for functional Renormalization Group flows
abstract_integrator.hh
Go to the documentation of this file.
1#pragma once
2
3// DiFfRG
6
7namespace DiFfRG
8{
9 namespace internal
10 {
17 inline size_t default_quadrature_order(const std::string &name)
18 {
19 return name.starts_with("x") || name.starts_with("q") ? 32 : 8;
20 }
21
22 template <int dim, typename NT = double>
23 std::array<size_t, dim> make_int_grid(const ConfigTree &config, const std::array<std::string, dim> &names)
24 {
25 std::array<size_t, dim> int_grid;
26 for (int i = 0; i < dim; ++i)
27 int_grid[i] = config.get_uint_or_warn("/integration/" + names[i], default_quadrature_order(names[i]));
28 if constexpr (get_type::is_autodiff<NT>) {
29 const double factor = config.get_double("/integration/jacobian_quadrature_factor", 0.8);
30 for (int i = 0; i < dim; ++i)
31 int_grid[i] = static_cast<size_t>(factor * int_grid[i]);
32 }
33 return int_grid;
34 }
35 } // namespace internal
36
37 template <typename KERNEL>
38 concept provides_regulator = requires { typename KERNEL::Regulator; };
39
40 template <typename NT, typename KERNEL, typename ctype, int dim, typename... ARGS>
41 NT multidim_kernel_call(const ARGS &...args)
42 {
43 if constexpr (dim == 0)
44 return KERNEL::kernel(args...);
45 else {
46 const ctype darg{};
47 return multidim_kernel_call<NT, KERNEL, ctype, dim - 1, ARGS...>(darg, args...);
48 }
49 }
50
51 template <typename NT, typename KERNEL, typename ctype, int dim, typename... ARGS>
53 requires(const ARGS &...args) { multidim_kernel_call<NT, KERNEL, ctype, dim, ARGS...>(args...); };
54
55 template <typename NT, typename KERNEL, typename... ARGS>
56 concept provides_constant = requires(const ARGS &...args) {
57 { KERNEL::constant(args...) } -> std::convertible_to<NT>;
58 };
59
60 template <typename NT, typename KERNEL, typename ctype, int dim, typename... ARGS>
62 (provides_kernel<NT, KERNEL, ctype, dim, ARGS...> && provides_constant<NT, KERNEL, ARGS...>);
63
64 template <typename NT, typename KERNEL, typename ctype, int dim, typename... ARGS>
66 {
67 static_assert(provides_kernel<NT, KERNEL, ctype, dim, ARGS...>,
68 "Kernel must provide a static 'kernel(...)' method callable with the integration arguments.");
69 static_assert(provides_constant<NT, KERNEL, ARGS...>,
70 "Kernel must provide a static 'constant(...)' method returning the numeric type.");
71 }
72
81 {
82 public:
83 // Construction order is part of the program, so these ids come out the same on every rank
84 // without any communication -- which is what lets MapScheduler put them in a plan that all
85 // ranks must agree on.
86 //
87 // The copy constructor is deliberately left implicit, so that an id travels with the object.
88 // Integrators are captured by value into device lambdas (KOKKOS_CLASS_LAMBDA), and a
89 // user-defined copy constructor is host-only, which makes that capture ill-formed. Copies
90 // sharing an id is harmless: only the host-side original ever schedules.
92
94 KOKKOS_FORCEINLINE_FUNCTION size_t integrator_id() const { return m_integrator_id; }
95
96 protected:
98
99 private:
100 static size_t next_integrator_id();
101 };
102} // namespace DiFfRG
Common base of every integrator, carrying the identity MapScheduler needs.
Definition abstract_integrator.hh:81
KOKKOS_FORCEINLINE_FUNCTION size_t integrator_id() const
Stable, rank-independent identity of this integrator.
Definition abstract_integrator.hh:94
static size_t next_integrator_id()
size_t m_integrator_id
Definition abstract_integrator.hh:97
AbstractIntegrator()
Definition abstract_integrator.hh:91
A hierarchical configuration tree, readable from JSON and TOML files.
Definition config_tree.hh:32
Definition abstract_integrator.hh:61
Definition abstract_integrator.hh:56
Definition abstract_integrator.hh:52
Definition abstract_integrator.hh:38
constexpr bool is_autodiff
Definition types.hh:78
size_t default_quadrature_order(const std::string &name)
Fallback quadrature order for a momentum-space direction.
Definition abstract_integrator.hh:17
std::array< size_t, dim > make_int_grid(const ConfigTree &config, const std::array< std::string, dim > &names)
Definition abstract_integrator.hh:23
Definition complex_math.hh:10
consteval void check_kernel_requirements()
Definition abstract_integrator.hh:65
@ config
/discretization/threads.
NT multidim_kernel_call(const ARGS &...args)
Definition abstract_integrator.hh:41