Ejemplo n.º 1
0
def test_with_cube():
    z_cnt = 8
    spacing = 0.1

    rho0 = 1000.
    visc = 0.01
    kappa = 0.000
    dt = 0.04
    g = 0.

    pos = create_pos_cube(z_cnt, spacing=spacing)
    mass_part = spacing*spacing*spacing*rho0

    maxneighs = 200
    avgneighs = 100
    h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.)

    solver = IISPHSolver()
    solver.particles.pos.value = pos
    solver.particles.rho0.value = np.ones((len(pos),1))*rho0
    solver.particles.mass.value = np.ones((len(pos),1))*mass_part
    solver.particles.info.value = np.ones((len(pos),1))*solver.consts['MAT_FLUID']
    solver.particles.visc.value = np.ones((len(pos),1))*visc
    solver.particles.kappa.value = np.ones((len(pos),1))*kappa
    solver.h = h
    solver.dt = dt
    solver.g = g
    solver.maxneighs = maxneighs
    solver.avgneighs = avgneighs
    solver.wkrn = 'WendlandC2'
    solver.setup()

    display = GL_Window()
    display.register_points_display(solver.update, solver.particles.pos, solver.particles.rho)
    display.start()
Ejemplo n.º 2
0
def test_with_dambreak():
    z_cnt = 20
    spacing = 0.1

    rho0 = 1000.
    visc = 10.
    kappa = 0.001
    dt = 0.002
    g = 9.81
    slipcoeff = 1.
    avgdvar = 0.001
    maxdvar = 0.01
    dt_min = 0.01
    auto_dt_coeff = 0.03

    pos, info = create_dam_break(z_cnt, lfact=1., wallthick=2, walldensfact=1, spacing=spacing, fill=0.4)
    mass_part = spacing*spacing*spacing*rho0

    maxneighs = 60
    avgneighs = 40
    h = pow(3.*avgneighs*mass_part/(4.*PI*rho0), 1./3.)

    solver = IISPHSolver()
    solver.particles.pos.value = pos
    solver.particles.rho0.value = np.ones((len(pos),1))*rho0
    solver.particles.mass.value = np.ones((len(pos),1))*mass_part
    solver.particles.info.value = info
    solver.particles.visc.value = np.ones((len(pos),1))*visc
    solver.particles.kappa.value = np.ones((len(pos),1))*kappa
    solver.h = h
    solver.dt = dt
    solver.g = g
    solver.slipcoeff = slipcoeff
    solver.maxneighs = maxneighs
    solver.avgneighs = avgneighs
    solver.maxdvar = maxdvar
    solver.avgdvar = avgdvar
    solver.dt_min = dt_min
    solver.auto_dt_coeff = auto_dt_coeff
    solver.wkrn = 'WendlandC2'
    solver.setup()

    def update_and_count_neighs():
        count = 10
        for i in range(count):
            solver.update()
        numcl.analyze.dump()


        neighs = solver.neighsearch.neighbors.value
        np.place(neighs, neighs == -1, [0])
        nnz = np.zeros(len(solver.neighsearch.neighbors))
        for i in range(len(nnz)):
            nnz[i] = np.count_nonzero(neighs[i])
        print 'neigh_count ', np.amax(nnz)

    display = GL_Window()
    display.register_points_display(update_and_count_neighs, solver.particles.pos, solver.particles.rho, z=-z_cnt*spacing*1.8)
    display.start()