Example #1
0
    def test_get_edge_midpoint_coordinates_triangle_id(self):
        """test_get_vertex_coordinates_triangle_id
        Test that vertices for one triangle can be returned.
        """
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)

        assert num.allclose(domain.get_nodes(), nodes)

        M = domain.number_of_triangles

        for i in range(M):
            E = domain.get_edge_midpoint_coordinates(triangle_id=i)
            assert E.shape[0] == 3

            k0 = triangles[i, 0]  #Index of vertex 0 in triangle i
            k1 = triangles[i, 1]  #Index of vertex 0 in triangle i
            k2 = triangles[i, 2]  #Index of vertex 0 in triangle i

            assert num.allclose(E[0, :], 0.5 * (nodes[k1] + nodes[k2]))
            assert num.allclose(E[1, :], 0.5 * (nodes[k0] + nodes[k2]))
            assert num.allclose(E[2, :], 0.5 * (nodes[k1] + nodes[k0]))

            E0 = domain.get_edge_midpoint_coordinate(i, 0)
            E1 = domain.get_edge_midpoint_coordinate(i, 1)
            E2 = domain.get_edge_midpoint_coordinate(i, 2)

            assert num.allclose(E0, 0.5 * (nodes[k1] + nodes[k2]))
            assert num.allclose(E1, 0.5 * (nodes[k0] + nodes[k2]))
            assert num.allclose(E2, 0.5 * (nodes[k1] + nodes[k0]))
Example #2
0
    def test_get_vertex_coordinates(self):
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)

        assert num.allclose(domain.get_nodes(), nodes)

        M = domain.number_of_triangles

        V = domain.get_vertex_coordinates()
        assert V.shape[0] == 3 * M

        for i in range(M):
            for j in range(3):
                k = triangles[i, j]  #Index of vertex j in triangle i
                assert num.allclose(V[3 * i + j, :], nodes[k])
    def test_get_vertex_coordinates(self):
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)


        assert num.allclose(domain.get_nodes(), nodes)


        M = domain.number_of_triangles        

        V = domain.get_vertex_coordinates()
        assert V.shape[0] == 3*M

        for i in range(M):
            for j in range(3):
                k = triangles[i,j]  #Index of vertex j in triangle i
                assert num.allclose(V[3*i+j,:], nodes[k])
Example #4
0
    def test_get_vertex_coordinates_triangle_id(self):
        """test_get_vertex_coordinates_triangle_id
        Test that vertices for one triangle can be returned.
        """
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)

        assert num.allclose(domain.get_nodes(), nodes)

        M = domain.number_of_triangles

        for i in range(M):
            V = domain.get_vertex_coordinates(triangle_id=i)
            assert V.shape[0] == 3

            for j in range(3):
                k = triangles[i, j]  #Index of vertex j in triangle i
                assert num.allclose(V[j, :], nodes[k])
Example #5
0
    def test_get_edge_midpoint_coordinates(self):
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)

        assert num.allclose(domain.get_nodes(), nodes)

        M = domain.number_of_triangles

        E = domain.get_edge_midpoint_coordinates()
        assert E.shape[0] == 3 * M

        for i in range(M):
            k0 = triangles[i, 0]  #Index of vertex 0 in triangle i
            k1 = triangles[i, 1]  #Index of vertex 1 in triangle i
            k2 = triangles[i, 2]  #Index of vertex 2 in triangle i

            assert num.allclose(E[3 * i + 0, :], 0.5 * (nodes[k1] + nodes[k2]))
            assert num.allclose(E[3 * i + 1, :], 0.5 * (nodes[k0] + nodes[k2]))
            assert num.allclose(E[3 * i + 2, :], 0.5 * (nodes[k1] + nodes[k0]))
    def test_get_vertex_coordinates_triangle_id(self):
        """test_get_vertex_coordinates_triangle_id
        Test that vertices for one triangle can be returned.
        """
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)


        assert num.allclose(domain.get_nodes(), nodes)


        M = domain.number_of_triangles        

        for i in range(M):
            V = domain.get_vertex_coordinates(triangle_id=i)
            assert V.shape[0] == 3

            for j in range(3):
                k = triangles[i,j]  #Index of vertex j in triangle i
                assert num.allclose(V[j,:], nodes[k])
    def test_get_edge_midpoint_coordinates_triangle_id(self):
        """test_get_vertex_coordinates_triangle_id
        Test that vertices for one triangle can be returned.
        """
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)


        assert num.allclose(domain.get_nodes(), nodes)


        M = domain.number_of_triangles        

        for i in range(M):
            E = domain.get_edge_midpoint_coordinates(triangle_id=i)
            assert E.shape[0] == 3


            k0 = triangles[i,0]  #Index of vertex 0 in triangle i
            k1 = triangles[i,1]  #Index of vertex 0 in triangle i
            k2 = triangles[i,2]  #Index of vertex 0 in triangle i

            assert num.allclose(E[0,:], 0.5*(nodes[k1]+nodes[k2]))
            assert num.allclose(E[1,:], 0.5*(nodes[k0]+nodes[k2]))
            assert num.allclose(E[2,:], 0.5*(nodes[k1]+nodes[k0]))

            E0 = domain.get_edge_midpoint_coordinate(i, 0 )
            E1 = domain.get_edge_midpoint_coordinate(i, 1 )
            E2 = domain.get_edge_midpoint_coordinate(i, 2 )

            assert num.allclose(E0, 0.5*(nodes[k1]+nodes[k2]))
            assert num.allclose(E1, 0.5*(nodes[k0]+nodes[k2]))
            assert num.allclose(E2, 0.5*(nodes[k1]+nodes[k0]))
    def test_get_edge_midpoint_coordinates(self):
        from anuga.abstract_2d_finite_volumes.mesh_factory import rectangular

        #Create basic mesh
        nodes, triangles, _ = rectangular(1, 3)
        domain = General_mesh(nodes, triangles)


        assert num.allclose(domain.get_nodes(), nodes)


        M = domain.number_of_triangles        

        E = domain.get_edge_midpoint_coordinates()
        assert E.shape[0] == 3*M

        for i in range(M):
            k0 = triangles[i,0]  #Index of vertex 0 in triangle i
            k1 = triangles[i,1]  #Index of vertex 1 in triangle i
            k2 = triangles[i,2]  #Index of vertex 2 in triangle i

            assert num.allclose(E[3*i+0,:], 0.5*(nodes[k1]+nodes[k2]) )
            assert num.allclose(E[3*i+1,:], 0.5*(nodes[k0]+nodes[k2]) )
            assert num.allclose(E[3*i+2,:], 0.5*(nodes[k1]+nodes[k0]) )