Ejemplo n.º 1
0
def initFBL():
    tic = time.time()

    dataShape = (args.ny, args.nx)

    eta0 = np.fromfunction(lambda i, j: my_exp(i, j),
                           dataShape,
                           dtype=np.float32)
    u0 = np.zeros((dataShape[0] + 0, dataShape[1] + 1), dtype=np.float32)
    v0 = np.zeros((dataShape[0] + 1, dataShape[1] + 0), dtype=np.float32)
    h0 = np.ones(dataShape, dtype=np.float32) * waterHeight

    toc = time.time()
    print("{:02.4f} s: ".format(toc - tic) + "Generated initial conditions")

    # Initialize simulator
    tic = time.time()

    kwargs = {'boundary_conditions': boundaryConditions}
    if (args.block_width != None):
        kwargs['block_width'] = args.block_width
    if (args.block_height != None):
        kwargs['block_height'] = args.block_height

    sim = FBL.FBL(gpu_ctx, \
        h0, eta0, u0, v0, \
        args.nx, args.ny, \
        dx, dy, dt, \
        g, f, r, \
        **kwargs)
    toc = time.time()
    print("{:02.4f} s: ".format(toc - tic) + "Created FBL simulator")

    return sim
Ejemplo n.º 2
0
    def test_wall_corner(self):
        self.setBoundaryConditions(1)
        self.createHostData()
        makeCornerBump(self.eta0, self.nx, self.ny, self.dx, self.dy, self.ghosts)
        self.sim = FBL.FBL(self.gpu_ctx, \
                           self.h0, self.eta0, self.u0, self.v0, \
                           self.nx, self.ny, \
                           self.dx, self.dy, self.dt, \
                           self.g, self.f, self.r)
        
        t = self.sim.step(self.T)
        eta1, u1, v1 = self.sim.download()
        eta2, u2, v2 = loadResults("FBL", "wallBC", "corner")

        self.checkResults(eta1, u1, v1, eta2, u2, v2)
Ejemplo n.º 3
0
    def test_wall_central(self):
        self.setBoundaryConditions(1)
        self.createHostData()
        makeCentralBump(self.eta0, self.nx, self.ny, self.dx, self.dy,
                        self.ghosts)
        self.sim = FBL.FBL(self.gpu_ctx, \
                           self.h0, self.eta0, self.u0, self.v0, \
                           self.nx, self.ny, \
                           self.dx, self.dy, self.dt, \
                           self.g, self.f, self.r)

        t = self.sim.step(self.T)
        eta1, u1, v1 = self.sim.download(interior_domain_only=True)
        eta2, u2, v2 = loadResults("FBL", "wallBC", "central")

        self.checkResults(eta1, u1, v1, eta2, u2, v2)
Ejemplo n.º 4
0
    def test_periodicEW_corner(self):
        self.setBoundaryConditions(4)
        self.createHostData()
        makeCornerBump(self.eta0, self.nx, self.ny, self.dx, self.dy, self.ghosts)
        self.sim = FBL.FBL(self.gpu_ctx, \
                           self.h0, self.eta0, self.u0, self.v0, \
                           self.nx, self.ny, \
                           self.dx, self.dy, self.dt, \
                           self.g, self.f, self.r, \
                           boundary_conditions=self.boundaryConditions)
        
        t = self.sim.step(self.T)
        eta1, u1, v1 = self.sim.download()
        eta2, u2, v2 = loadResults("FBL", "periodicEW", "corner")

        self.checkResults(eta1, u1, v1, eta2, u2, v2, self.arrayRange)
Ejemplo n.º 5
0
    def test_periodicNS_central(self):
        self.setBoundaryConditions(3)
        self.createHostData()
        makeCentralBump(self.eta0, self.nx, self.ny, self.dx, self.dy, self.ghosts)
        self.sim = FBL.FBL(self.gpu_ctx, \
                           self.h0, self.eta0, self.u0, self.v0, \
                           self.nx, self.ny, \
                           self.dx, self.dy, self.dt, \
                           self.g, self.f, self.r, \
                           boundary_conditions=self.boundaryConditions)
        
        t = self.sim.step(self.T)
        eta1, u1, v1 = self.sim.download()
        eta2, u2, v2 = loadResults("FBL", "wallBC", "central")

        self.checkResults(eta1, u1, v1, eta2, u2, v2)
Ejemplo n.º 6
0
    def test_periodicNS_upperCorner(self):
        self.setBoundaryConditions(3)
        self.createHostData()
        makeUpperCornerBump(self.eta0, self.nx, self.ny, self.dx, self.dy,
                            self.ghosts)
        self.sim = FBL.FBL(self.gpu_ctx, \
                           self.h0, self.eta0, self.u0, self.v0, \
                           self.nx, self.ny, \
                           self.dx, self.dy, self.dt, \
                           self.g, self.f, self.r, \
                           boundary_conditions=self.boundaryConditions)

        t = self.sim.step(self.T)
        eta1, u1, v1 = self.sim.download(interior_domain_only=True)
        eta2, u2, v2 = loadResults("FBL", "periodicNS", "upperCorner")

        self.checkResults(eta1, u1, v1, eta2, u2, v2)
Ejemplo n.º 7
0
    def test_coriolis_central(self):
        self.setBoundaryConditions(1)
        self.createHostData()
        self.f = 0.01
        makeCentralBump(self.eta0, self.nx, self.ny, self.dx, self.dy,
                        self.ghosts)
        self.sim = FBL.FBL(self.gpu_ctx, \
                           self.h0, self.eta0, self.u0, self.v0, \
                           self.nx, self.ny, \
                           self.dx, self.dy, self.dt, \
                           self.g, self.f, self.r)
        
        t = self.sim.step(self.T)
        eta1, u1, v1 = self.sim.download()
        eta2, u2, v2 = loadResults("FBL", "coriolis", "central")

        self.checkResults(eta1, u1, v1, eta2, u2, v2)
Ejemplo n.º 8
0
def initFBL():
    tic = time.time()

    ghosts = [1, 1, 1, 1]
    dataShape = (args.ny + 2, args.nx + 2)

    eta0 = np.zeros(dataShape, dtype=np.float32, order='C')
    initEtaFD(eta0, ghosts)

    u0 = np.zeros((dataShape[0] + 0, dataShape[1] - 1), dtype=np.float32)
    v0 = np.zeros((dataShape[0] + 1, dataShape[1] + 0), dtype=np.float32)
    h0 = np.ones(dataShape, dtype=np.float32) * waterHeight

    dt = courant_number * dx / (np.sqrt(2) * gravity_wave_speed)
    toc = time.time()
    print("{:02.4f} s: ".format(toc - tic) + "Generated initial conditions")

    # Initialize simulator
    tic = time.time()

    kwargs = {'boundary_conditions': boundaryConditions}
    if (args.block_width != None):
        kwargs['block_width'] = args.block_width
    if (args.block_height != None):
        kwargs['block_height'] = args.block_height

    sim = FBL.FBL(gpu_ctx, \
                                    h0, eta0, u0, v0, \
                                    args.nx, args.ny, \
                                    dx, dy, dt, \
                                    g, f, r, \
                                    **kwargs)
    toc = time.time()
    print("{:02.4f} s: ".format(toc - tic) + "Created FBL simulator")

    print_memory_req(sim, fbl=True)

    return sim