Commit dd7f2600 authored by Burlen Loring's avatar Burlen Loring

Merge branch 'oscillator_bug_fix' into 'master'

fix indexing bug in oscillator miniapp

See merge request !140
parents 0c0b645f 71c6415e
......@@ -3,16 +3,33 @@
// --------------------------------------------------------------------------
void Block::update_fields(float t)
{
// update the scalar oscilltor field
diy::for_each(grid.shape(), [&](const Vertex& v)
// update the scalar oscillator field
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);
gv = 0;
auto v_global = v + Vertex(&bounds.min[0]);
for (auto& o : oscillators)
gv += o.evaluate(v_global, t);
});
float z = k0 + k;
float *pdk = pdata + k*nij;
for (int j = 0; j < nj; ++j)
{
float y = j0 + j;
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
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