Skip to content

Commit

Permalink
fix: 🐛 weight for p2 interpolator wasn't being applied
Browse files Browse the repository at this point in the history
  • Loading branch information
Lachlan Grose committed Mar 2, 2022
1 parent 1ee5dd6 commit 5002a8a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions LoopStructural/interpolators/_p2interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ def add_value_constraints(self, w=1.0):
wt = np.ones(size.shape[0])
wt *= w
self.add_constraints_to_least_squares(
N[mask, :] * wt[:, None],
points[mask, 3] * wt,
N[mask, :],
points[mask, 3],
self.support.elements[elements[mask], :],
w=wt,
name="value",
)

Expand Down Expand Up @@ -199,17 +200,17 @@ def minimise_grad_steepness(self, w=0.1, maskall=True, wtfunc=None):
d2 = self.support.evaluate_shape_d2(elements[mask])
# d2 is [ele_idx, deriv, node]
wt = np.ones(d2.shape[0])

wt *= w # * self.support.element_size[mask]
if callable(wtfunc):
logger.info("Using function to weight gradient steepness")
wt = wtfunc(self.support.barycentre) * self.support.element_size[mask]
idc = self.support.elements[elements[mask]]
for i in range(d2.shape[1]):
self.add_constraints_to_least_squares(
d2[:, i, :] * wt[i, None, None],
d2[:, i, :],
np.zeros(d2.shape[0]),
idc[:, :],
w=wt,
name=f"grad_steepness_{i}",
)

Expand Down Expand Up @@ -247,9 +248,10 @@ def minimise_edge_jumps(
if wtfunc:
wt = wtfunc(tri_cp)
self.add_constraints_to_least_squares(
const_cp * wt[:, None],
const_cp,
np.zeros(const_cp.shape[0]),
tri_cp,
w=wt,
name=f"shared element jump cp{i}",
)

Expand Down

0 comments on commit 5002a8a

Please sign in to comment.