@@ -24,6 +24,7 @@ def val(x, n, o, bp, be, contact_area):
2424 if d < dhat :
2525 s = d / dhat
2626 sum += contact_area [i ] * dhat * kappa / 2 * (s - 1 ) * math .log (s )
27+ # ANCHOR: value
2728 # self-contact
2829 dhat_sqr = dhat * dhat
2930 for xI in bp :
@@ -34,6 +35,7 @@ def val(x, n, o, bp, be, contact_area):
3435 s = d_sqr / dhat_sqr
3536 # since d_sqr is used, need to divide by 8 not 2 here for consistency to linear elasticity:
3637 sum += 0.5 * contact_area [xI ] * dhat * kappa / 8 * (s - 1 ) * math .log (s )
38+ # ANCHOR_END: value
3739 return sum
3840
3941def grad (x , n , o , bp , be , contact_area ):
@@ -53,6 +55,7 @@ def grad(x, n, o, bp, be, contact_area):
5355 local_grad = contact_area [i ] * dhat * (kappa / 2 * (math .log (s ) / dhat + (s - 1 ) / d )) * n
5456 g [i ] += local_grad
5557 g [- 1 ] -= local_grad
58+ # ANCHOR: gradient
5659 # self-contact
5760 dhat_sqr = dhat * dhat
5861 for xI in bp :
@@ -66,6 +69,7 @@ def grad(x, n, o, bp, be, contact_area):
6669 g [xI ] += local_grad [0 :2 ]
6770 g [eI [0 ]] += local_grad [2 :4 ]
6871 g [eI [1 ]] += local_grad [4 :6 ]
72+ # ANCHOR_END: gradient
6973 return g
7074
7175def hess (x , n , o , bp , be , contact_area ):
@@ -94,6 +98,7 @@ def hess(x, n, o, bp, be, contact_area):
9498 IJV [0 ].append (index [nI ] * 2 + r )
9599 IJV [1 ].append (index [nJ ] * 2 + c )
96100 IJV [2 ] = np .append (IJV [2 ], ((- 1 ) ** (nI != nJ )) * local_hess [r , c ])
101+ # ANCHOR: Hessian
97102 # self-contact
98103 dhat_sqr = dhat * dhat
99104 for xI in bp :
@@ -114,6 +119,7 @@ def hess(x, n, o, bp, be, contact_area):
114119 IJV [0 ].append (index [nI ] * 2 + r )
115120 IJV [1 ].append (index [nJ ] * 2 + c )
116121 IJV [2 ] = np .append (IJV [2 ], local_hess [nI * 2 + r , nJ * 2 + c ])
122+ # ANCHOR_END: Hessian
117123 return IJV
118124
119125def init_step_size (x , n , o , bp , be , p ):
@@ -129,6 +135,7 @@ def init_step_size(x, n, o, bp, be, p):
129135 p_n = (p [i ] - p [- 1 ]).dot (n )
130136 if p_n < 0 :
131137 alpha = min (alpha , 0.9 * n .dot (x [i ] - x [- 1 ]) / - p_n )
138+ # ANCHOR: line_search_filtering
132139 # self-contact
133140 for xI in bp :
134141 for eI in be :
@@ -137,6 +144,7 @@ def init_step_size(x, n, o, bp, be, p):
137144 toc = CCD .narrow_phase_CCD (x [xI ], x [eI [0 ]], x [eI [1 ]], p [xI ], p [eI [0 ]], p [eI [1 ]], alpha )
138145 if alpha > toc :
139146 alpha = toc
147+ # ANCHOR_END: line_search_filtering
140148 return alpha
141149
142150def compute_mu_lambda (x , n , o , bp , be , contact_area , mu ):
0 commit comments