-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathintegrationweights.m
86 lines (82 loc) · 1.99 KB
/
integrationweights.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
function w = integrationweights(ncoord,nelnodes,npoints,elident)
%
%================= INTEGRATION WEIGHTS ==================================
%
% Defines integration weights w_i (Gaussian quadrature for 1D/2D/3D)
%
w = zeros(npoints,1);
%
% 1D elements
%
if (ncoord == 1)
if (npoints == 1)
w(1) = 2.;
elseif (npoints == 2)
w = [1.,1.];
elseif (npoints == 3)
w = [0.555555555,0.888888888,0.555555555];
end
%
% 2D elements
%
elseif (ncoord == 2)
%
% Triangular element
%
if ( nelnodes == 3 || nelnodes == 6 )
if (npoints == 1)
w(1) = 0.5;
elseif (npoints == 3)
w(1) = 1./6.;
w(2) = 1./6.;
w(3) = 1./6.;
elseif (npoints == 4)
w = [-27./96.,25./96.,25/96.,25/96.];
end
%
% Rectangular element
%
elseif ( nelnodes==4 || nelnodes==8 )
if (npoints == 1)
w(1) = 4.;
elseif (npoints == 4)
w = [1.,1.,1.,1.];
elseif (npoints == 9 )
w1D = [0.555555555,0.888888888,0.55555555555];
for j = 1:3
for i = 1:3
n = 3*(j-1)+i;
w(n) = w1D(i)*w1D(j);
end
end
end
end
elseif (ncoord == 3)
%
% 3D elements
%
if (nelnodes == 4 || nelnodes==10 )
if (npoints == 1)
w(1) = 1./6.;
elseif (npoints == 4)
w = [1./24.,1./24.,1./24.,1./24.];
end
elseif ( nelnodes==8 || nelnodes==20 )
if (npoints == 1)
w(1) = 8.;
elseif (npoints == 8)
w = [1.,1.,1.,1.,1.,1.,1.,1.];
elseif (npoints == 27)
w1D = [0.555555555,0.888888888,0.55555555555];
for k = 1:3
for j = 1:3
for i = 1:3
n = 9*(k-1)+3*(j-1)+i;
w(n) = w1D(i)*w1D(j)*w1D(k);
end
end
end
end
end
end
end