Exemple #1
0
def test_failsafe_sweep():
    interpolate_expression = Expression('x[0]', degree=1)
    mesh = UnitSquareMesh(5, 5)
    V = FunctionSpace(mesh, "DG", 1)

    v = Function(V)
    v.assign(interpolate_expression)

    np_min, np_max = 1, 2
    np_failsafe = 4

    # Initialize particles
    x = RandomRectangle(Point(0.0, 0.0), Point(1., 1.)).generate([100, 100])
    s = assign_particle_values(x, interpolate_expression)
    # Broadcast to other procs
    x = comm.bcast(x, root=0)
    s = comm.bcast(s, root=0)

    property_idx = 1
    p = particles(x, [s], mesh)
    AD = AddDelete(p, np_min, np_max, [v])
    AD.do_sweep_failsafe(np_failsafe)

    # Must recover linear
    lstsq_rho = l2projection(p, V, property_idx)
    lstsq_rho.project(v.cpp_object())

    error = sqrt(
        assemble(
            (v - interpolate_expression) * (v - interpolate_expression) * dx))

    assert len(p.positions() == mesh.num_cells() * np_failsafe)
    assert error < 1e-12
Exemple #2
0
        area_0 = assemble(psi0_h * dx)
        timer = Timer()

        timer.start()
        while step < num_steps:
            step += 1
            t += float(dt)

            if comm.rank == 0:
                print("Step " + str(step))

            # Advect particle, assemble and solve pde projection
            t1 = Timer("[P] Advect particles step")
            AD.do_sweep()
            ap.do_step(float(dt))
            AD.do_sweep_failsafe(4)
            del t1

            if projection_type == "PDE":
                t1 = Timer("[P] Assemble PDE system")
                pde_projection.assemble(True, True)
                del t1
                t1 = Timer("[P] Solve projection")
                pde_projection.solve_problem(psibar_h, psi_h, "mumps",
                                             "default")
                del t1
            else:
                t1 = Timer("[P] Solve projection")
                lstsq_psi.project(psi_h)
                del t1
Exemple #3
0
while step < num_steps:
    step += 1
    t += float(dt)

    if comm.Get_rank() == 0:
        print("Step number " + str(step))

    t1 = Timer("[P] Sweep and step")
    # Limit number of particles
    AD.do_sweep()

    # Advect particles
    ap.do_step(float(dt))

    # Do failsafe sweep
    AD.do_sweep_failsafe(7)
    del t1

    # Do constrained projection
    t1 = Timer("[P] Assemble")
    pde_projection.assemble(True, True)
    del t1
    t1 = Timer("[P] Solve")
    pde_projection.solve_problem(ubar_a.cpp_object(), ustar.cpp_object(),
                                 "bicgstab", "hypre_amg")
    del t1

    # Solve Stokes
    t1 = Timer("[P] Stokes assemble")
    ssc.assemble_global_system(True)
    del t1
        t = 0.
        area_0 = assemble(psi0_h * dx)
        timer = Timer()

        timer.start()
        while step < num_steps:
            step += 1
            t += float(dt)

            if comm.rank == 0:
                print("Step  " + str(step))

            # Advect particle, assemble and solve pde projection
            t1 = Timer("[P] Advect particles step")
            ap.do_step(float(dt))
            AD.do_sweep_failsafe(4 * k)
            del (t1)

            t1 = Timer("[P] Assemble PDE system")
            pde_projection.assemble(True, True)
            # pde_projection.apply_boundary(bc)
            del (t1)

            t1 = Timer("[P] Solve PDE constrained projection")
            pde_projection.solve_problem(psibar_h, psi_h, 'mumps', 'default')
            del (t1)

            t1 = Timer("[P] Update and store")
            # Update old solution
            assign(psi0_h, psi_h)
while step < num_steps:
    step += 1
    t += float(dt)
    if comm.rank == 0:
        print("Step number " + str(step))

    # Limit number of particles
    t1 = Timer("[P] advect particles")
    AD.do_sweep()

    # Advect particles
    ap.do_step(float(dt))

    # Do failsafe sweep
    AD.do_sweep_failsafe(5)
    del t1
    # Do constrained projection
    t1 = Timer("[P] assemble projection")
    pde_projection.assemble(True, True)
    del t1
    t1 = Timer("[P] solve projection")
    pde_projection.solve_problem(ubar_a.cpp_object(), ustar.cpp_object(),
                                 lamb.cpp_object(), "mumps", "default")
    del t1

    # Solve Stokes
    t1 = Timer("[P] Stokes assemble ")
    ssc.assemble_global_system(True)
    for bc in bcs:
        ssc.apply_boundary(bc)