Skip to content

Commit

Permalink
fix: removed divide by 0 error
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Feb 7, 2022
1 parent 69dbc6d commit 9f17489
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions LoopStructural/interpolators/piecewiselinear_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,11 @@ def add_gradient_orthogonal_constraints(self, points, vector, w=1.0, B=0):
# e, inside = self.support.elements_for_array(points[:, :3])
# nodes = self.support.nodes[self.support.elements[e]]
norm = np.linalg.norm(vector, axis=1)
vector /= norm[:, None]
mask = ~np.isnan(norm)
vector /= norm[mask, None]
vecs = vertices[:, 1:, :] - vertices[:, 0, None, :]
vol = np.abs(np.linalg.det(vecs)) / 6
element_gradients /= norm[:, None, None]
element_gradients /= norm[mask, None, None]

A = np.einsum("ij,ijk->ik", vector, element_gradients)

Expand Down

0 comments on commit 9f17489

Please sign in to comment.