aboutsummaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-09-13 23:01:06 +0200
committerAdrian Kummerlaender2019-09-13 23:01:06 +0200
commitbf728d8a33b57b2b775b9a1c3bc8f2d84388acd6 (patch)
treed174730a064677d9f86efcd892da0d2424c7948d /utility
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 'utility')
-rw-r--r--utility/particles.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/utility/particles.py b/utility/particles.py
index 43f32a3..a75ed34 100644
--- a/utility/particles.py
+++ b/utility/particles.py
@@ -12,16 +12,22 @@ class Particles:
self.count = len(grid)
self.np_particles = numpy.ndarray(shape=(self.count, 4), dtype=float_type)
-
- self.np_particles[:,0:2] = grid
- self.np_particles[:,2:4] = self.np_particles[:,0:2]
-
- self.np_init_particles = numpy.ndarray(shape=(self.count, 2), dtype=float_type)
- self.np_init_particles[:,0:2] = grid
- self.cl_init_particles = cl.Buffer(context, mf.READ_ONLY, size=self.count * 2*numpy.float32(0).nbytes)
- cl.enqueue_copy(queue, self.cl_init_particles, self.np_init_particles).wait();
+ self.np_init_particles = numpy.ndarray(shape=(self.count, 4), dtype=float_type)
+
+ if len(grid[0,:]) == 2:
+ self.np_particles[:,0:2] = grid
+ self.np_particles[:,2:4] = 0
+ self.np_init_particles[:,0:2] = grid
+ self.np_init_particles[:,2:4] = 0
+ elif len(grid[0,:]) == 3:
+ self.np_particles[:,0:3] = grid
+ self.np_particles[:,3] = 0
+ self.np_init_particles[:,0:3] = grid
+ self.np_init_particles[:,3] = 0
self.gl_particles = vbo.VBO(data=self.np_particles, usage=gl.GL_DYNAMIC_DRAW, target=gl.GL_ARRAY_BUFFER)
self.gl_particles.bind()
self.cl_gl_particles = cl.GLBuffer(self.context, mf.READ_WRITE, int(self.gl_particles))
+ self.cl_init_particles = cl.Buffer(context, mf.READ_ONLY, size=self.count * 4*numpy.float32(0).nbytes)
+ cl.enqueue_copy(queue, self.cl_init_particles, self.np_init_particles).wait();