aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-05-28 18:00:01 +0200
committerAdrian Kummerlaender2019-05-28 18:00:01 +0200
commitccd0fc6bb23dd3b98961ffb3a3cb396261192926 (patch)
tree42cc7f7e18a3e74b00e19020462c680442cbc0ae
parentde97cf07c1f0e54f4760b6153054cfaaa754663d (diff)
downloadsymlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.tar
symlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.tar.gz
symlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.tar.bz2
symlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.tar.lz
symlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.tar.xz
symlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.tar.zst
symlbm_playground-ccd0fc6bb23dd3b98961ffb3a3cb396261192926.zip
Pull streaming for local writes
-rw-r--r--implosion.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/implosion.py b/implosion.py
index b786461..8e75921 100644
--- a/implosion.py
+++ b/implosion.py
@@ -74,15 +74,20 @@ __kernel void collide_and_stream(__global float* pop_a,
const unsigned int gid = get_global_id(0);
const uint2 cell = cellAtGid(gid);
- float d = density(&pop_b[gid*9]);
- float2 v = velocity(&pop_b[gid*9],d);
-
const int m = material[gid];
+ if ( m == 0 ) {
+ return;
+ }
+
+ const float d = density(&pop_b[gid*9]);
+ const float2 v = velocity(&pop_b[gid*9],d);
+
for ( int i = -1; i <= 1; ++i ) {
for ( int j = -1; j <= 1; ++j ) {
- pop_a[gidOfCell(cell.x+m*i, cell.y+m*j)*9 + indexOfDirection(m*i,m*j)] =
- pop_b[gid*9 + indexOfDirection(i,j)] + $tau * (equilibrium(d,v,i,j) - pop_b[gid*9 + indexOfDirection(i,j)]);
+ const unsigned int ngid = gidOfCell(cell.x-i, cell.y-j);
+ pop_a[gid*9 + indexOfDirection(m*i,m*j)] =
+ pop_b[ngid*9 + indexOfDirection(i,j)] + $tau * (equilibrium(d,v,i,j) - pop_b[ngid*9 + indexOfDirection(i,j)]);
}
}
}"""