28 static_cast<double>(
dx),
29 static_cast<double>(
ox),
30 static_cast<double>(
oy),
31 static_cast<double>(
oz)},
32 data_(static_cast<
idx>(grid_.
size())) {}
44 fill(std::forward<F>(f));
49 int nx()
const {
return grid_.
nx; }
50 int ny()
const {
return grid_.
ny; }
51 int nz()
const {
return grid_.
nz; }
52 float dx()
const {
return static_cast<float>(grid_.
dx); }
53 float ox()
const {
return static_cast<float>(grid_.
ox); }
54 float oy()
const {
return static_cast<float>(grid_.
oy); }
55 float oz()
const {
return static_cast<float>(grid_.
oz); }
60 void set(
int i,
int j,
int k,
double v) {
61 data_[grid_.
flat(i, j, k)] =
static_cast<real>(v);
65 for (
idx n = 0; n < data_.
size(); ++n)
66 data_[n] =
static_cast<real>(v);
72 for (
int k = 0; k < grid_.
nz; ++k)
73 for (
int j = 0; j < grid_.
ny; ++j)
74 for (
int i = 0; i < grid_.
nx; ++i)
75 data_[grid_.
flat(i, j, k)] =
static_cast<real>(f(i, j, k));
84 float sample(
float x,
float y,
float z)
const;
102 std::array<float, 3>
sample(
float px,
float py,
float pz)
const;
constexpr idx size() const noexcept
void set(int i, int j, int k, double v)
real operator()(int i, int j, int k) const
const real * data() const
const Vector & vec() const
void fill(F &&f)
Fill every node with f(i, j, k).
ScalarField3D(int nx, int ny, int nz, float dx, F &&f, float ox=0.0f, float oy=0.0f, float oz=0.0f)
real & operator()(int i, int j, int k)
float sample(float x, float y, float z) const
ScalarField3D(int nx, int ny, int nz, float dx, float ox=0.0f, float oy=0.0f, float oz=0.0f)
const Grid3D & grid() const
3D uniform Cartesian grid: geometry only, no field data.
idx flat(int i, int j, int k) const
double dx
uniform cell size
double oz
origin (physical coordinate of node 0)
std::array< float, 3 > sample(float px, float py, float pz) const
Dense vector storage and operations.