source: palm/trunk/SOURCE/inflow_turbulence.f90 @ 254

Last change on this file since 254 was 226, checked in by raasch, 16 years ago

preparations for the next release

  • Property svn:keywords set to Id
File size: 6.2 KB
Line 
1 SUBROUTINE inflow_turbulence
2
3!------------------------------------------------------------------------------!
4! Actual revisions:
5! -----------------
6!
7!
8! Former revisions:
9! -----------------
10! $Id: inflow_turbulence.f90 226 2009-02-02 07:39:34Z heinze $
11!
12! 222 2009-01-12 16:04:16Z letzel
13! Bugfix for nonparallel execution
14!
15! Initial version (2008/03/07)
16!
17! Description:
18! ------------
19! Imposing turbulence at the respective inflow using the turbulence
20! recycling method of Kataoka and Mizuno (2002).
21!------------------------------------------------------------------------------!
22
23    USE arrays_3d
24    USE control_parameters
25    USE cpulog
26    USE grid_variables
27    USE indices
28    USE interfaces
29    USE pegrid
30
31
32    IMPLICIT NONE
33
34    INTEGER ::  i, imax, j, k, ngp_ifd, ngp_pr
35
36    REAL, DIMENSION(1:2) ::  volume_flow_l, volume_flow_offset
37    REAL, DIMENSION(nzb:nzt+1,5) ::  avpr, avpr_l
38    REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,5) ::  inflow_dist
39
40    CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
41
42!
43!-- Carry out horizontal averaging in the recycling plane
44    avpr_l = 0.0
45    ngp_pr = ( nzt - nzb + 2 ) * 5
46    ngp_ifd = ngp_pr * ( nyn - nys + 3 )
47
48!
49!-- First, local averaging within the recycling domain
50    IF ( recycling_plane >= nxl )  THEN
51
52       imax = MIN( nxr, recycling_plane )
53
54       DO  i = nxl, imax
55          DO  j = nys, nyn
56             DO  k = nzb, nzt+1
57
58                avpr_l(k,1) = avpr_l(k,1) + u(k,j,i)
59                avpr_l(k,2) = avpr_l(k,2) + v(k,j,i)
60                avpr_l(k,3) = avpr_l(k,3) + w(k,j,i)
61                avpr_l(k,4) = avpr_l(k,4) + pt(k,j,i)
62                avpr_l(k,5) = avpr_l(k,5) + e(k,j,i)
63
64             ENDDO
65          ENDDO
66       ENDDO
67
68    ENDIF
69
70!    WRITE (9,*) '*** averaged profiles avpr_l'
71!    DO  k = nzb, nzt+1
72!       WRITE (9,'(F5.1,1X,F5.1,1X,F5.1,1X,F6.1,1X,F7.2)') avpr_l(k,1),avpr_l(k,2),avpr_l(k,3),avpr_l(k,4),avpr_l(k,5)
73!    ENDDO
74!    WRITE (9,*) ' '
75
76#if defined( __parallel )
77!
78!-- Now, averaging over all PEs
79    CALL MPI_ALLREDUCE( avpr_l(nzb,1), avpr(nzb,1), ngp_pr, MPI_REAL, MPI_SUM, &
80                        comm2d, ierr )
81#else
82    avpr = avpr_l
83#endif
84
85    avpr = avpr / ( ( ny + 1 ) * ( recycling_plane + 1 ) )
86
87!    WRITE (9,*) '*** averaged profiles'
88!    DO  k = nzb, nzt+1
89!       WRITE (9,'(F5.1,1X,F5.1,1X,F5.1,1X,F6.1,1X,F7.2)') avpr(k,1),avpr(k,2),avpr(k,3),avpr(k,4),avpr(k,5)
90!    ENDDO
91!    WRITE (9,*) ' '
92
93!
94!-- Calculate the disturbances at the recycling plane
95    i = recycling_plane
96
97#if defined( __parallel )
98    IF ( myidx == id_recycling )  THEN
99
100       DO  j = nys-1, nyn+1
101          DO  k = nzb, nzt+1
102
103              inflow_dist(k,j,1) = u(k,j,i+1) - avpr(k,1)
104              inflow_dist(k,j,2) = v(k,j,i)   - avpr(k,2)
105              inflow_dist(k,j,3) = w(k,j,i)   - avpr(k,3)
106              inflow_dist(k,j,4) = pt(k,j,i)  - avpr(k,4)
107              inflow_dist(k,j,5) = e(k,j,i)   - avpr(k,5)
108
109          ENDDO
110       ENDDO
111
112    ENDIF
113#else
114    DO  j = nys-1, nyn+1
115       DO  k = nzb, nzt+1
116
117          inflow_dist(k,j,1) = u(k,j,i+1) - avpr(k,1)
118          inflow_dist(k,j,2) = v(k,j,i)   - avpr(k,2)
119          inflow_dist(k,j,3) = w(k,j,i)   - avpr(k,3)
120          inflow_dist(k,j,4) = pt(k,j,i)  - avpr(k,4)
121          inflow_dist(k,j,5) = e(k,j,i)   - avpr(k,5)
122
123       ENDDO
124    ENDDO
125#endif
126
127!
128!-- For parallel runs, send the disturbances to the respective inflow PE
129#if defined( __parallel )
130    IF ( myidx == id_recycling  .AND.  myidx /= id_inflow )  THEN
131
132       CALL MPI_SEND( inflow_dist(nzb,nys-1,1), ngp_ifd, MPI_REAL, &
133                      id_inflow, 1, comm1dx, ierr )
134
135    ELSEIF ( myidx /= id_recycling  .AND.  myidx == id_inflow )  THEN
136
137       inflow_dist = 0.0
138       CALL MPI_RECV( inflow_dist(nzb,nys-1,1), ngp_ifd, MPI_REAL, &
139                      id_recycling, 1, comm1dx, status, ierr )
140
141    ENDIF
142#endif
143
144!
145!-- Add the disturbance at the inflow
146    IF ( nxl == 0 )  THEN
147
148       DO  j = nys-1, nyn+1
149          DO  k = nzb, nzt+1
150
151!              WRITE (9,*) 'j=',j,' k=',k
152!              WRITE (9,*) 'mean_u = ', mean_inflow_profiles(k,1), ' dist_u = ',&
153!                          inflow_dist(k,j,1)
154!              WRITE (9,*) 'mean_v = ', mean_inflow_profiles(k,2), ' dist_v = ',&
155!                          inflow_dist(k,j,2)
156!              WRITE (9,*) 'mean_w = 0.0', ' dist_w = ',&
157!                          inflow_dist(k,j,3)
158!              WRITE (9,*) 'mean_pt = ', mean_inflow_profiles(k,4), ' dist_pt = ',&
159!                          inflow_dist(k,j,4)
160!              WRITE (9,*) 'mean_e = ', mean_inflow_profiles(k,5), ' dist_e = ',&
161!                          inflow_dist(k,j,5)
162              u(k,j,0)   = mean_inflow_profiles(k,1) + &
163                           inflow_dist(k,j,1) * inflow_damping_factor(k)
164              v(k,j,-1)  = mean_inflow_profiles(k,2) + &
165                           inflow_dist(k,j,2) * inflow_damping_factor(k)
166              w(k,j,-1)  = inflow_dist(k,j,3) * inflow_damping_factor(k)
167              pt(k,j,-1) = mean_inflow_profiles(k,4) + &
168                           inflow_dist(k,j,4) * inflow_damping_factor(k)
169              e(k,j,-1)  = mean_inflow_profiles(k,5) + &
170                           inflow_dist(k,j,5) * inflow_damping_factor(k)
171              e(k,j,-1)  = MAX( e(k,j,-1), 0.0 )
172
173          ENDDO
174       ENDDO
175
176    ENDIF
177
178!
179!-- Conserve the volume flow at the inflow in order to avoid generation of
180!-- waves in the stable layer
181!    IF ( conserve_volume_flow  .AND.  inflow_l )  THEN
182
183!       volume_flow(1)   = 0.0
184!       volume_flow_l(1) = 0.0
185
186!       i = 0
187
188!       DO  j = nys, nyn
189!
190!--       Sum up the volume flow through the south/north boundary
191!          DO  k = nzb_2d(j,i) + 1, nzt
192!             volume_flow_l(1) = volume_flow_l(1) + u(k,j,i) * dzu(k)
193!          ENDDO
194!       ENDDO
195
196#if defined( __parallel )   
197!       CALL MPI_ALLREDUCE( volume_flow_l(1), volume_flow(1), 1, MPI_REAL, &
198!                           MPI_SUM, comm1dy, ierr )   
199#else
200!       volume_flow = volume_flow_l 
201#endif
202!       volume_flow_offset(1) = ( volume_flow_initial(1) - volume_flow(1) )    &
203!                               / volume_flow_area(1)
204
205!       DO  j = nys-1, nyn+1
206!          DO  k = nzb_v_inner(j,i) + 1, nzt
207!             u(k,j,i) = u(k,j,i) + volume_flow_offset(1)
208!          ENDDO
209!       ENDDO
210
211!    ENDIF
212
213    CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' )
214
215
216 END SUBROUTINE inflow_turbulence
Note: See TracBrowser for help on using the repository browser.