Skip to content

Commit

Permalink
fix: bugfix for pli weighting
Browse files Browse the repository at this point in the history
volume was calculated incorrectly for PLI
norm was being multiplied by gradient twice
  • Loading branch information
Lachlan Grose committed Nov 3, 2021
1 parent 665e4fe commit 1ce7380
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions LoopStructural/interpolators/piecewiselinear_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def add_gradient_constraints(self, w=1.0):
#e, inside = self.support.elements_for_array(points[:, :3])
#nodes = self.support.nodes[self.support.elements[e]]
vecs = vertices[:, 1:, :] - vertices[:, 0, None, :]
vol = np.abs(np.linalg.det(vecs)) # / 6
vol = np.abs(np.linalg.det(vecs)) / 6
norm = np.linalg.norm(points[:,3:6],axis=1)
points[:,3:6]/=norm[:,None]
element_gradients /= norm[:, None, None]
Expand Down Expand Up @@ -240,7 +240,7 @@ def add_norm_constraints(self, w=1.0):
# nodes = self.support.nodes[self.support.elements[e]]
vol = np.zeros(element_gradients.shape[0])
vecs = vertices[:, 1:, :] - vertices[:, 0, None, :]
vol = np.abs(np.linalg.det(vecs)) # / 6
vol = np.abs(np.linalg.det(vecs)) / 6
d_t = element_gradients
d_t[inside,:,:] *= vol[inside, None, None]
# add in the element gradient matrix into the inte
Expand All @@ -254,7 +254,7 @@ def add_norm_constraints(self, w=1.0):
outside = ~np.any(idc == -1, axis=2)
outside = outside[:, 0]
w = points[:, 6]*w
points[inside,3:6]*=vol[inside]
# points[inside,3:6]*=vol[inside,None]
# w /= 3

self.add_constraints_to_least_squares(d_t[outside, :, :] * w[:,None,None],
Expand Down Expand Up @@ -365,7 +365,7 @@ def add_gradient_orthogonal_constraints(self, points, vector, w=1.0,
norm = np.linalg.norm(vector,axis=1)
vector /= norm[:,None]
vecs = vertices[:, 1:, :] - vertices[:, 0, None, :]
vol = np.abs(np.linalg.det(vecs)) # / 6
vol = np.abs(np.linalg.det(vecs)) / 6
element_gradients /= norm[:,None,None]

A = np.einsum('ij,ijk->ik', vector, element_gradients)
Expand Down

0 comments on commit 1ce7380

Please sign in to comment.