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

Debug messages #62

Merged
merged 4 commits into from
Feb 27, 2024
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
32 changes: 30 additions & 2 deletions meshwell/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def add_surface(self, vertices: List[Tuple[float, float, float]]) -> int:
ID of the added surface
"""
channel_loop = self._channel_loop_from_vertices(vertices)
return self.occ.add_plane_surface([channel_loop])
try:
return self.occ.add_plane_surface([channel_loop])
except Exception as e:
print("Failed vertices:")
print(vertices)
raise e

def sync_model(self):
"""Synchronize the CAD model, and update points and lines vertex mapping."""
Expand Down Expand Up @@ -229,15 +234,25 @@ def mesh(
resolution = entity_obj.resolution
if progress_bars:
if physical_name:
enumerator.set_description(f"{physical_name:<30}")
enumerator.set_description(
f"{physical_name:<30} - {'instanciate':<15}"
)
# First create the shape
dimtags_out = entity_obj.instanciate()

if progress_bars:
if physical_name:
enumerator.set_description(f"{physical_name:<30} - {'dimtags':<15}")
# Parse dimension
dim = validate_dimtags(dimtags_out)
max_dim = max(dim, max_dim)
dimtags = unpack_dimtags(dimtags_out)

if progress_bars:
if physical_name:
enumerator.set_description(
f"{physical_name:<30} - {'entities':<15}"
)
# Assemble with other shapes
current_entities = LabeledEntities(
index=index,
Expand All @@ -247,6 +262,9 @@ def mesh(
model=self.model,
resolution=resolution,
)
if progress_bars:
if physical_name:
enumerator.set_description(f"{physical_name:<30} - {'boolean':<15}")
if index != 0:
cut = self.occ.cut(
current_entities.dimtags,
Expand All @@ -259,7 +277,17 @@ def mesh(
removeTool=False, # Tool (previous entities) should remain untouched
)
# Heal interfaces now that there are no volume conflicts
if progress_bars:
if physical_name:
enumerator.set_description(
f"{physical_name:<30} - {'duplicates':<15}"
)
self.occ.removeAllDuplicates()
if progress_bars:
if physical_name:
enumerator.set_description(
f"{physical_name:<30} - {'sync':<15}"
)
self.sync_model()
current_entities.dimtags = list(set(cut[0]))
if current_entities.dimtags:
Expand Down
4 changes: 3 additions & 1 deletion meshwell/prism.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ def __init__(

# Validate the input
if not self._validate_polygon_buffers():
raise ValueError("The buffer has modified the polygon vertices!")
raise ValueError(
f"The buffer has modified the polygon vertices! Bad physical: {physical_name}"
)

# Mesh order and name
self.mesh_order = mesh_order
Expand Down
Loading