def test_quad(): points, cells = meshzoo.rectangle_quad((0, 0), (1, 1), 11) assert len(points) == 121 assert _near_equal(np.sum(points, axis=0), [60.5, 60.5]) assert len(cells) == 100 assert np.all(_get_signed_areas(points.T, cells) > 0.0) # meshzoo.save2d("rectangle-quad.svg", points, cells) points, cells = meshzoo.rectangle_quad((0, 0), (1, 1), (3, 2)) assert len(points) == 6 assert _near_equal(np.sum(points, axis=0), [3.0, 3.0]) assert len(cells) == 2 assert set(cells[0]) == {0, 1, 3, 4} assert set(cells[1]) == {1, 2, 4, 5} assert np.all(_get_signed_areas(points.T, cells) > 0.0)
def test_up(): points, cells = meshzoo.rectangle_tri((0, 0), (1, 1), 11, variant="up") assert len(points) == 121 assert _near_equal(np.sum(points, axis=0), [60.5, 60.5]) assert len(cells) == 200 assert np.all(_get_signed_areas(points.T, cells) > 0.0) points, cells = meshzoo.rectangle_tri((0, 0), (1, 1), (3, 2), variant="up") assert len(points) == 6 assert _near_equal(np.sum(points, axis=0), [3.0, 3.0]) assert len(cells) == 4 assert set(cells[0]) == {0, 1, 4} assert set(cells[2]) == {0, 3, 4} assert np.all(_get_signed_areas(points.T, cells) > 0.0)
def test_triangle(): bary, cells = meshzoo.triangle(4) assert len(bary.T) == 15 assert _near_equal(numpy.sum(_get_points(bary), axis=0), [0.0, 0.0]) assert len(cells) == 16 # make sure the order of the nodes in each cell is counterclockwise corner_coords = numpy.array([[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]) coords = numpy.dot(corner_coords, bary) assert numpy.all(_get_signed_areas(coords, cells) > 0.0)
def test_ngon(): points, cells = meshzoo.ngon(9, 8) assert len(points) == 325 assert len(cells) == 576 # meshzoo.save2d("9gon.svg", points, cells) assert np.all(_get_signed_areas(points.T, cells) > 0.0)
def test_disk(): points, cells = meshzoo.disk(9, 8) assert len(points) == 325 assert len(cells) == 576 # meshzoo.save2d("4gon_disk.svg", points, cells) assert (_get_signed_areas(points.T, cells) > 0.0).all()
def test_center(): points, cells = meshzoo.rectangle_tri((0, 0), (1, 1), (11, 9), variant="center") meshzoo.show2d(points, cells) assert len(points) == 99 assert len(cells) == 160 assert np.all(_get_signed_areas(points.T, cells) > 0.0)
def test_down(): points, cells = meshzoo.rectangle_tri((0, 0), (1, 1), (5, 4), variant="down") assert len(points) == 20 assert len(cells) == 24 assert np.all(_get_signed_areas(points.T, cells) > 0.0)