-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprint_outflow.f
191 lines (175 loc) · 5.49 KB
/
print_outflow.f
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
subroutine print_outflow(rchar,rloc)
include 'mpif.h'
include 'SIZE'
include 'TOTAL'
integer lxyz,nmax,lpmax
parameter(lxyz=lx1*ly1*lz1, lpmax = 128)
parameter(nmax=max(lelx*max(lely,lelz),lely*lelz)*lx1*lx1)
character rchar
real rloc,tmploc
real rcrd(lx1*ly1*lz1*lelv)
real scrd(lx1*ly1*lz1*lelv)
real tcrd(lx1*ly1*lz1*lelv)
character fname*32,schar,tchar
character*4 tname(ldimt)
integer ipoint,npts,aflag,lpts(nmax),gpts(lpmax),gpos(lpmax),ierr
integer i,i0,i1,j,j0,j1,k,k0,k1,n,npsout
real norm(3),fnorm(3),dp,vel
real lscrd(nmax),ltcrd(nmax),lvel(nmax),lt(nmax,ldimt)
real gscrd(nmax),gtcrd(nmax),gvel(nmax),gt(nmax,ldimt)
data aflag /0/
save aflag
if(np.gt.lpmax) then
if(nio.eq.0) write(6,*)
& "Not configured for more than 128 processes"
return
endif
if(aflag.gt.0) return
npts=0
n=nx1*ny1*nz1*nelv
call cfill(norm,0.0,3)
if(rchar.eq.'x'.or.rchar.eq.'X')then
norm(1)=1.0
schar="Y"
tchar="Z"
call copy(rcrd,xm1,n)
call copy(scrd,ym1,n)
if(if3d) call copy(tcrd,zm1,n)
elseif(rchar.eq.'y'.or.rchar.eq.'Y')then
norm(2)=1.0
call copy(rcrd,ym1,n)
if(if3d)then
schar="Z"
tchar="X"
call copy(scrd,zm1,n)
call copy(tcrd,xm1,n)
else
schar="X"
call copy(scrd,xm1,n)
endif
elseif(rchar.eq.'z'.or.rchar.eq.'Z')then
norm(3)=1.0
schar="X"
tchar="Y"
call copy(rcrd,zm1,n)
call copy(scrd,xm1,n)
call copy(tcrd,ym1,n)
endif
npsout=0
if(ifheat) then
j=0
if(ifto) then
write(tname(1),'(a4)')"temp"
j=j+1
endif
do i=1,npscal
if(ifpsco(i))then
write(tname(j+1),'(a2,i2)')"PS",i
j=j+1
endif
enddo
npsout=j
endif
tmploc=get_nearest_face(rloc,rcrd,norm)
do ielem=1,nelv
do iside=1,2*ldim
call facind(i0,i1,j0,j1,k0,k1,lx1,ly1,lz1,iside)
i=(i0+i1)/2
j=(j0+j1)/2
k=(k0+k1)/2
call getSnormal(fnorm,i,j,k,iside,ielem)
dp=fnorm(1)*norm(1)+fnorm(2)*norm(2)+fnorm(3)*norm(3)
if(abs(1.0-dp).lt.1.0d-8) then
ipoint=i+lx1*(j-1)+lx1*ly1*(k-1)+lxyz*(ielem-1)
if(abs(rcrd(ipoint)-tmploc).lt.1.0d-8) then
do i=i0,i1
do j=j0,j1
do k=k0,k1
ipoint=i+lx1*(j-1)+lx1*ly1*(k-1)+lxyz*(ielem-1)
npts=npts+1
if(npts.gt.nmax)then
aflag=1
goto 25
endif
lpts(npts)=ipoint
enddo
enddo
enddo
endif
endif
enddo
enddo
25 aflag=iglsum(aflag,1)
if(aflag.gt.0) then
if(nid.eq.0) then
write(*,'(2x,a)')"Warning: Too many points in outflow plane!"
write(*,'(5x,a)')"no outflow data will be printed!"
endif
return
endif
do i=1,npts
ipoint=lpts(i)
lscrd(i)=scrd(ipoint)
if(if3d) ltcrd(i)=tcrd(ipoint)
vel=vx(ipoint,1,1,1)*norm(1)+vy(ipoint,1,1,1)*norm(2)
if(if3d) vel=vel+vz(ipoint,1,1,1)*norm(3)
lvel(i) =vel
if(ifheat) then
k=1
if(ifto) then
lt(i,1)=t(ipoint,1,1,1,1)
k=k+1
endif
do j=1,npscal
if(ifpsco(j))then
lt(i,k)=t(ipoint,1,1,1,j+1)
k=k+1
endif
enddo
endif
enddo
call MPI_Gather(npts,1,MPI_INTEGER,gpts,1,MPI_INTEGER,0
& ,MPI_COMM_WORLD,ierr)
gpos(1)=0
do i=2,np
gpos(i)=gpos(i-1)+gpts(i-1)
enddo
call MPI_GatherV(lscrd,npts,MPI_DOUBLE,gscrd,gpts,gpos,MPI_DOUBLE
& ,0,MPI_COMM_WORLD,ierr)
if(if3d)
&call MPI_GatherV(ltcrd,npts,MPI_DOUBLE,gtcrd,gpts,gpos,MPI_DOUBLE
& ,0,MPI_COMM_WORLD,ierr)
call MPI_GatherV(lvel ,npts,MPI_DOUBLE,gvel ,gpts,gpos,MPI_DOUBLE
& ,0,MPI_COMM_WORLD,ierr)
if(ifheat) then
do i=1,npsout
call MPI_GatherV(lt(1,i),npts,MPI_DOUBLE,gt(1,i),gpts,gpos
& ,MPI_DOUBLE,0,MPI_COMM_WORLD,ierr)
enddo
endif
npts=iglsum(npts,1)
if(nid.eq.0) then
write(fname,'(a,i3,a)')"outflow.dat"
open(unit=10,file=fname,status='unknown',form='formatted')
if(if3d) then
write(10,'(i6,a14,21a20)')npts,schar,tchar,"velocity"
& ,(tname(i),i=1,npsout)
do i=1,npts
write(10,'(23(ES20.12))') gscrd(i),gtcrd(i),gvel(i)
& ,(gt(i,j),j=1,npsout)
enddo
else
write(10,'(i6,a14,21a20)')npts,schar,"velocity"
& ,(tname(i),i=1,npsout)
do i=1,npts
write(10,'(23(ES20.12))') gscrd(i),gvel(i)
& ,(gt(i,j),j=1,npsout)
enddo
endif
close(10)
write(*,'(5x,i6,1x,a,a)')
& npts,"GLL points written to file ",fname
write(*,*)
endif
return
end