aboutsummaryrefslogtreecommitdiff
path: root/implosion.py
diff options
context:
space:
mode:
Diffstat (limited to 'implosion.py')
-rw-r--r--implosion.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/implosion.py b/implosion.py
index 245f2bb..b95dffd 100644
--- a/implosion.py
+++ b/implosion.py
@@ -25,11 +25,12 @@ def generate_moment_plots(lattice, moments):
plt.imshow(velocity, origin='lower', cmap=plt.get_cmap('seismic'))
plt.savefig("result/implosion_%02d.png" % i, bbox_inches='tight', pad_inches=0)
-def box(geometry, x, y):
- if x == 1 or y == 1 or x == geometry.size_x-2 or y == geometry.size_y-2:
- return 2
- else:
- return 1
+def get_box_material_map(geometry):
+ return [
+ (lambda x, y: x > 0 and x < geometry.size_x-1 and y > 0 and y < geometry.size_y-1, 1), # bulk fluid
+ (lambda x, y: x == 1 or y == 1 or x == geometry.size_x-2 or y == geometry.size_y-2, 2), # walls
+ (lambda x, y: x == 0 or x == geometry.size_x-1 or y == 0 or y == geometry.size_y-1, 0) # ghost cells
+ ]
pop_eq = """
if ( sqrt(pow(get_global_id(0) - ${geometry.size_x//2}.f, 2.f)
@@ -73,7 +74,9 @@ lattice = Lattice(
pop_eq_src = pop_eq,
boundary_src = boundary)
-lattice.setup_geometry(box)
+lattice.apply_material_map(
+ get_box_material_map(lattice.geometry))
+lattice.sync_material()
print("Starting simulation using %d cells...\n" % lattice.geometry.volume)