gustaf.io.meshio.export#

gustaf.io.meshio.export(fname, mesh, submeshes=None, **kwargs)[source]#

Export mesh elements and vertex data into meshio and use its write function. The definition of submeshes with identical vertex coordinates is possible. In that case vertex numbering and data from the main mesh are used. For more export options, refer to meshio’s documentation nschloe/meshio .

import gustaf

# define coordinates
v = np.array(
    [
        [0.0, 0.0, 0.0],
        [1.0, 0.0, 0.0],
        [0.0, 1.0, 0.0],
        [1.0, 1.0, 0.0],
        [0.0, 0.0, 1.0],
        [1.0, 0.0, 1.0],
        [0.0, 1.0, 1.0],
        [1.0, 1.0, 1.0],
    ]
)
# define triangle connectivity
tf = np.array(
    [
        [1, 0, 2],
        [0, 1, 5],
        [3, 2, 6],
        [2, 0, 4],
        [4, 5, 7],
        [2, 3, 1],
        [7, 5, 1],
        [6, 7, 3],
        [4, 6, 2],
        [7, 6, 4],
    ]
)
# init tri faces
mesh = gus.Faces(
    vertices=v,
    faces=tf,
)
gustaf.io.meshio.export(mesh, "tri-mesh.stl")
Parameters:
  • fname (Union[str, pathlib.Path]) – File to save the mesh in.

  • mesh (Edges, Faces or Volumes) – Input mesh

  • submeshes (Iterable) – Submeshes where the vertices are identical to the main mesh. The element type can be identical to mesh.elements or lower-dimensional (e.g. boundary elements).

  • **kwargs (Any) – Any additional argument will be passed to the respective meshio write function. See meshio docs for more information

Raises:
  • NotImplementedError: – For mesh types that are not implemented.

  • ValueError: – Raises a value error, if the vertices indexed in a subset are not present in the main mesh.