16 static_assert(d >= 2,
"dimension must be at least 2");
24 json.get_double(
"/physical/T"))
30 const uint max_block_size = 0)
32 x_extent(x_extent), x0_extent(x0_extent), original_x0_summands(_x0_summands)
34 ptr_x_quadrature_p = quadrature_provider.
get_points<ctype>(grid_sizes[0]).data();
35 ptr_x_quadrature_w = quadrature_provider.get_weights<ctype>(grid_sizes[0]).data();
48 x0_summands = original_x0_summands;
49 ptr_x0_quadrature_p = quadrature_provider.get_points<
ctype>(grid_sizes[1] - x0_summands).data();
50 ptr_x0_quadrature_w = quadrature_provider.get_weights<
ctype>(grid_sizes[1] - x0_summands).data();
56 : quadrature_provider(other.quadrature_provider), grid_sizes(other.grid_sizes),
57 ptr_x_quadrature_p(other.ptr_x_quadrature_p), ptr_x_quadrature_w(other.ptr_x_quadrature_w),
58 ptr_x0_quadrature_p(other.ptr_x0_quadrature_p), ptr_x0_quadrature_w(other.ptr_x0_quadrature_w),
59 x_extent(other.x_extent), x0_extent(other.x0_extent), original_x0_summands(other.original_x0_summands),
60 x0_summands(other.x0_summands), m_T(other.m_T)
64 template <
typename... T> NT
get(
const ctype k,
const T &...t)
const
67 using std::sqrt, std::exp, std::log;
69 const ctype integral_start = (2 * x0_summands * (
ctype)M_PI * m_T) / k;
70 const ctype log_start = log(integral_start + (m_T == 0) *
ctype(1e-3));
71 const ctype log_ext = log(x0_extent / (integral_start + (m_T == 0) *
ctype(1e-3)));
73 const auto constant = KERNEL::constant(k, t...);
76 tbb::blocked_range2d<uint, uint>(0, grid_sizes[0], 0, grid_sizes[1]), NT(0),
77 [&](
const tbb::blocked_range2d<uint, uint> &r, NT value) -> NT {
78 for (
uint idx_x = r.rows().begin(); idx_x != r.rows().end(); ++idx_x) {
79 const ctype q = k * sqrt(ptr_x_quadrature_p[idx_x] * x_extent);
80 for (
uint idx_y = r.cols().begin(); idx_y != r.cols().end(); ++idx_y) {
81 if (idx_y >= x0_summands) {
82 const ctype q0 = k * (exp(log_start + log_ext * ptr_x0_quadrature_p[idx_y - x0_summands]) -
83 (m_T == 0) *
ctype(1e-3));
85 const ctype int_element = S_dm1
89 const ctype weight = ptr_x_quadrature_w[idx_x] * x_extent *
90 (ptr_x0_quadrature_w[idx_y - x0_summands] * log_ext * q0 / k);
93 int_element * weight * (KERNEL::kernel(q, q0, k, t...) + KERNEL::kernel(q, -q0, k, t...));
95 const ctype q0 = 2 * (
ctype)M_PI * m_T * idx_y;
96 const ctype int_element = m_T * S_dm1
99 const ctype weight = ptr_x_quadrature_w[idx_x] * x_extent;
100 value += int_element * weight *
101 (idx_y == 0 ? KERNEL::kernel(q, (
ctype)0, k, t...)
102 : KERNEL::kernel(q, q0, k, t...) + KERNEL::kernel(q, -q0, k, t...));
108 [&](NT x, NT y) -> NT {
return x + y; });
111 template <
typename... T> std::future<NT>
request(
const ctype k,
const T &...t)
const
113 return std::async(std::launch::deferred, [=,
this]() {
return get(k, t...); });
Definition integrator_finiteTx0_cpu.hh:15
const uint original_x0_summands
Definition integrator_finiteTx0_cpu.hh:123
const ctype * ptr_x_quadrature_p
Definition integrator_finiteTx0_cpu.hh:127
QuadratureProvider & quadrature_provider
Definition integrator_finiteTx0_cpu.hh:117
NT get(const ctype k, const T &...t) const
Definition integrator_finiteTx0_cpu.hh:64
uint x0_summands
Definition integrator_finiteTx0_cpu.hh:124
ctype m_T
Definition integrator_finiteTx0_cpu.hh:125
void set_x0_extent(const ctype val)
Definition integrator_finiteTx0_cpu.hh:53
const ctype x_extent
Definition integrator_finiteTx0_cpu.hh:121
std::future< NT > request(const ctype k, const T &...t) const
Definition integrator_finiteTx0_cpu.hh:111
const ctype * ptr_x0_quadrature_p
Definition integrator_finiteTx0_cpu.hh:129
IntegratorFiniteTx0TBB(const IntegratorFiniteTx0TBB &other)
Definition integrator_finiteTx0_cpu.hh:55
typename get_type::ctype< NT > ctype
Definition integrator_finiteTx0_cpu.hh:19
void set_T(const ctype T)
Definition integrator_finiteTx0_cpu.hh:42
IntegratorFiniteTx0TBB(QuadratureProvider &quadrature_provider, const std::array< uint, 2 > _grid_sizes, const ctype x_extent, const ctype x0_extent, const uint _x0_summands, const ctype T, const uint max_block_size=0)
Definition integrator_finiteTx0_cpu.hh:28
const std::array< uint, 2 > grid_sizes
Definition integrator_finiteTx0_cpu.hh:119
const ctype * ptr_x_quadrature_w
Definition integrator_finiteTx0_cpu.hh:128
const ctype * ptr_x0_quadrature_w
Definition integrator_finiteTx0_cpu.hh:130
ctype x0_extent
Definition integrator_finiteTx0_cpu.hh:122
IntegratorFiniteTx0TBB(QuadratureProvider &quadrature_provider, const std::array< uint, 2 > grid_sizes, const ctype x_extent, const ctype x0_extent, const uint x0_summands, const JSONValue &json)
Definition integrator_finiteTx0_cpu.hh:21
A wrapper around the boost json value class.
Definition json.hh:19
A class that provides quadrature points and weights, in host and device memory. The quadrature points...
Definition quadrature_provider.hh:139
const std::vector< NT > & get_points(const size_t order, const QuadratureType type=QuadratureType::legendre)
Get the quadrature points for a quadrature of size quadrature_size.
Definition quadrature_provider.hh:151
typename internal::_ctype< CT >::value ctype
Definition types.hh:106
Definition complex_math.hh:14
constexpr __forceinline__ __host__ __device__ NumberType powr(const NumberType x)
A compile-time evaluatable power function for whole number exponents.
Definition math.hh:45
constexpr auto & get(named_tuple< tuple_type, strs... > &ob)
get a reference to the element with the given name
Definition tuples.hh:82
bool __forceinline__ __host__ __device__ is_close(T1 a, T2 b, T3 eps_)
Function to evaluate whether two floats are equal to numerical precision. Tests for both relative and...
Definition math.hh:160
consteval NT S_d_prec(uint d)
Surface of a d-dimensional sphere (precompiled)
Definition math.hh:104
unsigned int uint
Definition utils.hh:22