Commit 41c39e44 authored by ph's avatar ph

big case

parent 9780cdf8
#!/usr/bin/env python #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# resolution of a transport equation by the finite volume method
# on regular grid
# regular python implementation compared to a pyopencl version
from __future__ import absolute_import, print_function from __future__ import absolute_import, print_function
import pyopencl as cl import pyopencl as cl
import numpy as np import numpy as np
...@@ -60,6 +67,7 @@ def solve_python(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy, ...@@ -60,6 +67,7 @@ def solve_python(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy,
#init #init
t = 0. t = 0.
wn = np.full((nx,ny), wbord, dtype = 'float32') wn = np.full((nx,ny), wbord, dtype = 'float32')
print("start Python computations...")
for i in range(1,nx-1): for i in range(1,nx-1):
for j in range(1,ny-1): for j in range(1,ny-1):
xy=[i*dx+dx/2,j*dy+dy/2] xy=[i*dx+dx/2,j*dy+dy/2]
...@@ -138,6 +146,7 @@ def solve_ocl(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy, ...@@ -138,6 +146,7 @@ def solve_ocl(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy,
elapsed = 0.; elapsed = 0.;
wn_cpu = np.empty((nx * ny, ), dtype = np.float32) wn_cpu = np.empty((nx * ny, ), dtype = np.float32)
print("start OpenCL computations...")
while t < Tmax: while t < Tmax:
t = t + dt t = t + dt
iter = iter + 1 iter = iter + 1
......
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