Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix trianglemesh custom_dataset bug #1041

Merged
merged 1 commit into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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