Skip to content

Commit 1ce7380

Browse files
author
Lachlan Grose
committed
fix: bugfix for pli weighting
volume was calculated incorrectly for PLI norm was being multiplied by gradient twice
1 parent 665e4fe commit 1ce7380

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

LoopStructural/interpolators/piecewiselinear_interpolator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def add_gradient_constraints(self, w=1.0):
185185
#e, inside = self.support.elements_for_array(points[:, :3])
186186
#nodes = self.support.nodes[self.support.elements[e]]
187187
vecs = vertices[:, 1:, :] - vertices[:, 0, None, :]
188-
vol = np.abs(np.linalg.det(vecs)) # / 6
188+
vol = np.abs(np.linalg.det(vecs)) / 6
189189
norm = np.linalg.norm(points[:,3:6],axis=1)
190190
points[:,3:6]/=norm[:,None]
191191
element_gradients /= norm[:, None, None]
@@ -240,7 +240,7 @@ def add_norm_constraints(self, w=1.0):
240240
# nodes = self.support.nodes[self.support.elements[e]]
241241
vol = np.zeros(element_gradients.shape[0])
242242
vecs = vertices[:, 1:, :] - vertices[:, 0, None, :]
243-
vol = np.abs(np.linalg.det(vecs)) # / 6
243+
vol = np.abs(np.linalg.det(vecs)) / 6
244244
d_t = element_gradients
245245
d_t[inside,:,:] *= vol[inside, None, None]
246246
# add in the element gradient matrix into the inte
@@ -254,7 +254,7 @@ def add_norm_constraints(self, w=1.0):
254254
outside = ~np.any(idc == -1, axis=2)
255255
outside = outside[:, 0]
256256
w = points[:, 6]*w
257-
points[inside,3:6]*=vol[inside]
257+
# points[inside,3:6]*=vol[inside,None]
258258
# w /= 3
259259

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

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

0 commit comments

Comments
 (0)