-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfastdw.m
104 lines (64 loc) · 1.78 KB
/
fastdw.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function[dw,DW]=fastdw(lattice)
one_by_four_pi=1/(4*pi);
[psize vsize void]=size(lattice.VORTEX);
%disp('running right')
lemma=ones(1,psize);
LDW=zeros(psize,psize,7,3);
mCOLLOC(:,:,1)=lattice.COLLOC(:,1)*lemma;
mCOLLOC(:,:,2)=lattice.COLLOC(:,2)*lemma;
mCOLLOC(:,:,3)=lattice.COLLOC(:,3)*lemma;
mN(:,:,1)=lattice.N(:,1)*lemma;
mN(:,:,2)=lattice.N(:,2)*lemma;
mN(:,:,3)=lattice.N(:,3)*lemma;
for j=1:(vsize-1)
lr1(:,:,1)=(lattice.VORTEX(:,j,1)*lemma)';
lr1(:,:,2)=(lattice.VORTEX(:,j,2)*lemma)';
lr1(:,:,3)=(lattice.VORTEX(:,j,3)*lemma)';
lr2(:,:,1)=(lattice.VORTEX(:,j+1,1)*lemma)';
lr2(:,:,2)=(lattice.VORTEX(:,j+1,2)*lemma)';
lr2(:,:,3)=(lattice.VORTEX(:,j+1,3)*lemma)';
r1=lr1-mCOLLOC;
r2=lr2-mCOLLOC;
warning off
LDW(:,:,j,:)=mega(r1,r2);
warning on
end
LDW(find((isnan(LDW(:,:,:,:)))))=0;
DW=-squeeze(sum(LDW,3))*one_by_four_pi;
dw=sum(DW.*mN,3);
end
function[DW2]=mega(r1,r2)
%% First part
F1=cross(r1,r2,3);
LF1=(sum(F1.^2,3));
F2(:,:,1)=F1(:,:,1)./(LF1);
F2(:,:,2)=F1(:,:,2)./(LF1);
F2(:,:,3)=F1(:,:,3)./(LF1);
%clear('F1')
%% Next part
Lr1=sqrt(sum(r1.^2,3));
Lr2=sqrt(sum(r2.^2,3));
R1(:,:,1)=r1(:,:,1)./Lr1;
R1(:,:,2)=r1(:,:,2)./Lr1;
R1(:,:,3)=r1(:,:,3)./Lr1;
R2(:,:,1)=r2(:,:,1)./Lr2;
R2(:,:,2)=r2(:,:,2)./Lr2;
R2(:,:,3)=r2(:,:,3)./Lr2;
L1=(R2-R1);
%clear('R1','R2')
%% Third part
R0=(r2-r1);
radial_distance=sqrt((LF1./(sum(R0.^2,3))));
%% combinging 2 and 3
L2= R0(:,:,1).*L1(:,:,1)...
+R0(:,:,2).*L1(:,:,2)...
+R0(:,:,3).*L1(:,:,3);
%% Downwash
DW(:,:,1)=F2(:,:,1).*L2;
DW(:,:,2)=F2(:,:,2).*L2;
DW(:,:,3)=F2(:,:,3).*L2;
near=config('near');
DW2(:,:,1)=DW(:,:,1).*(1-(radial_distance<near));
DW2(:,:,2)=DW(:,:,2).*(1-(radial_distance<near));
DW2(:,:,3)=DW(:,:,3).*(1-(radial_distance<near));
end