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 for multilines #66

Merged
merged 2 commits into from
Jul 10, 2023
Merged
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
25 changes: 14 additions & 11 deletions femwell/mesh/meshtracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,24 +130,27 @@ 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.)

Args:
shapely_xy_curve (shapely.geometry.LineString): curve
shapely_xy_curves (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):
Expand Down
Loading