5#include "grid_sampler.h"
19 static constexpr std::array
dim{512ul, 128ul, 201ul};
33 for (
size_t ti = 0; ti <
dim[2]; ++ti) {
35 ss <<
domain.dimension(2)[ti];
36 const std::string filename = rbc_binary_dir +
"/rbc_" + ss.str() +
".bin";
39 std::ifstream file(filename, std::ifstream::binary);
41 std::vector<vec<double, 2>> data(
dim[0] *
dim[1]);
43 constexpr auto num_bytes =
sizeof(
double) *
dim[0] *
dim[1] * 2;
44 file.read((
char*)(data.data()), num_bytes);
47 grids.back().data() = data;
49 throw std::runtime_error{
"could not open " + filename};
55 const auto& times =
domain.dimension(2);
56 for (
size_t i = 0; i <
grids.size() - 1; ++i)
57 if (times[i] <= t && t <= times[i + 1]) {
58 real_type f = (t - times[i]) / (times[i + 1] - times[i]);
59 return (1 - f) *
grids[i](pos(0), pos(1)) +
60 f *
grids[i + 1](pos(0), pos(1));
66 auto& times =
domain.dimension(2);
67 return times.front() <= t && t <= times.back() &&
68 grids.front().in_domain(p(0), p(1));
Definition: grid_edge.h:16
Definition: algorithm.h:6
Real real_type
Definition: field.h:17
2 tensor_type
Definition: field.h:18
Definition: interpolation.h:16
Definition: linspace.h:26
bool in_domain(const pos_type &p, real_type t) const
Definition: rbc.h:65
grid_sampler< real_type, 2, vec< real_type, 2 >, interpolation::linear, interpolation::linear > grid_t
Definition: rbc.h:18
static constexpr grid domain
Definition: rbc.h:20
std::vector< grid_t > grids
Definition: rbc.h:25
static constexpr std::array dim
Definition: rbc.h:19
tensor_type evaluate(const pos_type &pos, real_type t) const
Definition: rbc.h:54
rbc(const std::string &rbc_binary_dir)
Definition: rbc.h:29
void read_from_binary(const std::string &rbc_binary_dir)
Definition: rbc.h:31