%-------------------------- % @Author: Jingqiao Hu % @Date: 2021-01-25 20:51:51 % @LastEditTime: 2021-01-27 11:21:48 %-------------------------- function [U1, converged] = line_search_nonlinear(du, rhs, fext, U0, dNh_e, dN_c, ... edofMat_mi, edofMat_ma, fixeddofs, dx, global_u, global_l, opt_rotation, ... regulated_matrix, sort_u, dFdx) maxloop = 10; loop = 0; alldofs = size(U0, 1); num_vdofs_ma = size(edofMat_ma, 2); eleNum_mi = size(edofMat_mi, 1); step = 1; approxE0 = -sum(dot(rhs, U0)); norm0 = max(max(abs(rhs))); found_step = 0; while loop < maxloop loop = loop+1; U1 = step*du + U0; if opt_rotation R = update_corotation_matrix(edofMat_mi, edofMat_ma, U1, dN_c); else % update deform gradient F = deform_grad(sort_u, edofMat_ma, dNh_e, eleNum_mi, U1, regulated_matrix); end inverted = check_inversion(F); step = step*0.5; if (inverted) continue; % regard as not converged, % it is advised that the deformation gradient F be temporarily replaced by % the nearest physically plausible value ~F end fint = multi_elastic_force(num_vdofs_ma, alldofs, dx, F, dFdx, edofMat_ma, global_u, global_l); rhs = fint + fext; rhs(fixeddofs) = 0; approxE1 = -sum(dot(rhs, U1)); norm1 = max(max(abs(rhs))); if( (norm1 0) inverted = true; return; end end end end