From 14b1b445ac385b5dd3d44ad401475bbe70eab7c1 Mon Sep 17 00:00:00 2001 From: Helge Gehring <42973196+HelgeGehring@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:22:22 +0200 Subject: [PATCH 1/2] fix for multilines --- femwell/mesh/meshtracker.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/femwell/mesh/meshtracker.py b/femwell/mesh/meshtracker.py index a3bb2f6a..af86637c 100644 --- a/femwell/mesh/meshtracker.py +++ b/femwell/mesh/meshtracker.py @@ -130,7 +130,7 @@ def add_get_xy_segment(self, shapely_xy_point1, shapely_xy_point2, label): self.xy_segments_secondary_labels.append(None) return gmsh_segment, orientation - def add_get_xy_line(self, shapely_xy_curve, label): + def add_get_xy_line(self, shapely_xy_curves, label): """ Add a shapely line (multi-point line) to the gmsh model in the xy plane, or retrieve the existing gmsh segment with equivalent coordinates (within tol.) @@ -138,16 +138,19 @@ def add_get_xy_line(self, shapely_xy_curve, label): shapely_xy_curve (shapely.geometry.LineString): curve """ segments = [] - for shapely_xy_point1, shapely_xy_point2 in zip( - shapely_xy_curve.coords[:-1], shapely_xy_curve.coords[1:] + for shapely_xy_curve in ( + shapely_xy_curves.geoms if hasattr(shapely_xy_curves, "geoms") else [shapely_xy_curves] ): - gmsh_segment, orientation = self.add_get_xy_segment( - Point(shapely_xy_point1), Point(shapely_xy_point2), label - ) - if orientation: - segments.append(gmsh_segment) - else: - segments.append(-gmsh_segment) + for shapely_xy_point1, shapely_xy_point2 in zip( + shapely_xy_curve.coords[:-1], shapely_xy_curve.coords[1:] + ): + gmsh_segment, orientation = self.add_get_xy_segment( + Point(shapely_xy_point1), Point(shapely_xy_point2), label + ) + if orientation: + segments.append(gmsh_segment) + else: + segments.append(-gmsh_segment) self.model.add_physical(segments, f"{label}") def add_xy_surface(self, shapely_xy_polygons, label=None, physical=True): From 43717e539622dad399c21326e9435ecf9ab1a777 Mon Sep 17 00:00:00 2001 From: Helge Gehring <42973196+HelgeGehring@users.noreply.github.com> Date: Mon, 10 Jul 2023 16:24:27 +0200 Subject: [PATCH 2/2] fix docs --- femwell/mesh/meshtracker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/femwell/mesh/meshtracker.py b/femwell/mesh/meshtracker.py index af86637c..ade50ec8 100644 --- a/femwell/mesh/meshtracker.py +++ b/femwell/mesh/meshtracker.py @@ -135,7 +135,7 @@ def add_get_xy_line(self, shapely_xy_curves, label): Add a shapely line (multi-point line) to the gmsh model in the xy plane, or retrieve the existing gmsh segment with equivalent coordinates (within tol.) Args: - shapely_xy_curve (shapely.geometry.LineString): curve + shapely_xy_curves (shapely.geometry.LineString): curve """ segments = [] for shapely_xy_curve in (