-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_integral.m
25 lines (21 loc) · 977 Bytes
/
get_integral.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
function z = get_integral(N,vertices,deg)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input : 1) N - order of Gaussian quadrature 2) Coordinates vertices of %
% current element %
% %
% Output : 6*1 vector with i^th entry [integral f(x,y)*phi_i(x,y)] where %
% phi_i is i^th local basis function in the current element. %
% Integral is over each triangle. i ranges from 1 to 6. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
basis_count = (deg+1)*(deg+2)/2;
z = zeros(basis_count,1);
[X,W] = simplexquad(N,vertices);
NP = length(W);
for i = 1:basis_count
for j = 1:NP
x = X(j,1); y = X(j,2);
coords = [x,y];
z(i,1) = z(i,1) + f(coords)*basis(i,x,y,vertices(1:3,:),deg)*W(j);
end
end
end