-
Notifications
You must be signed in to change notification settings - Fork 1
/
pre_assemble_MassN.m
22 lines (18 loc) · 1.01 KB
/
pre_assemble_MassN.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function [A, B, C] = pre_assemble_MassN(area_T3)
global ele_nods nnel nel nnode
global ndofp ndof
A = sparse(ndofp*nnode, ndofp*nnode);
B = sparse(ndofp*nnode, ndofp*nnode); % Stabilization
C = sparse(2, ndof*nnode); % for body force term
for iel=1:nel % loop for total number of element
index=get_eledof(ele_nods(iel, :), nnel, ndofp);
index2=get_eledof(ele_nods(iel, :), nnel, ndof);
% Integration of N^T*N on one triangle element = constant matrix * area
% area_T3(iel)*[1/6, 1/12, 1/12; 1/12, 1/6, 1/12; 1/12, 1/12, 1/6]
% We can also add stablization term here (see follows)
% area_T3(iel)*[1/18, -1/36, -1/36; -1/36, 1/18, -1/36; -1/36, -1/36, 1/18];
A(index, index) = A(index, index) + area_T3(iel)*[1/6, 1/12, 1/12; 1/12, 1/6, 1/12; 1/12, 1/12, 1/6];
B(index, index) = B(index, index) + area_T3(iel)*[1/18, -1/36, -1/36; -1/36, 1/18, -1/36; -1/36, -1/36, 1/18];
C(:, index2) = C(:, index2) + area_T3(iel)*[1/3, 0, 1/3, 0, 1/3, 0; 0, 1/3, 0, 1/3, 0, 1/3];
end
end