diff options
-rw-r--r-- | ldc_2d.py | 6 | ||||
-rw-r--r-- | shell.nix | 15 | ||||
-rw-r--r-- | simulation.py | 15 |
3 files changed, 20 insertions, 16 deletions
@@ -42,7 +42,9 @@ generator = Generator( functions = ['collide_and_stream', 'equilibrilize', 'collect_moments', 'momenta_boundary'] extras = ['cell_list_dispatch'] -kernel_src = generator.kernel('cl', 'single', 'SOA', geometry, functions, extras) + Template(""" +precision = 'single' + +kernel_src = generator.kernel('cl', precision, 'SOA', 'ZYX', geometry, functions, extras) + Template(""" __kernel void equilibrilize(__global $float_type* f_next, __global $float_type* f_prev) { @@ -60,7 +62,7 @@ __kernel void collect_moments(__global $float_type* f, print("Initializing simulation...\n") -lattice = Lattice(geometry, kernel_src) +lattice = Lattice(geometry, kernel_src, D2Q9, precision = precision) gid = lattice.memory.gid bulk_cells = CellList(lattice.context, lattice.queue, lattice.float_type, @@ -9,18 +9,21 @@ pkgs.stdenvNoCC.mkDerivation rec { pname = "boltzgen"; version = "0.1"; - src = pkgs.fetchFromGitHub { - owner = "KnairdA"; - repo = "boltzgen"; - rev = "v0.1"; - sha256 = "072kx4jrzd0g9rn63hjb0yic7qhbga47lp2vbz7rq3gvkqv1hz4d"; - }; + #src = pkgs.fetchFromGitHub { + #owner = "KnairdA"; + #repo = "boltzgen"; + #rev = "v0.1"; + #sha256 = "072kx4jrzd0g9rn63hjb0yic7qhbga47lp2vbz7rq3gvkqv1hz4d"; + #}; + src = ~/projects/dev/boltzgen; propagatedBuildInputs = with pkgs.python37Packages; [ sympy numpy Mako ]; + + doCheck = false; }; local-python = pkgs.python3.withPackages (python-packages: with python-packages; [ diff --git a/simulation.py b/simulation.py index d2f24c9..e0ce3ba 100644 --- a/simulation.py +++ b/simulation.py @@ -4,17 +4,16 @@ mf = cl.mem_flags import numpy class Memory: - def __init__(self, grid, context, float_type): + def __init__(self, descriptor, geometry, context, float_type): self.context = context self.float_type = float_type - self.size_x = grid.size_x - self.size_y = grid.size_y - self.size_z = grid.size_z - + self.size_x = geometry.size_x + self.size_y = geometry.size_y + self.size_z = geometry.size_z self.volume = self.size_x * self.size_y * self.size_z - self.pop_size = 9 * self.volume * self.float_type(0).nbytes + self.pop_size = descriptor.q * self.volume * self.float_type(0).nbytes self.moments_size = 3 * self.volume * self.float_type(0).nbytes self.cl_pop_a = cl.Buffer(self.context, mf.READ_WRITE, size=self.pop_size) @@ -40,7 +39,7 @@ class CellList: return (len(self.np_cells), 1, 1) class Lattice: - def __init__(self, geometry, kernel_src, platform = 0, precision = 'single'): + def __init__(self, geometry, kernel_src, descriptor, platform = 0, precision = 'single'): self.geometry = geometry self.float_type = { @@ -56,7 +55,7 @@ class Lattice: self.queue = cl.CommandQueue(self.context) - self.memory = Memory(self.geometry, self.context, self.float_type[0]) + self.memory = Memory(descriptor, self.geometry, self.context, self.float_type[0]) self.tick = False self.compiler_args = { |