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

Last change on this file since 1061 was 1037, checked in by raasch, 12 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 6.2 KB
Line 
1 SUBROUTINE inflow_turbulence
2
3!--------------------------------------------------------------------------------!
4! This file is part of PALM.
5!
6! PALM is free software: you can redistribute it and/or modify it under the terms
7! of the GNU General Public License as published by the Free Software Foundation,
8! either version 3 of the License, or (at your option) any later version.
9!
10! PALM is distributed in the hope that it will be useful, but WITHOUT ANY
11! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12! A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13!
14! You should have received a copy of the GNU General Public License along with
15! PALM. If not, see <http://www.gnu.org/licenses/>.
16!
17! Copyright 1997-2012  Leibniz University Hannover
18!--------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22!
23!
24! Former revisions:
25! -----------------
26! $Id: inflow_turbulence.f90 1037 2012-10-22 14:10:22Z raasch $
27!
28! 1036 2012-10-22 13:43:42Z raasch
29! code put under GPL (PALM 3.9)
30!
31! 709 2011-03-30 09:31:40Z raasch
32! formatting adjustments
33!
34! 667 2010-12-23 12:06:00Z suehring/gryschka
35! Using nbgp recycling planes for a better resolution of the turbulent flow
36! near the inflow.
37!
38! 622 2010-12-10 08:08:13Z raasch
39! optional barriers included in order to speed up collective operations
40!
41! 222 2009-01-12 16:04:16Z letzel
42! Bugfix for nonparallel execution
43!
44! Initial version (2008/03/07)
45!
46! Description:
47! ------------
48! Imposing turbulence at the respective inflow using the turbulence
49! recycling method of Kataoka and Mizuno (2002).
50!------------------------------------------------------------------------------!
51
52    USE arrays_3d
53    USE control_parameters
54    USE cpulog
55    USE grid_variables
56    USE indices
57    USE interfaces
58    USE pegrid
59
60
61    IMPLICIT NONE
62
63    INTEGER ::  i, imax, j, k, l, ngp_ifd, ngp_pr
64
65    REAL, DIMENSION(1:2) ::  volume_flow_l, volume_flow_offset
66    REAL, DIMENSION(nzb:nzt+1,5,nbgp) ::  avpr, avpr_l
67    REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) ::  inflow_dist
68
69    CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
70
71!
72!-- Carry out spanwise averaging in the recycling plane
73    avpr_l = 0.0
74    ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp
75    ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp )
76
77!
78!-- First, local averaging within the recycling domain
79    i = recycling_plane
80
81#if defined( __parallel )
82    IF ( myidx == id_recycling )  THEN
83       
84       DO  l = 1, nbgp
85          DO  j = nys, nyn
86             DO  k = nzb, nzt + 1
87
88                avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
89                avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
90                avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
91                avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
92                avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
93
94             ENDDO
95          ENDDO
96          i = i + 1
97       ENDDO
98
99    ENDIF
100!
101!-- Now, averaging over all PEs
102    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
103    CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, &
104                        MPI_SUM, comm2d, ierr )
105
106#else
107    DO  l = 1, nbgp
108       DO  j = nys, nyn
109          DO  k = nzb, nzt + 1
110
111             avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
112             avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
113             avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
114             avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
115             avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
116
117          ENDDO
118       ENDDO
119       i = i + 1 
120    ENDDO
121   
122    avpr = avpr_l
123#endif
124
125    avpr = avpr / ( ny + 1 )
126!
127!-- Calculate the disturbances at the recycling plane
128    i = recycling_plane
129
130#if defined( __parallel )
131    IF ( myidx == id_recycling )  THEN
132       DO  l = 1, nbgp
133          DO  j = nysg, nyng
134             DO  k = nzb, nzt + 1
135
136                inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
137                inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
138                inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
139                inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
140                inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
141             
142            ENDDO
143          ENDDO
144          i = i + 1
145       ENDDO
146
147    ENDIF
148#else
149    DO  l = 1, nbgp
150       DO  j = nysg, nyng
151          DO  k = nzb, nzt+1
152
153             inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
154             inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
155             inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
156             inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
157             inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
158             
159          ENDDO
160       ENDDO
161       i = i + 1
162    ENDDO
163#endif
164
165!
166!-- For parallel runs, send the disturbances to the respective inflow PE
167#if defined( __parallel )
168    IF ( myidx == id_recycling  .AND.  myidx /= id_inflow )  THEN
169
170       CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
171                      id_inflow, 1, comm1dx, ierr )
172
173    ELSEIF ( myidx /= id_recycling  .AND.  myidx == id_inflow )  THEN
174
175       inflow_dist = 0.0
176       CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
177                      id_recycling, 1, comm1dx, status, ierr )
178
179    ENDIF
180#endif
181
182!
183!-- Add the disturbance at the inflow
184    IF ( nxl == 0 )  THEN
185
186       DO  j = nysg, nyng
187          DO  k = nzb, nzt + 1
188
189              u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + &
190                           inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k)
191              v(k,j,-nbgp:-1)  = mean_inflow_profiles(k,2) + &
192                           inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k)
193              w(k,j,-nbgp:-1)  =                             &
194                           inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k)
195              pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + &
196                           inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k)
197              e(k,j,-nbgp:-1)  = mean_inflow_profiles(k,5) + &
198                           inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k)
199              e(k,j,-nbgp:-1)  = MAX( e(k,j,-nbgp:-1), 0.0 )
200
201          ENDDO
202       ENDDO
203
204    ENDIF
205
206    CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' )
207
208
209 END SUBROUTINE inflow_turbulence
Note: See TracBrowser for help on using the repository browser.