Skip to content

Commit

Permalink
catch points outside lattice
Browse files Browse the repository at this point in the history
  • Loading branch information
j-zimmermann committed Sep 8, 2024
1 parent f84e241 commit 770cbb8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ossdbs/fem/volume_conductor/volume_conductor_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,10 +565,11 @@ def evaluate_potential_at_points(self, lattice: np.ndarray) -> np.ndarray:
x, y, z = lattice.T
try:
pots = self.potential(mesh(x, y, z))
except netgen.libngpy._meshing.NgException:
print("There are points in the lattice outside the mesh.")
print("Choose a smaller lattice.")
raise
except netgen.libngpy._meshing.NgException as exc:
raise ValueError(
"There are points in the lattice outside the mesh. "
"Choose a smaller lattice."
) from exc
return pots

def evaluate_field_at_points(self, lattice: np.ndarray) -> np.ndarray:
Expand All @@ -588,10 +589,11 @@ def evaluate_field_at_points(self, lattice: np.ndarray) -> np.ndarray:
x, y, z = lattice.T
try:
fields = self.electric_field(mesh(x, y, z))
except netgen.libngpy._meshing.NgException:
print("There are points in the lattice outside the mesh.")
print("Choose a smaller lattice.")
raise
except netgen.libngpy._meshing.NgException as exc:
raise ValueError(
"There are points in the lattice outside the mesh. "
"Choose a smaller lattice."
) from exc
return fields

@property
Expand Down

0 comments on commit 770cbb8

Please sign in to comment.