Skip to content

Prism objects with duplicated vertices cause a segfault #1520

@ianwilliamson

Description

@ianwilliamson

Defining a Meep prism object with repeated coordinates seems to cause a segfault. It may be more user-friendly to perform some input validation here and, instead, raise an exception. Consider the example below, where the first and last vertex are the same:

import meep as mp

geometry = [
    mp.Prism(
        vertices=[
            mp.Vector3(51.07817888570662, -41.40026050039933, 0.0),
            mp.Vector3(26.07817888570662, -41.400436735950734, 0.0),
            mp.Vector3(16.07817888570662, -51.40027726778226, 0.0),
            mp.Vector3(11.875133679754981, -51.400343290466935, 0.0),
            mp.Vector3(-48.92182111429338, -51.400343290466935, 0.0),
            mp.Vector3(-48.92182111429338, 48.599656709533065, 0.0),
            mp.Vector3(51.07817888570662, 48.599656709533065, 0.0),
            mp.Vector3(51.07817888570662, -41.40026050039933, 0.0),
        ],
        height=100,
        sidewall_angle=0,
        material=mp.Medium(index=3.5),
    ),
]

simulation = mp.Simulation(
    cell_size=mp.Vector3(100.0, 100.0, 0.0),
    geometry=geometry,
    resolution=0.02,
)

simulation.init_sim()

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