Skip to content

Add len() support to Meshes #3548

@MicahGale

Description

@MicahGale

Description

Sometimes it is helpful to know how many elements are in a Mesh. Right now there is no easy way to do this.

I proposed implementing __len__ for all Mesh classes (e.g., SphericalMesh). This is the function called by len().

Alternatives

The current workaround that I have seen is:

mesh = openmc.SphericalMesh(...)
mesh_size = len(list(mesh.indices))

Compatibility

This would not change any existing behavior. There is the question of if this should return the number of elements, or the number of "edges".

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