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.
59 lines
1.7 KiB
59 lines
1.7 KiB
3 years ago
|
%--------------------------
|
||
|
% @Author: Jingqiao Hu
|
||
|
% @Date: 2020-10-29 15:04:18
|
||
|
% @LastEditTime: 2021-01-11 15:54:42
|
||
|
%--------------------------
|
||
|
% node order: 4-3
|
||
|
% 1-2
|
||
|
% alldofs: alldofs num in the whole domain
|
||
|
% ele_nodeNum: node num in this macro-ele
|
||
|
function f = multi_elastic_force(lenout, alldofs, dx, F, dFdx, edofMat_ma, global_u, global_l)
|
||
|
|
||
|
% % take one column in dF:
|
||
|
% % dF here: [ 0, 0; current dF:[0, dNdx;
|
||
|
% % dNdx, dNdy]; 0, dNdy];
|
||
|
% % At first, we need to transpose current dF to become dF here
|
||
|
% dFdx = dFdx([1,3,2,4], :, :);
|
||
|
|
||
|
eleNum_ma = size(dFdx, 2);
|
||
|
f = zeros(alldofs, 1);
|
||
|
jac = dx^2/4;
|
||
|
|
||
|
for ele_ma = 1:eleNum_ma
|
||
|
u = global_u{ele_ma}(:);
|
||
|
l = global_l{ele_ma}(:);
|
||
|
|
||
|
% as micro outer order: 4_coners, bottom, right, up, left
|
||
|
fe = 0;
|
||
|
for gp = 1:4
|
||
|
Fe = F{gp, ele_ma}; % 4 * eleNum_mi
|
||
|
P2 = PK1_fast(u, l, Fe); % 4 * eleNum_mi
|
||
|
|
||
|
dFe = dFdx{gp, ele_ma}; % 4 * lenout * eleNum_mi
|
||
|
dF1 = permute(dFe, [2,1,3]); % l * 4 * eleNum_mi
|
||
|
dF2 = reshape(dF1, lenout, [])'; % 4m * l
|
||
|
|
||
|
fg = P2(:)' * dF2; % 1 * lenout
|
||
|
fe = fe + fg * jac;
|
||
|
end
|
||
|
|
||
|
% every macro ele: 4corners -> down -> right -> up -> left
|
||
|
edof = edofMat_ma(ele_ma, :);
|
||
|
f(edof) = f(edof) - fe(:); % NOTE: MINUS!
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function P = PK1(u,l,F)
|
||
|
F = reshape(F, 2, 2);
|
||
|
|
||
|
% Neo hookean
|
||
|
JJ = log(det(F));
|
||
|
Finv = inv(F)';
|
||
|
PP = u*(F-Finv) + l*JJ*Finv;
|
||
|
|
||
|
P = PP(:)';
|
||
|
|
||
|
% Linear
|
||
|
% I = eye(3,3);
|
||
|
% PP = u*(F + F'-2*I) + l * (trace(F)-3) * I;
|
||
|
end
|