mirror of
https://github.com/smyalygames/FiniteVolumeGPU.git
synced 2025-09-15 03:32:17 +02:00
fix(common): change assert to raise in Array2D
This commit is contained in:
parent
d1df00267a
commit
b8836f4fb0
@ -37,3 +37,13 @@ class BaseArray2D(object):
|
||||
|
||||
if np.isfortran(cpu_data):
|
||||
raise TypeError("Wrong datatype (Fortran, expected C)")
|
||||
|
||||
def check(self, x, y, nx, ny, cpu_data):
|
||||
if nx != cpu_data.shape[1]:
|
||||
raise ValueError
|
||||
if ny != cpu_data.shape[0]:
|
||||
raise ValueError
|
||||
if x + nx > self.nx + 2 * self.x_halo:
|
||||
raise ValueError
|
||||
if y + ny > self.ny + 2 * self.y_halo:
|
||||
raise ValueError
|
||||
|
@ -58,10 +58,7 @@ class CudaArray2D(BaseArray2D):
|
||||
# Non-pagelocked: cpu_data = np.empty((ny, nx), dtype=np.float32)
|
||||
# cpu_data = self.memorypool.allocate((ny, nx), dtype=np.float32)
|
||||
|
||||
assert nx == cpu_data.shape[1]
|
||||
assert ny == cpu_data.shape[0]
|
||||
assert x + nx <= self.nx + 2 * self.x_halo
|
||||
assert y + ny <= self.ny + 2 * self.y_halo
|
||||
self.check(x, y, nx, ny, cpu_data)
|
||||
|
||||
# Create a copy object from device to host
|
||||
copy = cuda.Memcpy2D()
|
||||
@ -93,10 +90,7 @@ class CudaArray2D(BaseArray2D):
|
||||
else:
|
||||
x, y, nx, ny = extent
|
||||
|
||||
assert (nx == cpu_data.shape[1])
|
||||
assert (ny == cpu_data.shape[0])
|
||||
assert (x + nx <= self.nx + 2 * self.x_halo)
|
||||
assert (y + ny <= self.ny + 2 * self.y_halo)
|
||||
self.check(x, y, nx, ny, cpu_data)
|
||||
|
||||
# Create a copy object from device to host
|
||||
copy = cuda.Memcpy2D()
|
||||
|
Loading…
x
Reference in New Issue
Block a user