def __init__(self,
                 context,
                 rho,
                 rho_u,
                 rho_v,
                 E,
                 nx,
                 ny,
                 dx,
                 dy,
                 g,
                 gamma,
                 theta=1.3,
                 cfl_scale=0.9,
                 boundary_conditions=BoundaryCondition(),
                 block_width=16,
                 block_height=8):

        # Call super constructor
        super().__init__(context, nx, ny, dx, dy, boundary_conditions,
                         cfl_scale, 2, block_width, block_height)
        self.g = np.float32(g)
        self.gamma = np.float32(gamma)
        self.theta = np.float32(theta)

        #Get kernels
        module = context.get_module("cuda/EE2D_KP07_dimsplit.cu",
                                    defines={
                                        'BLOCK_WIDTH': self.block_size[0],
                                        'BLOCK_HEIGHT': self.block_size[1]
                                    },
                                    compile_args={
                                        'no_extern_c': True,
                                        'options': ["--use_fast_math"],
                                    },
                                    jit_compile_args={})
        self.kernel = module.get_function("KP07DimsplitKernel")
        self.kernel.prepare("iiffffffiiPiPiPiPiPiPiPiPiP")

        #Create data by uploading to device
        self.u0 = Common.ArakawaA2D(self.stream, nx, ny, 2, 2,
                                    [rho, rho_u, rho_v, E])
        self.u1 = Common.ArakawaA2D(self.stream, nx, ny, 2, 2,
                                    [None, None, None, None])
        self.cfl_data = gpuarray.GPUArray(self.grid_size, dtype=np.float32)
        dt_x = np.min(self.dx / (np.abs(rho_u / rho) + np.sqrt(gamma * rho)))
        dt_y = np.min(self.dy / (np.abs(rho_v / rho) + np.sqrt(gamma * rho)))
        self.dt = min(dt_x, dt_y)
        self.cfl_data.fill(self.dt, stream=self.stream)
Beispiel #2
0
    def __init__(self,
                 context,
                 h0,
                 hu0,
                 hv0,
                 nx,
                 ny,
                 dx,
                 dy,
                 g,
                 cfl_scale=0.9,
                 boundary_conditions=BoundaryCondition(),
                 block_width=16,
                 block_height=16):

        # Call super constructor
        super().__init__(context, nx, ny, dx, dy, boundary_conditions,
                         cfl_scale, 2, block_width, block_height)
        self.g = np.float32(g)

        #Get kernels
        module = context.get_module("cuda/SWE2D_WAF.cu",
                                    defines={
                                        'BLOCK_WIDTH': self.block_size[0],
                                        'BLOCK_HEIGHT': self.block_size[1]
                                    },
                                    compile_args={
                                        'no_extern_c': True,
                                        'options': ["--use_fast_math"],
                                    },
                                    jit_compile_args={})
        self.kernel = module.get_function("WAFKernel")
        self.kernel.prepare("iiffffiiPiPiPiPiPiPiP")

        #Create data by uploading to device
        self.u0 = Common.ArakawaA2D(self.stream, nx, ny, 2, 2, [h0, hu0, hv0])
        self.u1 = Common.ArakawaA2D(self.stream, nx, ny, 2, 2,
                                    [None, None, None])
        self.cfl_data = gpuarray.GPUArray(self.grid_size, dtype=np.float32)
        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)