Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Coulette
patapon
Commits
41c39e44
Commit
41c39e44
authored
Nov 19, 2017
by
ph
Browse files
big case
parent
9780cdf8
Changes
1
Hide whitespace changes
Inline
Side-by-side
transport_cl.py
100644 → 100755
View file @
41c39e44
#!/usr/bin/env python
#!/usr/bin/env python
3
# -*- 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
import
pyopencl
as
cl
import
numpy
as
np
...
...
@@ -60,6 +67,7 @@ def solve_python(m = _m, nx = _nx, ny = _ny, Tmax = _Tmax, dx = _dx, dy = _dy,
#init
t
=
0.
wn
=
np
.
full
((
nx
,
ny
),
wbord
,
dtype
=
'float32'
)
print
(
"start Python computations..."
)
for
i
in
range
(
1
,
nx
-
1
):
for
j
in
range
(
1
,
ny
-
1
):
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,
elapsed
=
0.
;
wn_cpu
=
np
.
empty
((
nx
*
ny
,
),
dtype
=
np
.
float32
)
print
(
"start OpenCL computations..."
)
while
t
<
Tmax
:
t
=
t
+
dt
iter
=
iter
+
1
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment