How to use the meshio.write function in meshio

To help you get started, we’ve selected a few meshio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nschloe / pygmsh / test / test_rectangle.py View on Github external
def test():
    geom = pygmsh.built_in.Geometry()

    geom.add_rectangle(0.0, 1.0, 0.0, 1.0, 0.0, 0.1)

    ref = 1.0
    mesh = pygmsh.generate_mesh(geom, mesh_file_type="vtk")
    assert abs(compute_volume(mesh) - ref) < 1.0e-2 * ref
    return mesh


if __name__ == "__main__":
    import meshio

    meshio.write("rectangle.vtu", test())
github nschloe / pygmsh / test / test_rotated_layers.py View on Github external
point_on_axis=[0.0, 0.0, 0.0],
        angle=0.5 * pi,
        num_layers=5,
        recombine=True,
    )

    ref = 3.98156496566
    mesh = pygmsh.generate_mesh(geom)
    assert abs(compute_volume(mesh) - ref) < 1.0e-2 * ref
    return mesh


if __name__ == "__main__":
    import meshio

    meshio.write("rotated_layers.vtu", test())
github nschloe / meshio / test / test_helpers.py View on Github external
def test_write_buffer(mesh, tmpdir):
    tmp_path = str(tmpdir.join("tmp.obj"))
    with open(tmp_path, "w") as f:
        meshio.write(f, mesh, "obj")
    assert Path(tmp_path).is_file()
github nschloe / meshzoo / meshzoo / simple_shell.py View on Github external
[ 0.0, -1.0, 0.0]
        ])
    elems = np.array([
        [0, 1, 2],
        [0, 2, 3],
        [0, 3, 4],
        [0, 4, 1]
        ])

    return nodes, elems


if __name__ == '__main__':
    import meshio
    points, cells = create_mesh()
    meshio.write('simple_shell.e', points, {'triangle': cells})
github nschloe / meshzoo / meshzoo / sphere.py View on Github external
# close geometry
    elems[k] = np.array([
        0 + n_phi*(n_theta-3) + 1,
        n_phi-1 + n_phi*(n_theta-3) + 1,
        north_pole_index
        ])
    k += 1
    assert k == num_elems, 'Wrong element count.'

    return nodes, elems


if __name__ == '__main__':
    import meshio
    points, cells = create_mesh()
    meshio.write('sphere.vtu', points, {'triangle': cells})
github nschloe / meshzoo / examples / meshpy / rectangle_with_hole.py View on Github external
return bool(area > max_area)

    meshpy_mesh = meshpy.triangle.build(info, refinement_func=_needs_refinement)

    # append column
    pts = np.array(meshpy_mesh.points)
    points = np.c_[pts[:, 0], pts[:, 1], np.zeros(len(pts))]

    return points, np.array(meshpy_mesh.elements)


if __name__ == "__main__":
    import meshio

    points, cells = create_mesh()
    meshio.write("rectangle_with_hole.e", points, {"triangle": cells})
github nschloe / meshzoo / meshzoo / cube.py View on Github external
nz * ( ny*i     + j+1 ) + k+1,
                nz * ( ny*i     + j   ) + k+1
            ]
            for i in range(nx - 1) for j in range(ny - 1) for k in range(nz - 1)
            if (i + j + k) % 2 != 0
            ]))

    elems = np.vstack(elems)

    return nodes, elems


if __name__ == '__main__':
    import meshio
    points, cells = create_mesh()
    meshio.write('cube.vtu', points, {'tetra': cells})
github nschloe / meshzoo / examples / meshpy / lshape.py View on Github external
return bool(area > maxarea)

    meshpy_mesh = meshpy.triangle.build(info, refinement_func=_needs_refinement)

    # append column
    pts = np.array(meshpy_mesh.points)
    points = np.c_[pts[:, 0], pts[:, 1], np.zeros(len(pts))]

    return points, np.array(meshpy_mesh.elements)


if __name__ == "__main__":
    import meshio

    points, cells = create_mesh()
    meshio.write("lshape.e", points, {"triangle": cells})
github nschloe / meshzoo / meshzoo / moebius2_tri.py View on Github external
elems.append(elem_nodes)
    else:
        # Close the geometry upside down (odd Möbius fold)
        for j in range(nw - 1):
            elem_nodes = [(nl-1)*nw + j, (nw-1) - (j+1), (nl-1)*nw + j+1]
            elems.append(elem_nodes)
            elem_nodes = [(nl-1)*nw + j, (nw-1) - j, (nw-1) - (j+1)]
            elems.append(elem_nodes)

    return np.array(nodes), np.array(elems)


if __name__ == '__main__':
    import meshio
    points, cells = create_mesh()
    meshio.write('moebius2.e', points, {'triangle': cells})
github nschloe / pygalmesh / pygalmesh / cli.py View on Github external
mesh = generate_volume_mesh_from_surface_mesh(
        args.infile,
        lloyd=args.lloyd,
        odt=args.odt,
        perturb=args.perturb,
        exude=args.exude,
        edge_size=args.edge_size,
        facet_angle=args.facet_angle,
        facet_size=args.facet_size,
        facet_distance=args.facet_distance,
        cell_radius_edge_ratio=args.cell_radius_edge_ratio,
        cell_size=args.cell_size,
        verbose=not args.quiet,
    )
    meshio.write(args.outfile, mesh)
    return