def test_rectangle(): points, cells = meshzoo.rectangle(nx=11, ny=11, zigzag=False) assert len(points) == 121 assert _near_equal(numpy.sum(points, axis=0), [60.5, 60.5, 0.0]) assert len(cells) == 200 points, cells = meshzoo.rectangle(nx=11, ny=11, zigzag=True) assert len(points) == 121 assert _near_equal(numpy.sum(points, axis=0), [60.5, 60.5, 0.0]) assert len(cells) == 200 points, cells = meshzoo.rectangle(nx=2, ny=2, zigzag=True) assert len(points) == 4 assert _near_equal(numpy.sum(points, axis=0), [2.0, 2.0, 0.0]) assert len(cells) == 2 points, cells = meshzoo.rectangle(nx=3, ny=2, zigzag=False) assert len(points) == 6 assert _near_equal(numpy.sum(points, axis=0), [3.0, 3.0, 0.0]) assert len(cells) == 4 assert set(cells[0]) == set([0, 1, 4]) assert set(cells[2]) == set([0, 3, 4]) points, cells = meshzoo.rectangle(nx=3, ny=2, zigzag=True) assert len(points) == 6 assert _near_equal(numpy.sum(points, axis=0), [3.0, 3.0, 0.0]) assert len(cells) == 4 assert set(cells[0]) == set([0, 1, 4]) assert set(cells[2]) == set([0, 3, 4])
def test_rectangle(): points, cells = meshzoo.rectangle(nx=11, ny=11, variant="up") assert len(points) == 121 assert _near_equal(numpy.sum(points, axis=0), [60.5, 60.5]) assert len(cells) == 200 points, cells = meshzoo.rectangle(nx=11, ny=11, variant="zigzag") assert len(points) == 121 assert _near_equal(numpy.sum(points, axis=0), [60.5, 60.5]) assert len(cells) == 200 points, cells = meshzoo.rectangle(nx=2, ny=2, variant="zigzag") assert len(points) == 4 assert _near_equal(numpy.sum(points, axis=0), [2.0, 2.0]) assert len(cells) == 2 points, cells = meshzoo.rectangle(nx=3, ny=2, variant="up") assert len(points) == 6 assert _near_equal(numpy.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} points, cells = meshzoo.rectangle(nx=3, ny=2, variant="zigzag") assert len(points) == 6 assert _near_equal(numpy.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}
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_moebius3(num_twists, num_points, num_cells, ref1, ref2): points, cells = meshzoo.moebius(num_twists, 100, 10, mode="classical") assert len(points) == num_points assert len(cells) == num_cells assert _near_equal(numpy.sum(points, axis=0), ref1, tol=1.0e-10) sum_points2 = numpy.sum(points**2, axis=0) assert numpy.allclose(sum_points2, ref2, rtol=1.0e-12, atol=0.0)
def test_tetra_sphere(n=16): points, cells = meshzoo.tetra_sphere(n) # import meshio # meshio.write_points_cells("out.vtk", points, {"triangle": cells}) assert len(points) == 514 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 1024
def test_moebius2(num_twists, num_points, num_cells, ref1, ref2): points, cells = meshzoo.moebius(nl=190, nw=30, num_twists=num_twists, mode="smooth") assert len(points) == num_points assert len(cells) == num_cells assert _near_equal(numpy.sum(points, axis=0), ref1, tol=1.0e-10) sum_points2 = numpy.sum(points ** 2, axis=0) assert numpy.allclose(sum_points2, ref2, rtol=1.0e-12, atol=0.0)
def test_pseudomoebius(): points, cells = meshzoo.moebius(nl=190, nw=31, mode="pseudo") assert len(points) == 5890 assert len(cells) == 11400 assert _near_equal(numpy.sum(points, axis=0), [0, 0, 0], tol=1.0e-10) sum_points2 = numpy.sum(points**2, axis=0) ref2 = [2753575 / 9.0, 2724125 / 9.0, 58900 / 3.0] assert numpy.allclose(sum_points2, ref2, rtol=1.0e-12, atol=0.0)
def test_icosa_sphere(n=16): points, cells = meshzoo.icosa_sphere(n) # import meshio # meshio.write_points_cells("out.vtk", points, {"triangle": cells}) assert len(points) == 2562 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 5120 assert (_compute_cells_normals_dir(points, cells) > 0.0).all()
def test_octa_sphere(n=16): points, cells = meshzoo.octa_sphere(n) assert len(points) == 1026 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 2048 assert (_compute_cells_normals_dir(points, cells) > 0.0).all() assert numpy.all( numpy.abs(numpy.einsum("ij,ij->i", points, points) - 1.0) < 1.0e-10)
def test_uv_sphere(num_points_per_circle=20, num_circles=10): points, cells = meshzoo.uv_sphere(num_points_per_circle, num_circles) assert len(points) == 162 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 320 assert (_compute_cells_normals_dir(points, cells) > 0.0).all() assert numpy.all( numpy.abs(numpy.einsum("ij,ij->i", points, points) - 1.0) < 1.0e-10)
def test_tetra_sphere(n=16): points, cells = meshzoo.tetra_sphere(n) # import meshio # meshio.write_points_cells("out.vtk", points, {"triangle": cells}) assert len(points) == 514 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 1024 assert (_compute_cells_normals_dir(points, cells) > 0.0).all() assert numpy.all( numpy.abs(numpy.einsum("ij,ij->i", points, points) - 1.0) < 1.0e-10)
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_geo_sphere(num_points_per_circle=20, num_circles=10): points, tri, quad = meshzoo.geo_sphere(num_points_per_circle, num_circles) # import meshio # meshio.write_points_cells("geo-sphere.vtk", points, {"triangle": tri, "quad": quad}) assert len(points) == 162 assert _near_equal(np.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(tri) == 40 assert len(quad) == 140 # assert (_compute_cells_normals_dir(points, cells) > 0.0).all() assert np.all( np.abs(np.einsum("ij,ij->i", points, points) - 1.0) < 1.0e-10)
def test_uv_sphere(): points, cells = meshzoo.uv_sphere() assert len(points) == 162 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 320
def test_octa_sphere(n=16): points, cells = meshzoo.octa_sphere(n) assert len(points) == 1026 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 2048 assert (_compute_cells_normals_dir(points, cells) > 0.0).all()
def test_tube(): points, cells = meshzoo.tube(n=10) assert len(points) == 20 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 20
def test_simple_shell(): points, cells = meshzoo.simple_shell() assert len(points) == 5 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 1.0]) assert len(cells) == 4
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
def test_triangle(): points, cells = meshzoo.triangle(4) assert len(points) == 15 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 16
def test_hexagon(): points, cells = meshzoo.hexagon(2) assert len(points) == 61 assert _near_equal(numpy.sum(points, axis=0), [0.0, 0.0, 0.0]) assert len(cells) == 96