Skip to content

Commit

Permalink
fix trianglemesh custom_dataset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflex committed Jul 31, 2023
1 parent 1e305d4 commit 3667deb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
20 changes: 20 additions & 0 deletions tests/test_components/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,23 @@ def test_custom_surface_geometry():
)
_, ax = plt.subplots()
_ = sim.plot(y=0, ax=ax)


def test_geo_group_sim():

geo_grp = td.TriangleMesh.from_stl("tests/data/two_boxes_separate.stl")
geos_orig = list(geo_grp.geometries)
geo_grp_full = geo_grp.updated_copy(geometries=geos_orig + [td.Box(size=(1, 1, 1))])

sim = td.Simulation(
size=(10, 10, 10),
grid_spec=td.GridSpec.uniform(dl=0.1),
sources=[],
structures=[td.Structure(geometry=geo_grp_full, medium=td.Medium(permittivity=2))],
monitors=[],
run_time=1e-12,
boundary_spec=td.BoundarySpec.all_sides(td.PML()),
)

# why is this failing? assert 4==2
assert len(sim.custom_datasets) == len(geos_orig)
10 changes: 5 additions & 5 deletions tidy3d/components/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2759,11 +2759,11 @@ def custom_datasets(self) -> List[Dataset]:
datasets_geometry = []

for struct in self.structures:
if isinstance(struct.geometry, TriangleMesh):
datasets_geometry += struct.geometry.mesh_dataset
elif isinstance(struct.geometry, GeometryGroup):
for geometry in struct.geometry.geometries:
datasets_geometry += geometry.mesh_dataset
geo = struct.geometry
geometries = geo.geometries if isinstance(geo, GeometryGroup) else [geo]
for geometry in geometries:
if isinstance(geometry, TriangleMesh):
datasets_geometry += [geometry.mesh_dataset]

return (
datasets_source_time
Expand Down

0 comments on commit 3667deb

Please sign in to comment.