-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathComputeAx_collocatedVs2.m
66 lines (51 loc) · 1.92 KB
/
ComputeAx_collocatedVs2.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
% ComputeAx
function R=ComputeAx_collocatedVs2(X, rr, tt ,delr, delth, r_n, t_n,dt,Re)
% int ii r direction,jj theta direction; double P_rr, P_tt, P_r
%X=reshape(X1,r_n,t_n);
R=zeros(r_n,t_n);
for ii=2:r_n-1 %r direction
for jj=1:t_n % theta direction
% for theta derivative
if(jj==1)
Vss_tt = (X(ii,jj+1)+X(ii,t_n)-2*X(ii,jj))/(delth^2);
elseif (jj==t_n)
Vss_tt = (X(ii,1)+X(ii,jj-1)-2*X(ii,jj))/(delth^2);
else
Vss_tt = (X(ii,jj+1)+X(ii,jj-1)-2*X(ii,jj))/(delth^2);
end
% for first r derivatives
if (ii==2)
Vss_r=(X(ii+1,jj)-0)/(2*delr);% dirichlet
elseif (ii==r_n-1)
% At the farfield
% if (tt(ii,jj)<pi/2 || tt(ii,jj)>3*pi/2 ) % neumann
% Vss_r=(X(ii,jj)-X(ii-1,jj))/(2*delr);
% % downstream
% else
%
Vss_r=(0-X(ii-1,jj))/(2*delr);% Dirichlet
% end
else
Vss_r=(X(ii+1,jj)-X(ii-1,jj))/(2*delr); %
end
% for second r derivatives
if (ii==2)
Vss_rr=(X(ii+1,jj)-2*X(ii,jj)+0)/(delr^2);
elseif (ii==r_n-1)
% if (tt(ii,jj)<pi/2 || tt(ii,jj)>3*pi/2 )
% Vss_rr=(-1*X(ii,jj)+X(ii-1,jj))/(delr^2);
%
% else
%
Vss_rr=(0-2*X(ii,jj)+X(ii-1,jj))/(delr^2);% Dirichlet
% end
else
Vss_rr=(X(ii+1,jj)-2*X(ii,jj)+X(ii-1,jj))/(delr^2);
end
R(ii,jj)= (dt/Re)*( Vss_rr + (1/(rr(ii,jj)^2))*Vss_tt + (1/rr(ii,jj))*Vss_r ) ...
-((dt/(Re*rr(ii,jj)^2)) +1)*X(ii,jj);
end
end
%R(r_n-1,1:2)=X(r_n-1,1:2);
%R=R1(:);
end