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

@@ -53,7 +53,7 @@ class LxF (Simulator.BaseSimulator):
context,
h0, hu0, hv0,
nx, ny,
dx, dy, dt,
dx, dy,
g,
cfl_scale=0.9,
boundary_conditions=BoundaryCondition(),
@@ -62,10 +62,10 @@ class LxF (Simulator.BaseSimulator):
# Call super constructor
super().__init__(context,
nx, ny,
dx, dy, dt,
dx, dy,
cfl_scale,
block_width, block_height);
self.g = np.float32(g)
self.cfl_scale = cfl_scale
self.boundary_conditions = boundary_conditions.asCodedInt()
# Get kernels
@@ -92,7 +92,10 @@ class LxF (Simulator.BaseSimulator):
1, 1,
[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.kernel.prepared_async_call(self.grid_size, self.block_size, self.stream,
@@ -116,4 +119,4 @@ class LxF (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