コード例 #1
0
def test_mesh2d_get_orthogonality_orthogonal_mesh2d():
    """Tests `mesh2d_get_orthogonality` with an orthogonal 2x2 Mesh2d.
    6---7---8
    |   |   |
    3---4---5
    |   |   |
    0---1---2
    """

    mk = MeshKernel()
    mk.mesh2d_set(Mesh2dFactory.create_rectilinear_mesh(2, 2))

    orthogonality = mk.mesh2d_get_orthogonality()

    assert orthogonality.values.size == 12

    exp_orthogonality = np.array(
        [
            -999.0,
            0.0,
            -999.0,
            -999.0,
            0.0,
            -999.0,
            -999.0,
            -999.0,
            0.0,
            0.0,
            -999.0,
            -999.0,
        ],
        dtype=np.double,
    )

    assert_array_equal(orthogonality.values, exp_orthogonality)
コード例 #2
0
def test_mesh2d_get_orthogonality_not_orthogonal_mesh2d():
    """Tests `mesh2d_get_orthogonality` with a non-orthogonal 3x3 Mesh2d.
    6---7---8
    |   |   |
    3---4*--5
    |   |   |
    0---1---2
    """

    mk = MeshKernel()

    node_x = np.array(
        [0.0, 1.0, 2.0, 0.0, 1.8, 2.0, 0.0, 1.0, 2.0],
        dtype=np.double,
    )
    node_y = np.array(
        [0.0, 0.0, 0.0, 1.0, 1.8, 1.0, 2.0, 2.0, 2.0],
        dtype=np.double,
    )
    edge_nodes = np.array(
        [
            0, 1, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 0, 3, 1, 4, 2, 5, 3, 6, 4, 7,
            5, 8
        ],
        dtype=np.int32,
    )

    mk.mesh2d_set(Mesh2d(node_x, node_y, edge_nodes))

    orthogonality = mk.mesh2d_get_orthogonality()

    assert orthogonality.values.size == 12

    assert orthogonality.values[0] == -999.0
    assert orthogonality.values[1] == -999.0
    assert orthogonality.values[2] > 0.0
    assert orthogonality.values[3] > 0.0
    assert orthogonality.values[4] == -999.0
    assert orthogonality.values[5] == -999.0
    assert orthogonality.values[6] == -999.0
    assert orthogonality.values[7] > 0.0
    assert orthogonality.values[8] == -999.0
    assert orthogonality.values[9] == -999.0
    assert orthogonality.values[10] > 0.0
    assert orthogonality.values[11] == -999.0