Пример #1
0
def test_meshpool_base_functionality(dim):

    if dim == 2:
        mesh1 = UnitSquareMesh(6, 6)
        mesh2 = UnitSquareMesh(6, 6)
        mesh3 = UnitSquareMesh(6, 6)
        mesh4 = UnitSquareMesh(7, 7)
    elif dim == 3:
        mesh1 = UnitCubeMesh(6, 6, 6)
        mesh2 = UnitCubeMesh(6, 6, 6)
        mesh3 = UnitCubeMesh(6, 6, 6)
        mesh4 = UnitCubeMesh(7, 7, 7)

    mp = argmin(norm(mesh3.coordinates() - array([0.5] * dim), axis=1))
    mesh3.coordinates()[mp, :] += 0.00001

    mesh1 = MeshPool(mesh1)
    mesh2 = MeshPool(mesh2)
    mesh3 = MeshPool(mesh3)
    mesh4 = MeshPool(mesh4)

    assert mesh1.id() == mesh2.id(), "1!=2"
    assert mesh1.id() != mesh3.id(), "1==3"
    assert mesh1.id() != mesh4.id(), "1==4"
    assert mesh3.id() != mesh4.id(), "3==4"

    # FIXME: While weak referencing meshes don't work, we can not run the following tests
    """
Пример #2
0
                          mesh.geometry().dim())

    fine_mesh.set_parent(mesh)
    mesh.set_child(fine_mesh)

    fine_mesh.parent_entity_map = {
        mesh.id(): {
            0: dict(enumerate(range(mesh.num_vertices()))),
            tdim: dict(enumerate(child2parent))
        }
    }

    return fine_mesh


# --------------------------------------------------------------------

if __name__ == '__main__':
    from dolfin import UnitSquareMesh, File, MeshFunction

    mesh = UnitSquareMesh(2, 2)

    fine_mesh = cross_grid_refine(mesh)
    assert fine_mesh.has_parent()

    mesh_f = MeshFunction('size_t', fine_mesh, 2, 0)
    for child, parent in fine_mesh.parent_entity_map[mesh.id()][2].items():
        mesh_f[child] = parent

    File('foo.pvd') << mesh_f
Пример #3
0
    }

    meshes = {}
    for name, refine in refine_ways.items():
        print '>>>>>>>>>>>>>>>>>>>%s<<<<<<<<<<<<<<<<<<<' % name
        fine_mesh = refine(mesh)
        meshes[name] = fine_mesh
        assert fine_mesh.has_parent()

        facet_f = MeshFunction('size_t', fine_mesh, 1, 0)
        facet_style_map = {0: 'very thin, black'}

        mesh_f = MeshFunction('size_t', fine_mesh, 2, 0)
        try:
            for child, parent in fine_mesh.parent_entity_map[
                    mesh.id()][2].items():
                mesh_f[child] = graph_colors[parent]
        except AttributeError:
            for child, parent in enumerate(fine_mesh.data().array(
                    'parent_cell', 2)):
                mesh_f[child] = graph_colors[parent]

        # TODO: put tikz here
        File('%s.pvd' % name) << mesh_f

        code = tikzify_2d_mesh(facet_f, facet_style_map, mesh_f,
                               cell_style_map)

        with open('%s.tex' % name, 'w') as out:
            out.write(code)