From 18c27ca60bc364d5e6cb811f56ec8c4f72867ac9 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 26 Mar 2020 21:30:05 +0100 Subject: Prototype port to 3D What is it with OpenCL @ GPU and arrays of 3-dimensional vectors?! Luckily I vaguely remembered encountering this problem before when implementing my OpenCL LBM code but why on earth is the compiler not warning about this? I guess the underlying reason has to do with the data alignment requirements on the GPU but still... --- boltzgas/initial_condition.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'boltzgas/initial_condition.py') diff --git a/boltzgas/initial_condition.py b/boltzgas/initial_condition.py index 4d66263..2526566 100644 --- a/boltzgas/initial_condition.py +++ b/boltzgas/initial_condition.py @@ -1,15 +1,20 @@ import numpy as np def grid_of_random_velocity_particles(width, radius, u_scale): - np_position = np.ndarray((width**2, 2)) - np_velocity = np.ndarray((width**2, 2)) + np_position = np.ndarray((width**3, 4)) + np_velocity = np.ndarray((width**3, 4)) grid = np.meshgrid(np.linspace(2*radius, 1-2*radius, width), + np.linspace(2*radius, 1-2*radius, width), np.linspace(2*radius, 1-2*radius, width)) np_position[:,0] = grid[0].flatten() np_position[:,1] = grid[1].flatten() + np_position[:,2] = grid[2].flatten() + np_position[:,3] = 0 - np_velocity[:,0] = u_scale*(-0.5 + np.random.random_sample((width**2,))) - np_velocity[:,1] = u_scale*(-0.5 + np.random.random_sample((width**2,))) + np_velocity[:,0] = u_scale*(-0.5 + np.random.random_sample((width**3,))) + np_velocity[:,1] = u_scale*(-0.5 + np.random.random_sample((width**3,))) + np_velocity[:,2] = u_scale*(-0.5 + np.random.random_sample((width**3,))) + np_velocity[:,3] = 0 return (np_position, np_velocity) -- cgit v1.2.3