Skip to content

Commit

Permalink
Merge pull request #62 from HelgeGehring/debug-messages
Browse files Browse the repository at this point in the history
Debug messages
  • Loading branch information
simbilod authored Feb 27, 2024
2 parents 7aa3494 + eb04899 commit 10b886c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
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

0 comments on commit 10b886c

Please sign in to comment.