Commit 9780cdf8 authored by ph's avatar ph

add transport solver

parent c6abce65
...@@ -17,8 +17,8 @@ _m = 1 ...@@ -17,8 +17,8 @@ _m = 1
_wbord = 0. _wbord = 0.
# grid size # grid size
_nx = 512 _nx = 1024
_ny = 512 _ny = 1024
Lx = 1. Lx = 1.
Ly = 1. Ly = 1.
...@@ -110,14 +110,18 @@ def solve_ocl(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy, ...@@ -110,14 +110,18 @@ def solve_ocl(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy,
# OpenCL init # OpenCL init
ctx = cl.create_some_context() ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx, properties=cl.command_queue_properties.PROFILING_ENABLE)
mf = cl.mem_flags mf = cl.mem_flags
# compile OpenCL C program
prg = cl.Program(ctx, source).build()
# create OpenCL buffers # create OpenCL buffers
wn_gpu = cl.Buffer(ctx, mf.READ_WRITE, size=(nx * ny * np.dtype('float32').itemsize)) wn_gpu = cl.Buffer(ctx, mf.READ_WRITE, size=(nx * ny * np.dtype('float32').itemsize))
wnp1_gpu = cl.Buffer(ctx, mf.READ_WRITE, size=(nx * ny * np.dtype('float32').itemsize)) wnp1_gpu = cl.Buffer(ctx, mf.READ_WRITE, size=(nx * ny * np.dtype('float32').itemsize))
prg = cl.Program(ctx, source).build() # create a queue (for submitting opencl operations)
queue = cl.CommandQueue(ctx, properties=cl.command_queue_properties.PROFILING_ENABLE)
# init data # init data
event = prg.init_sol(queue, (nx * ny, ), (32, ), wn_gpu) event = prg.init_sol(queue, (nx * ny, ), (32, ), wn_gpu)
...@@ -125,11 +129,10 @@ def solve_ocl(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy, ...@@ -125,11 +129,10 @@ def solve_ocl(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy,
# number of animation frames # number of animation frames
nbplots = 10 nbplots = 10
itermax = int(np.floor(Tmax / dt)) itermax = int(np.floor(Tmax / dt))
iterplot = int(itermax / nbplots) iterplot = int(itermax / nbplots)
# time loop on gpu # time loop
t = 0 t = 0
iter = 0 iter = 0
elapsed = 0.; elapsed = 0.;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment