59 lines
1.4 KiB
Matlab
59 lines
1.4 KiB
Matlab
|
|
function[quadrature]=GaussQuadrature(GaussOption)
|
|
% Compute the Gauss Point with their weights
|
|
% Case 1: Quad 1x1
|
|
% Case 2: Quad 2x2
|
|
% Case 3: Quad 3x3
|
|
% Gauss points are automatically chosen relative to shape function
|
|
|
|
quadrature=struct();
|
|
|
|
switch GaussOption
|
|
case 'gauss1'
|
|
quadrature.points=[0 0];
|
|
|
|
quadrature.weights=4;
|
|
|
|
case 'gauss2'
|
|
quadrature.points=[...
|
|
-1/sqrt(3) -1/sqrt(3)
|
|
1/sqrt(3) -1/sqrt(3)
|
|
1/sqrt(3) 1/sqrt(3)
|
|
-1/sqrt(3) 1/sqrt(3)];
|
|
|
|
quadrature.weights=ones(size(quadrature.points,1),1);
|
|
|
|
case 'gauss3'
|
|
quadrature.points=[...
|
|
0 0
|
|
sqrt(3/5) sqrt(3/5)
|
|
-sqrt(3/5) sqrt(3/5)
|
|
-sqrt(3/5) -sqrt(3/5)
|
|
sqrt(3/5) -sqrt(3/5)
|
|
0 sqrt(3/5)
|
|
-sqrt(3/5) 0
|
|
0 -sqrt(3/5)
|
|
sqrt(3/5) 0];
|
|
|
|
quadrature.weights=[...
|
|
64/81
|
|
25/81
|
|
25/81
|
|
25/81
|
|
25/81
|
|
40/81
|
|
40/81
|
|
40/81
|
|
40/81];
|
|
end
|
|
|
|
figure
|
|
grid on, hold on
|
|
scatter(quadrature.points(:,1),quadrature.points(:,2),'*');
|
|
axis([-1 1 -1 1]);
|
|
|
|
for i=1:size(quadrature.points,1)
|
|
text(quadrature.points(i,1),quadrature.points(i,2)+0.1,num2str(i),'FontSize',14);
|
|
end
|
|
|
|
return |