def all_refine(num_mesh, depth, fname):
    from meshmode.mesh.generation import (  # noqa
            generate_icosphere, generate_icosahedron,
            generate_torus, generate_regular_rect_mesh,
            generate_box_mesh)
    import timeit
    nelements = []
    runtimes = []
    for el_fact in range(2, num_mesh+2):
        mesh = generate_box_mesh(3*(np.linspace(0, 1, el_fact),))
        r = Refiner(mesh)
        for time in range(depth):
            flags = np.ones(len(mesh.groups[0].vertex_indices))
            if time < depth-1:
                mesh = r.refine(flags)
            else:
                start = timeit.default_timer()
                mesh = r.refine(flags)
                stop = timeit.default_timer()
                nelements.append(mesh.nelements)
                runtimes.append(stop-start)
        check_nodal_adj_against_geometry(mesh)
    import matplotlib.pyplot as pt
    pt.plot(nelements, runtimes, "o")
    pt.savefig(fname)
    pt.clf()
Example #2
0
def all_refine(num_mesh, depth, fname):
    from meshmode.mesh.generation import (  # noqa
        generate_icosphere, generate_icosahedron, generate_torus,
        generate_regular_rect_mesh, generate_box_mesh)
    import timeit
    nelements = []
    runtimes = []
    for el_fact in range(2, num_mesh + 2):
        mesh = generate_box_mesh(3 * (np.linspace(0, 1, el_fact), ))
        r = Refiner(mesh)
        for time in range(depth):
            flags = np.ones(len(mesh.groups[0].vertex_indices))
            if time < depth - 1:
                mesh = r.refine(flags)
            else:
                start = timeit.default_timer()
                mesh = r.refine(flags)
                stop = timeit.default_timer()
                nelements.append(mesh.nelements)
                runtimes.append(stop - start)
        check_nodal_adj_against_geometry(mesh)
    import matplotlib.pyplot as pt
    pt.plot(nelements, runtimes, "o")
    pt.savefig(fname)
    pt.clf()
Example #3
0
def test_refinement(case_name, mesh_gen, flag_gen, num_generations):
    from random import seed
    seed(13)

    mesh = mesh_gen()

    r = Refiner(mesh)

    for _ in range(num_generations):
        flags = flag_gen(mesh)
        mesh = r.refine(flags)

        check_nodal_adj_against_geometry(mesh)
Example #4
0
def test_refinement(case_name, mesh_gen, flag_gen, num_generations):
    from random import seed
    seed(13)

    mesh = mesh_gen()

    r = Refiner(mesh)

    for _ in range(num_generations):
        flags = flag_gen(mesh)
        mesh = r.refine(flags)

        check_nodal_adj_against_geometry(mesh)
def uniform_refine(num_mesh, fract, depth, fname):
    from meshmode.mesh.generation import (  # noqa
            generate_icosphere, generate_icosahedron,
            generate_torus, generate_regular_rect_mesh,
            generate_box_mesh)
    import timeit
    nelements = []
    runtimes = []
    for el_fact in range(2, num_mesh+2):
        mesh = generate_box_mesh(3*(np.linspace(0, 1, el_fact),))
        r = Refiner(mesh)
        all_els = list(range(mesh.nelements))
        for time in range(depth):
            print("EL_FACT", el_fact, "TIME", time)
            flags = np.zeros(mesh.nelements)
            from random import shuffle, seed
            seed(1)
            shuffle(all_els)
            nels_this_round = 0
            for i in range(len(all_els)):
                if i / len(flags) > fract:
                    break
                flags[all_els[i]] = 1
                nels_this_round += 1

            if time < depth-1:
                mesh = r.refine(flags)
            else:
                start = timeit.default_timer()
                mesh = r.refine(flags)
                stop = timeit.default_timer()
                nelements.append(mesh.nelements)
                runtimes.append(stop-start)
            all_els = []
            for i in range(len(flags)):
                if flags[i]:
                    all_els.append(i)
            for i in range(len(flags), mesh.nelements):
                all_els.append(i)
            check_nodal_adj_against_geometry(mesh)

    import matplotlib.pyplot as pt
    pt.plot(nelements, runtimes, "o")
    pt.savefig(fname)
    pt.clf()
Example #6
0
def uniform_refine(num_mesh, fract, depth, fname):
    from meshmode.mesh.generation import (  # noqa
            generate_icosphere, generate_icosahedron,
            generate_torus, generate_regular_rect_mesh,
            generate_box_mesh)
    import timeit
    nelements = []
    runtimes = []
    for el_fact in range(2, num_mesh+2):
        mesh = generate_box_mesh(3*(np.linspace(0, 1, el_fact),))
        r = Refiner(mesh)
        all_els = list(range(mesh.nelements))
        for time in range(depth):
            print("EL_FACT", el_fact, "TIME", time)
            flags = np.zeros(mesh.nelements)
            from random import shuffle, seed
            seed(1)
            shuffle(all_els)
            nels_this_round = 0
            for i in range(len(all_els)):
                if i / len(flags) > fract:
                    break
                flags[all_els[i]] = 1
                nels_this_round += 1

            if time < depth-1:
                mesh = r.refine(flags)
            else:
                start = timeit.default_timer()
                mesh = r.refine(flags)
                stop = timeit.default_timer()
                nelements.append(mesh.nelements)
                runtimes.append(stop-start)
            all_els = []
            for i in range(len(flags)):
                if flags[i]:
                    all_els.append(i)
            for i in range(len(flags), mesh.nelements):
                all_els.append(i)
            check_nodal_adj_against_geometry(mesh)

    import matplotlib.pyplot as pt
    pt.plot(nelements, runtimes, "o")
    pt.savefig(fname)
    pt.clf()