Removed fixed timestep size

This commit is contained in:
André R. Brodtkorb
2018-11-15 17:25:01 +01:00
parent ddac53271c
commit 815b4493b5
9 changed files with 79 additions and 50 deletions

View File

@@ -54,7 +54,7 @@ class HLL2 (Simulator.BaseSimulator):
context,
h0, hu0, hv0,
nx, ny,
dx, dy, dt,
dx, dy,
g,
theta=1.8,
cfl_scale=0.9,
@@ -64,7 +64,8 @@ class HLL2 (Simulator.BaseSimulator):
# Call super constructor
super().__init__(context,
nx, ny,
dx, dy, dt*2,
dx, dy,
cfl_scale,
block_width, block_height);
self.g = np.float32(g)
self.theta = np.float32(theta)
@@ -95,7 +96,10 @@ class HLL2 (Simulator.BaseSimulator):
2, 2,
[None, None, None])
self.cfl_data = gpuarray.GPUArray(self.grid_size, dtype=np.float32)
self.cfl_data.fill(self.dt, stream=self.stream)
dt_x = np.min(self.dx / (np.abs(hu0/h0) + np.sqrt(g*h0)))
dt_y = np.min(self.dy / (np.abs(hv0/h0) + np.sqrt(g*h0)))
dt = min(dt_x, dt_y)
self.cfl_data.fill(dt, stream=self.stream)
def step(self, dt):
self.substepDimsplit(dt*0.5, 0)
@@ -130,4 +134,4 @@ class HLL2 (Simulator.BaseSimulator):
def computeDt(self):
max_dt = gpuarray.min(self.cfl_data, stream=self.stream).get();
return max_dt*0.5*self.cfl_scale
return max_dt*0.5