From 1ce7380d4ba000bad004bbcbb308b8889b18fe31 Mon Sep 17 00:00:00 2001 From: Lachlan Grose Date: Thu, 4 Nov 2021 10:35:09 +1100 Subject: [PATCH] fix: bugfix for pli weighting volume was calculated incorrectly for PLI norm was being multiplied by gradient twice --- .../interpolators/piecewiselinear_interpolator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/LoopStructural/interpolators/piecewiselinear_interpolator.py b/LoopStructural/interpolators/piecewiselinear_interpolator.py index 6865653fb..18714424e 100644 --- a/LoopStructural/interpolators/piecewiselinear_interpolator.py +++ b/LoopStructural/interpolators/piecewiselinear_interpolator.py @@ -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] @@ -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 @@ -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], @@ -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)