diff --git a/9_reduced_DOF/time_integrator.py b/9_reduced_DOF/time_integrator.py index 29f423b..e94ce1b 100644 --- a/9_reduced_DOF/time_integrator.py +++ b/9_reduced_DOF/time_integrator.py @@ -56,6 +56,7 @@ def IP_hess(x, e, x_tilde, m, vol, IB, mu_lame, lam, y_ground, contact_area, h): H = sparse.coo_matrix((IJV[2], (IJV[0], IJV[1])), shape=(len(x) * 2, len(x) * 2)).tocsr() return H +# ANCHOR: search_dir def search_dir(x, e, x_tilde, m, vol, IB, mu_lame, lam, y_ground, contact_area, is_DBC, reduced_basis, h): projected_hess = IP_hess(x, e, x_tilde, m, vol, IB, mu_lame, lam, y_ground, contact_area, h) reshaped_grad = IP_grad(x, e, x_tilde, m, vol, IB, mu_lame, lam, y_ground, contact_area, h).reshape(len(x) * 2, 1) @@ -68,4 +69,5 @@ def search_dir(x, e, x_tilde, m, vol, IB, mu_lame, lam, y_ground, contact_area, reshaped_grad[i * 2] = reshaped_grad[i * 2 + 1] = 0.0 reduced_hess = reduced_basis.T.dot(projected_hess.dot(reduced_basis)) # applying chain rule reduced_grad = reduced_basis.T.dot(reshaped_grad) # applying chain rule - return (reduced_basis.dot(spsolve(reduced_hess, -reduced_grad))).reshape(len(x), 2) # transform to full space after the solve \ No newline at end of file + return (reduced_basis.dot(spsolve(reduced_hess, -reduced_grad))).reshape(len(x), 2) # transform to full space after the solve +# ANCHOR_END: search_dir \ No newline at end of file diff --git a/9_reduced_DOF/utils.py b/9_reduced_DOF/utils.py index 7cc69d4..0259442 100644 --- a/9_reduced_DOF/utils.py +++ b/9_reduced_DOF/utils.py @@ -50,6 +50,7 @@ def compute_abd_anchor_basis(x): basis[i * 2 + d][d * 3 + 2] = anchors[i][1] return basis +# ANCHOR: compute_reduced_basis def compute_reduced_basis(x, e, vol, IB, mu_lame, lam, method, order): if method == 0: # full basis, no reduction basis = np.zeros((len(x) * 2, len(x) * 2)) @@ -99,4 +100,5 @@ def compute_reduced_basis(x, e, vol, IB, mu_lame, lam, method, order): IJV = NeoHookeanEnergy.hess(x, e, vol, IB, mu_lame, lam, project_PSD=False) H = sparse.coo_matrix((IJV[2], (IJV[0], IJV[1])), shape=(len(x) * 2, len(x) * 2)).tocsr() eigenvalues, eigenvectors = eigsh(H, k=order, which='SM') # get 'order' eigenvectors with smallest eigenvalues - return eigenvectors \ No newline at end of file + return eigenvectors +# ANCHOR_END: compute_reduced_basis \ No newline at end of file