Skip to content

Geometry.export fails with AttributeError for a geometry without spline mappings #631

Closed

Description

@yguclu

Problem

Geometry.export can only write spline (or NURBS) mappings, because it reads their space and control_points. It is meant to reject other geometries with ValueError('No mappings were found'), but this check only tests whether the dictionary of mappings is empty:

if not( self.mappings ):
    raise ValueError('No mappings were found')

Geometry.from_topological_domain creates a dictionary with one None value per patch, so the check passes, and export fails later with an AttributeError. By then the HDF5 file has already been created, and it is left behind with partial content.

Reproducer

from sympde.topology import Square
from psydac.cad.geometry import Geometry

geo = Geometry.from_topological_domain(Square('Omega'), [3, 5])
print(geo.mappings)
geo.export('geo.h5')

Output:

{'Omega': None}
Traceback (most recent call last):
  ...
  File ".../psydac/cad/geometry.py", line 471, in export
    space = mapping.space
            ^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'space'

The file geo.h5 exists after the error.

Proposed solution

Before creating the file, check that every patch has a spline mapping, and raise a ValueError listing the patches that do not:

missing = [name for name, mapping in self.mappings.items()
           if not isinstance(mapping, SplineMapping)]
if missing:
    raise ValueError(f'Cannot export patches without a spline mapping: {missing}')

Since NurbsMapping is a subclass of SplineMapping, NURBS mappings are accepted.

Notes

Found by @campospinto in the review of #527 (see his comment)

Activity

  1. added
    CADGeometric operations on NURBS, geometry files, etc...
    on Oct 19, 2026
  2. added theissue type on Oct 19, 2026
  3. added a commit that references this issue on Oct 19, 2026
    4a592a9
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

    CADGeometric operations on NURBS, geometry files, etc...

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions