You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

3 years ago
%--------------------------
% @Author: Jingqiao Hu
% @Date: 2021-02-22 13:20:56
% @LastEditTime: 2021-03-31 15:55:36
%--------------------------
function [U1, converged] = line_search_linear_2scale(du, rhs, fext, U0, dNh_e, ...
eleNum_mi, edofMat_ma, fixeddofs, dx, global_u, global_l, ...
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;
F = deform_grad(sort_u, edofMat_ma, dNh_e, eleNum_mi, U1, regulated_matrix);
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_linear(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<norm0) || (approxE1<approxE0) )
found_step=1;
break;
end
end
converged = 0;
if(~found_step || (abs(norm1-norm0)<1e-5))
converged = 1;
end
U1(fixeddofs) = U0(fixeddofs);
end
function inverted = check_inversion(F)
inverted = false;
eps = 1e-5;
eleNum_ma = size(F, 2);
for ele_ma = 1 : eleNum_ma
for gp = 1:4
F1 = F{gp, ele_ma}; % 4 * eleNum_mi
Fdet = F1(1, :).*F1(4, :) - F1(2, :).*F1(3, :);
if (sum(Fdet <= eps) > 0)
inverted = true;
return;
end
end
end
end