aboutsummaryrefslogtreecommitdiff
path: root/D2Q9.py
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-06-12 22:20:51 +0200
committerAdrian Kummerlaender2019-06-12 22:20:51 +0200
commitd4dab626ea25c088e2a5c7256e17d115d4f80478 (patch)
tree5f8628a21d5eb00b96f71ba131e51230879d8c17 /D2Q9.py
parent9cf82f641b8982df526107b99d883545ee02fe20 (diff)
downloadsymlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.tar
symlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.tar.gz
symlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.tar.bz2
symlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.tar.lz
symlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.tar.xz
symlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.tar.zst
symlbm_playground-d4dab626ea25c088e2a5c7256e17d115d4f80478.zip
Make it easier to exchange initial equilibration logic
Diffstat (limited to 'D2Q9.py')
-rw-r--r--D2Q9.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/D2Q9.py b/D2Q9.py
index 173f1b7..fbce5d6 100644
--- a/D2Q9.py
+++ b/D2Q9.py
@@ -12,7 +12,7 @@ class Lattice:
def idx(self, x, y):
return y * self.nX + x;
- def __init__(self, nX, nY, tau, geometry):
+ def __init__(self, nX, nY, tau, geometry, pop_eq_src = ''):
self.nX = nX
self.nY = nY
self.nCells = nX * nY
@@ -26,6 +26,8 @@ class Lattice:
self.np_material = numpy.ndarray(shape=(self.nCells, 1), dtype=numpy.int32)
self.setup_geometry(geometry)
+ self.pop_eq_src = pop_eq_src
+
self.cl_pop_a = cl.Buffer(self.context, mf.READ_WRITE, size=9*self.nCells*numpy.float32(0).nbytes)
self.cl_pop_b = cl.Buffer(self.context, mf.READ_WRITE, size=9*self.nCells*numpy.float32(0).nbytes)
@@ -53,7 +55,14 @@ class Lattice:
collide_assignment = D2Q9.collide_opt[1],
c = D2Q9.c,
w = D2Q9.w,
- ccode = sympy.ccode
+ ccode = sympy.ccode,
+ pop_eq_src = Template(self.pop_eq_src).render(
+ nX = self.nX,
+ nY = self.nY,
+ nCells = self.nCells,
+ c = D2Q9.c,
+ w = D2Q9.w
+ )
)
self.program = cl.Program(self.context, program_src).build()