Skip to content

Commit

Permalink
fix: 🐛 fixing warning message with divide by 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Apr 12, 2022
1 parent 721270e commit ebd12ff
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,15 +430,17 @@ def add_gradient_orthogonal_constraints(self, points, vector, w=1.0, B=0):
inside = np.logical_and(~np.any(idc == -1, axis=1), inside)
# normalise vector and scale element gradient matrix by norm as well
norm = np.linalg.norm(vector, axis=1)
vector /= norm[:, None]

vector[norm > 0, :] /= norm[norm > 0, None]

# normalise element vector to unit vector for dot product
(
vertices,
T,
elements,
inside_,
) = self.support.get_element_gradient_for_location(points[inside, :3])
T /= norm[:, None, None]
T[norm > 0, :, :] /= norm[norm > 0, None, None]

# dot product of vector and element gradient = 0
A = np.einsum("ij,ijk->ik", vector[inside, :3], T)
Expand Down

0 comments on commit ebd12ff

Please sign in to comment.