OptFEM3DP1 Toolbox  20130618_070730
Matlab/Octave Optimized P1-Lagrange Finite Element Method in 3D
 All Files Functions Variables Pages
ElemStiffMat3DVecP1D0.m
Go to the documentation of this file.
1 function [Kg]=ElemStiffMat3DVecP1D0(q,me,volumes)
2 % NAME
3 % [Kg]=ElemStiffMat3DVecP1D0(q,me,areas)
4 % INPUTS
5 % q : matrix 2 x nq
6 % me : matrix 3 x nme
7 % volumes : vector 1 x nme (elements volume)
8 % OUTPUTS
9 % Kg : matrix 16x nme
10 % DESCRIPTION
11 % Compute P1-Lagrange Kg array for Stiff matrix (see report).
12 % Numbering of local points in reference element is :
13 % P=[(0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1)]
14 %----------------------------------------
15 % Automatic generation with sage
16 % (c) Cuvelier F. email:cuvelier@math.univ-paris13.fr
17 % Copyright:
18 % See \ref license
19 ndf=4;
20 nme=length(volumes);
21 D12=q(:,me(1,:))-q(:,me(2,:));
22 D13=q(:,me(1,:))-q(:,me(3,:));
23 D14=q(:,me(1,:))-q(:,me(4,:));
24 D23=q(:,me(2,:))-q(:,me(3,:));
25 D24=q(:,me(2,:))-q(:,me(4,:));
26 D34=q(:,me(3,:))-q(:,me(4,:));
27 G{1}=zeros(3,nme);
28 G{1}(1,:)=-D23(2,:).*D24(3,:) + D23(3,:).*D24(2,:);
29 G{1}(2,:)=D23(1,:).*D24(3,:) - D23(3,:).*D24(1,:);
30 G{1}(3,:)=-D23(1,:).*D24(2,:) + D23(2,:).*D24(1,:);
31 G{2}=zeros(3,nme);
32 G{2}(1,:)=D13(2,:).*D14(3,:) - D13(3,:).*D14(2,:);
33 G{2}(2,:)=-D13(1,:).*D14(3,:) + D13(3,:).*D14(1,:);
34 G{2}(3,:)=D13(1,:).*D14(2,:) - D13(2,:).*D14(1,:);
35 G{3}=zeros(3,nme);
36 G{3}(1,:)=-D12(2,:).*D14(3,:) + D12(3,:).*D14(2,:);
37 G{3}(2,:)=D12(1,:).*D14(3,:) - D12(3,:).*D14(1,:);
38 G{3}(3,:)=-D12(1,:).*D14(2,:) + D12(2,:).*D14(1,:);
39 G{4}=zeros(3,nme);
40 G{4}(1,:)=D12(2,:).*D13(3,:) - D12(3,:).*D13(2,:);
41 G{4}(2,:)=-D12(1,:).*D13(3,:) + D12(3,:).*D13(1,:);
42 G{4}(3,:)=D12(1,:).*D13(2,:) - D12(2,:).*D13(1,:);
43 clear D12 D13 D14 D23 D24 D34
44 vol36=36*volumes;
45 G1G1=sum(G{1}.*G{1},1)./vol36;
46 G1G2=sum(G{1}.*G{2},1)./vol36;
47 G1G3=sum(G{1}.*G{3},1)./vol36;
48 G1G4=sum(G{1}.*G{4},1)./vol36;
49 G2G2=sum(G{2}.*G{2},1)./vol36;
50 G2G3=sum(G{2}.*G{3},1)./vol36;
51 G2G4=sum(G{2}.*G{4},1)./vol36;
52 G3G3=sum(G{3}.*G{3},1)./vol36;
53 G3G4=sum(G{3}.*G{4},1)./vol36;
54 G4G4=sum(G{4}.*G{4},1)./vol36;
55 Kg=zeros(ndf*ndf,nme);
56 Kg(1,:)=+1.0*G1G1;
57 Kg(2,:)=+1.0*G1G2;
58 Kg(3,:)=+1.0*G1G3;
59 Kg(4,:)=+1.0*G1G4;
60 Kg(6,:)=+1.0*G2G2;
61 Kg(7,:)=+1.0*G2G3;
62 Kg(8,:)=+1.0*G2G4;
63 Kg(11,:)=+1.0*G3G3;
64 Kg(12,:)=+1.0*G3G4;
65 Kg(16,:)=+1.0*G4G4;
66 Kg([5, 9, 10, 13, 14, 15],:)=Kg([2, 3, 7, 4, 8, 12],:);