You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defstep_forward(x, e, v, m, l2, k, n, o, contact_area, mu, is_DBC, h, tol):
16
+
x_tilde=x+v*h# implicit Euler predictive position
17
+
x_n=copy.deepcopy(x)
18
+
mu_lambda=BarrierEnergy.compute_mu_lambda(x, n, o, contact_area, mu) # compute mu * lambda for each node using x^n
19
+
20
+
# Newton loop
21
+
iter=0
22
+
E_last=IP_val(x, e, x_tilde, m, l2, k, n, o, contact_area, (x-x_n) /h, mu_lambda, h)
23
+
p=search_dir(x, e, x_tilde, m, l2, k, n, o, contact_area, (x-x_n) /h, mu_lambda, is_DBC, h)
24
+
whileLA.norm(p, inf) /h>tol:
25
+
print('Iteration', iter, ':')
26
+
print('residual =', LA.norm(p, inf) /h)
27
+
28
+
# filter line search
29
+
alpha=BarrierEnergy.init_step_size(x, n, o, p) # avoid interpenetration and tunneling
30
+
whileIP_val(x+alpha*p, e, x_tilde, m, l2, k, n, o, contact_area, (x-x_n) /h, mu_lambda, h) >E_last:
31
+
alpha/=2
32
+
print('step size =', alpha)
33
+
34
+
x+=alpha*p
35
+
E_last=IP_val(x, e, x_tilde, m, l2, k, n, o, contact_area, (x-x_n) /h, mu_lambda, h)
36
+
p=search_dir(x, e, x_tilde, m, l2, k, n, o, contact_area, (x-x_n) /h, mu_lambda, is_DBC, h)
37
+
iter+=1
38
+
39
+
v= (x-x_n) /h# implicit Euler velocity update
40
+
return [x, v]
41
+
42
+
defIP_val(x, e, x_tilde, m, l2, k, n, o, contact_area, v, mu_lambda, h):
43
+
returnInertiaEnergy.val(x, x_tilde, m) +h*h* (MassSpringEnergy.val(x, e, l2, k) +GravityEnergy.val(x, m) +BarrierEnergy.val(x, n, o, contact_area) +FrictionEnergy.val(v, mu_lambda, h, n)) # implicit Euler
44
+
45
+
defIP_grad(x, e, x_tilde, m, l2, k, n, o, contact_area, v, mu_lambda, h):
46
+
returnInertiaEnergy.grad(x, x_tilde, m) +h*h* (MassSpringEnergy.grad(x, e, l2, k) +GravityEnergy.grad(x, m) +BarrierEnergy.grad(x, n, o, contact_area) +FrictionEnergy.grad(v, mu_lambda, h, n)) # implicit Euler
47
+
48
+
defIP_hess(x, e, x_tilde, m, l2, k, n, o, contact_area, v, mu_lambda, h):
0 commit comments