diff options
author | Adrian Kummerlaender | 2020-03-24 13:14:07 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2020-03-24 13:14:07 +0100 |
commit | ddce989b535ddf47cd0cee8cf4ab43966d631a4f (patch) | |
tree | 82beff502bee02c87c61267c9e6f17603a88cb13 /particles.py | |
parent | 08d4b723ca331b8f8613cc90c663102fb3c0d0a7 (diff) | |
download | boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.tar boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.tar.gz boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.tar.bz2 boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.tar.lz boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.tar.xz boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.tar.zst boltzgas-ddce989b535ddf47cd0cee8cf4ab43966d631a4f.zip |
Use modern OpenGL for displaying the plot texture
Diffstat (limited to 'particles.py')
-rw-r--r-- | particles.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/particles.py b/particles.py index 0f05786..048e52c 100644 --- a/particles.py +++ b/particles.py @@ -68,6 +68,7 @@ class GasFlow: self.cl_particle_position_b = cl.Buffer(self.context, mf.COPY_HOST_PTR, hostbuf=self.np_particle_position) self.cl_last_collide = cl.Buffer(self.context, mf.COPY_HOST_PTR, hostbuf=self.np_last_collide) + self.cl_particle_velocity_norms = cl.Buffer(self.context, mf.COPY_HOST_PTR, hostbuf=self.np_particle_velocity_norms) def __init__(self, setup, opengl = False, t_scale = 1.0): self.np_particle_position = setup.position.astype(np.float32) @@ -80,6 +81,8 @@ class GasFlow: self.np_last_collide = np.ndarray((self.n_particles, 1), dtype=np.uint32) self.np_last_collide[:,0] = self.n_particles + self.np_particle_velocity_norms = np.ndarray((self.n_particles, 1), dtype=np.float32) + self.kernel_src = build_kernel(self.t_scale*setup.radius/setup.char_u, self.n_particles, setup.radius) self.setup_cl() @@ -120,6 +123,16 @@ class GasFlow: cl.enqueue_copy(self.queue, self.np_particle_velocity, self.cl_particle_velocity_a).wait() return self.np_particle_velocity + def get_velocity_norms(self): + if self.tick: + self.program.get_velocity_norms(self.queue, (self.n_particles,), None, self.cl_particle_velocity_b, self.cl_particle_velocity_norms) + cl.enqueue_copy(self.queue, self.np_particle_velocity_norms, self.cl_particle_velocity_norms).wait() + return self.np_particle_velocity_norms + else: + self.program.get_velocity_norms(self.queue, (self.n_particles,), None, self.cl_particle_velocity_a, self.cl_particle_velocity_norms) + cl.enqueue_copy(self.queue, self.np_particle_velocity_norms, self.cl_particle_velocity_norms).wait() + return self.np_particle_velocity_norms + def get_positions(self): if self.tick: cl.enqueue_copy(self.queue, self.np_particle_position, self.cl_particle_position_b).wait() |