aboutsummaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-09-13 23:01:06 +0200
committerAdrian Kummerlaender2019-09-13 23:01:06 +0200
commitbf728d8a33b57b2b775b9a1c3bc8f2d84388acd6 (patch)
treed174730a064677d9f86efcd892da0d2424c7948d /template
parent337895330731bbb2e6c5eb1897c13a554fc9e6bb (diff)
downloadsymlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.tar
symlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.tar.gz
symlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.tar.bz2
symlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.tar.lz
symlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.tar.xz
symlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.tar.zst
symlbm_playground-bf728d8a33b57b2b775b9a1c3bc8f2d84388acd6.zip
Add 3d lid driven cavity OpenGL visualization
Diffstat (limited to 'template')
-rw-r--r--template/kernel.mako23
1 files changed, 15 insertions, 8 deletions
diff --git a/template/kernel.mako b/template/kernel.mako
index 89000a9..529eb30 100644
--- a/template/kernel.mako
+++ b/template/kernel.mako
@@ -142,26 +142,33 @@ __kernel void collect_gl_moments(__global __read_only ${float_type}* f,
__kernel void update_particles(__global __read_only float4* moments,
__global __read_only int* material,
__global __write_only float4* particles,
- __global __read_only float2* init_particles,
+ __global __read_only float4* init_particles,
float aging)
{
const unsigned int pid = get_global_id(0);
float4 particle = particles[pid];
+% if descriptor.d == 2:
const unsigned int gid = floor(particle.y)*${memory.size_x} + floor(particle.x);
+% elif descriptor.d == 3:
+ const unsigned int gid = floor(particle.z)*${memory.size_x*memory.size_y} + floor(particle.y)*${memory.size_x} + floor(particle.x);
+% endif
- float4 moment = moments[gid];
+ const float4 moment = moments[gid];
- if (material[gid] == 1 && particle.z < 1.0) {
+ if (material[gid] == 1 && particle.w < 1.0) {
particle.x += moment.y;
particle.y += moment.z;
- particle.z += min(particle.x, particle.y) * aging;
+% if descriptor.d == 2:
+ particle.w += min(particle.x, particle.y) * aging;
+% elif descriptor.d == 3:
+ particle.z += moment.w;
+ particle.w += min(min(particle.x, particle.y), particle.z) * aging;
+% endif
} else {
- float2 init_particle = init_particles[pid];
- particle.x = init_particle.x;
- particle.y = init_particle.y;
- particle.z = particle.z-1.0;
+ particle.xyz = init_particles[pid].xyz;
+ particle.w = particle.w-1.0;
}
particles[pid] = particle;