Commit 71c6415e authored by Burlen Loring's avatar Burlen Loring

fix indexing bug in oscillator miniapp

parent 0c0b645f
...@@ -3,16 +3,33 @@ ...@@ -3,16 +3,33 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
void Block::update_fields(float t) void Block::update_fields(float t)
{ {
// update the scalar oscilltor field // update the scalar oscillator field
diy::for_each(grid.shape(), [&](const Vertex& v) const Vertex &shape = grid.shape();
int ni = shape[0];
int nj = shape[1];
int nk = shape[2];
int nij = ni*nj;
int i0 = bounds.min[0];
int j0 = bounds.min[1];
int k0 = bounds.min[2];
float *pdata = grid.data();
for (int k = 0; k < nk; ++k)
{ {
auto& gv = grid(v); float z = k0 + k;
gv = 0; float *pdk = pdata + k*nij;
auto v_global = v + Vertex(&bounds.min[0]); for (int j = 0; j < nj; ++j)
{
for (auto& o : oscillators) float y = j0 + j;
gv += o.evaluate(v_global, t); float *pd = pdk + j*ni;
}); for (int i = 0; i < ni; ++i)
{
float x = i0 + i;
pd[i] = 0.f;
for (auto& o : oscillators)
pd[i] += o.evaluate({x,y,z}, t);
}
}
}
// update the velocity field on the particle mesh // update the velocity field on the particle mesh
for (auto& particle : particles) for (auto& particle : particles)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment