Skip to content

mesh.write() crashes for a mesh loaded directly from a .msh file (CoordinateSystemType is None) #397

Closed

Description

@lmoresi

Found while building the #269 reproducer matrix (2026-07-23).

uw.discretisation.Mesh("file.msh") — loading a gmsh file directly, without passing coordinate_system_type= — leaves mesh.CoordinateSystemType = None. Any subsequent mesh.write() / mesh.write_timestep() then crashes writing the metadata block in Mesh.write:

coordinates_type_dict = {
    "name": self.CoordinateSystemType.name,   # AttributeError: 'NoneType' object has no attribute 'name'
    "value": self.CoordinateSystemType.value,
}

Reproducer:

import underworld3 as uw
tmp = uw.meshing.UnstructuredSimplexBox(minCoords=(0,0), maxCoords=(1,1), cellSize=0.2, filename="/tmp/box.msh")
del tmp
mesh = uw.discretisation.Mesh("/tmp/box.msh")
mesh.write("/tmp/box.h5")   # AttributeError

Workaround: load via _from_gmsh + Mesh(plex, coordinate_system_type=uw.coordinates.CoordinateSystemType.CARTESIAN, ...) (the Spiegelman-benchmark pattern), which sets the type explicitly.

Suggested fix: either default the coordinate system to CARTESIAN when loading a plain gmsh file (matching what the uw.meshing.* constructors do), or make Mesh.write tolerate/refuse-legibly a missing coordinate system rather than tracebacking in the metadata writer.

Underworld development team with AI support from Claude Code

Activity

  1. lmoresi commented on Jul 23, 2026

    @lmoresi
    MemberAuthor

    Fixed by PR #401 (coordinate system defaults to CARTESIAN when none is given, with a rank-0 warning when an h5 checkpoint is missing its metadata), merged to development on 2026-07-23 after a public adversarial review round. (Manual close — PRs target development, so auto-close does not fire.)

    Underworld development team with AI support from Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions