-
Notifications
You must be signed in to change notification settings - Fork 1
/
out.f90
209 lines (153 loc) · 4.71 KB
/
out.f90
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
MODULE out
USE prms
USE data
USE cheb
IMPLICIT none
CONTAINS
SUBROUTINE initout
END SUBROUTINE initout
SUBROUTINE closeout
END SUBROUTINE closeout
SUBROUTINE writefield(y)
real, dimension(0:Ndr,0:Ndt) :: y
integer :: i,j
open(1,file='D/y.plt',form='FORMATTED')
write(1, '(A)') 'VARIABLES = X, Y, Dil'
write(1, '(A,I9,A,I9,A)') 'ZONE I =', Ndr+1,' J=', Ndt+1, ' F=POINT'
do j = 0,Ndt
do i = 0,Ndr
write(1,"(E20.5)") Rd(i)*COS(Td(j)),Rd(i)*SIN(Td(j)),y(i,j)
end do
end do
close(1)
END SUBROUTINE writefield
SUBROUTINE writevel(y)
real, dimension(0:Ndr,0:Ndt) :: y
real, dimension(0:Ndr,0:Ndt) :: u,v
real, dimension(0:Nfr,0:Nft) :: uF,vF
integer :: i,j
do j = 0,Ndt
v(:,j) = -MATMUL(Dddr(:,:,1),y(:,j))
end do
do i = 0,Ndr
u(i,:) = MATMUL(Dddt(:,:,1),y(i,:))
end do
!!$
!!$ uF = u; vF = v
call makefine(u,uF)
call makefine(v,vF)
do j = 0,Nft
uF(:,j) = uF(:,j)/Rf(:)
end do
open(1,file='D/uv.plt',form='FORMATTED')
write(1, '(A)') 'VARIABLES = X, Y, U, V'
write(1, '(A,I9,A,I9,A)') 'ZONE I =', Nfr,' J=', Nft+1, ' F=POINT'
do j = 0,Nft
do i = 0,Nfr-1
write(1,"(E20.5)") Rf(i)*COS(Tf(j)), &
Rf(i)*SIN(Tf(j)),uF(i,j)*COS(Tf(j))-vF(i,j)*SIN(Tf(j)), &
uF(i,j)*SIN(Tf(j))+vF(i,j)*COS(Tf(j))
end do
end do
close(1)
END SUBROUTINE writevel
SUBROUTINE writefieldF(y)
real, dimension(0:Ndr,0:Ndt) :: y
real, dimension(0:Nfr,0:Nft) :: yF
integer :: i,j
call makefine(y,yF)
open(1,file='D/yF.plt',form='FORMATTED')
write(1, '(A)') 'VARIABLES = X, Y, Dil'
write(1, '(A,I9,A,I9,A)') 'ZONE I =', Nfr+1,' J=', Nft+1, ' F=POINT'
do j = 0,Nft
do i = 0,Nfr
write(1,"(E20.5)") Rf(i)*COS(Tf(j)),Rf(i)*SIN(Tf(j)),yF(i,j)
end do
end do
close(1)
END SUBROUTINE writefieldF
SUBROUTINE makefine(y,yF)
real, dimension(0:Ndr,0:Ndt) :: y
real, dimension(0:Nfr,0:Nft) :: yF
real, dimension(0:Nfr,0:Ndt) :: yi
integer :: i,j
do j = 0,Ndt
yi(:,j) = MATMUL(Tfdr,MATMUL(Thddr,y(:,j)))
end do
do i = 0,Nfr
yF(i,:) = MATMUL(Tfdt,MATMUL(Thddt,yi(i,:)))
end do
END SUBROUTINE makefine
SUBROUTINE writeFDresid(y)
real, dimension(0:Ndr,0:Ndt) :: y
real, dimension(0:Nfr,0:Nft) :: yF
real, dimension(0:Nfr,0:Nft) :: ytttt,yrrrr,yttrr,yrrr,yrr,yr,yrtt,ytt,res
integer :: i,j
call makefine(y,yF)
call der(0,4,yF,ytttt)
call der(4,0,yF,yrrrr)
call der(2,2,yF,yttrr)
call der(3,0,yF,yrrr)
call der(2,0,yF,yrr)
call der(1,0,yF,yr)
call der(1,2,yF,yrtt)
call der(0,2,yF,ytt)
do i = 0,Nfr-1
res(i,:) = yrrrr(i,:) + 2./Rf(i)**2*yttrr(i,:) &
+ 1./Rf(i)**4*ytttt(i,:) &
+ 2./Rf(i)*yrrr(i,:) - 2./Rf(i)**3*yrtt(i,:) &
- 1./Rf(i)**2*yrr(i,:) + 4./Rf(i)**4*ytt(i,:) &
+ 1./Rf(i)**3*yr(i,:)
end do
open(1,file='D/res.plt',form='FORMATTED')
write(1, '(A)') 'VARIABLES = X, Y, Dil'
write(1, '(A,I9,A,I9,A)') 'ZONE I =', Nfr,' J=', Nft+1, ' F=POINT'
do j = 0,Nft
do i = 0,Nfr-1
write(1,"(E20.5)") Rf(i)*COS(Tf(j)),Rf(i)*SIN(Tf(j)),res(i,j)
end do
end do
close(1)
END SUBROUTINE writeFDresid
SUBROUTINE der(nr,nt,f,df)
integer :: nr,nt
real, dimension(0:Nfr,0:Nft) :: f,df
integer :: l
df = f
print *,"nr = ",nr," nt = ",nt
print *,"r"
do l = 1,nr
print *,l
call derR(df)
end do
print *,"t"
do l = 1,nt
print *,l
call derT(df)
end do
print *
print *
END SUBROUTINE der
SUBROUTINE derR(df)
real, dimension(0:Nfr,0:Nft) :: df
real, dimension(0:Nfr,0:Nft) :: w
integer :: i
w(0,:) = (df(1,:)-df(0,:))/(Rf(1)-Rf(0))
do i = 1,Nfr-1
w(i,:) = (df(i+1,:)-df(i-1,:))/(Rf(i+1)-Rf(i-1))
end do
w(Nfr,:) = (df(Nfr,:)-df(Nfr-1,:))/(Rf(Nfr)-Rf(Nfr-1))
df = w
END SUBROUTINE derR
SUBROUTINE derT(df)
real, dimension(0:Nfr,0:Nft) :: df
real, dimension(0:Nfr,0:Nft) :: w
integer :: i
w(:,0) = (df(:,1)-df(:,0))/(Tf(1)-Tf(0))
do i = 1,Nft-1
w(:,i) = (df(:,i+1)-df(:,i-1))/(Tf(i+1)-Tf(i-1))
end do
w(:,Nft) = (df(:,Nft)-df(:,Nft-1))/(Tf(Nft)-Tf(Nft-1))
df = w
END SUBROUTINE derT
END MODULE out