31 template <
typename NT,
typename FUN,
typename Coordinates,
typename... T>
33 std::shared_ptr<std::vector<std::future<NT>>>
request_data(FUN &fun, Coordinates &coordinates,
const double k,
34 std::tuple<T...> args)
36 return std::apply([&](
auto... args) {
return request_data<NT>(fun, coordinates, k, args...); }, args);
55 template <
typename NT,
typename FUN,
typename Coordinates,
typename... T>
57 std::shared_ptr<std::vector<std::future<NT>>>
request_data(FUN &fun, Coordinates &coordinates,
const double k,
60 auto futures = std::make_shared<std::vector<std::future<NT>>>();
63 auto req_point = [&](
auto... p) {
return fun.template request<NT>(k, p..., args...); };
65 for (
uint i = 0; i < coordinates.size(); ++i) {
67 std::apply([&](
auto... p) { futures->emplace_back(std::move(req_point(p...))); }, p);
89 template <
typename NT,
typename FUN,
typename GRID,
typename... T>
90 requires IsContainer<GRID>
91 std::shared_ptr<std::vector<std::future<NT>>>
request_data(FUN &fun,
const GRID &grid,
const double k,
92 std::tuple<T...> args)
94 return std::apply([&](
auto... args) {
return request_data<NT>(fun, grid, k, args...); }, args);
113 template <
typename NT,
typename FUN,
typename GRID,
typename... T>
114 requires IsContainer<GRID>
115 std::shared_ptr<std::vector<std::future<NT>>>
request_data(FUN &fun,
const GRID &grid,
const double k, T... args)
117 auto futures = std::make_shared<std::vector<std::future<NT>>>();
119 auto req_point = [&](
auto... p) {
return fun.template request<NT>(k, p..., args...); };
121 for (
uint i = 0; i < grid.size(); ++i) {
123 if constexpr (std::is_same_v<
decltype(p),
double> || std::is_same_v<
decltype(p),
float>)
124 futures->emplace_back(std::move(req_point(p)));
126 std::apply([&](
auto... p) { futures->emplace_back(std::move(req_point(p...))); }, p);
142 template <
typename NT1,
typename NT2,
typename... T>
143 void update_data(std::shared_ptr<std::vector<std::future<NT1>>> futures, NT2 *destination)
145 for (
uint i = 0; i < futures->size(); ++i)
146 destination[i] =
static_cast<NT2
>((*futures)[i].
get());
159 template <
typename NT,
typename INT,
typename... T>
162 for (
uint i = 0; i < futures->size(); ++i)
163 destination[i] = (*futures)[i].get();
164 destination.update();
183 template <
typename NT,
typename FUN,
typename GRID,
typename... T>
184 void get_data(NT *dest, FUN &fun,
const GRID &grid,
const double k, std::tuple<T...> args)
186 std::apply([&](
auto... args) {
get_data<NT>(dest, fun, grid, k, args...); }, args);
205 template <
typename NT,
typename FUN,
typename GRID,
typename... T>
206 void get_data(NT *dest, FUN &fun,
const GRID &grid,
const double k, T... args)
208 auto req_point = [&](
auto... p) {
return fun.template
get<NT>(k, p..., args...); };
211 tbb::parallel_for(tbb::blocked_range<uint>(0, grid.size()), [&](
const tbb::blocked_range<uint> &r) {
212 for (uint i = r.begin(); i < r.end(); ++i) {
214 if constexpr (std::is_same_v<decltype(p), double> || std::is_same_v<decltype(p), float>)
215 dest[i] = req_point(p);
217 std::apply([&](auto... p) { dest[i] = req_point(p...); }, p);
Definition coordinates.hh:15
Definition complex_math.hh:14
constexpr auto & get(named_tuple< tuple_type, strs... > &ob)
get a reference to the element with the given name
Definition tuples.hh:82
void get_data(NT *dest, FUN &fun, const GRID &grid, const double k, std::tuple< T... > args)
For a given grid and arguments, this function will call fun.request(k, grid[...].....
Definition utils.hh:184
void update_data(std::shared_ptr< std::vector< std::future< NT1 > > > futures, NT2 *destination)
Obtain data from a vector of futures and store it in a destination array.
Definition utils.hh:143
void update_interpolator(std::shared_ptr< std::vector< std::future< NT > > > futures, INT &destination)
Obtain data from a vector of futures and store it in an interpolator.
Definition utils.hh:160
unsigned int uint
Definition utils.hh:22
std::shared_ptr< std::vector< std::future< NT > > > request_data(FUN &fun, Coordinates &coordinates, const double k, std::tuple< T... > args)
For a given set of coordinates and arguments, this function will call fun.request(k,...
Definition utils.hh:33
auto make_grid(const Coordinates &coordinates)
Definition coordinates.hh:200