Skip to content

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

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

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