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

Last change on this file since 1165 was 1093, 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 1093 2013-02-02 12:58:49Z raasch $
27!
28! 1092 2013-02-02 11:24:22Z raasch
29! unused variables removed
30!
31! 1036 2012-10-22 13:43:42Z raasch
32! code put under GPL (PALM 3.9)
33!
34! 709 2011-03-30 09:31:40Z raasch
35! formatting adjustments
36!
37! 667 2010-12-23 12:06:00Z suehring/gryschka
38! Using nbgp recycling planes for a better resolution of the turbulent flow
39! near the inflow.
40!
41! 622 2010-12-10 08:08:13Z raasch
42! optional barriers included in order to speed up collective operations
43!
44! 222 2009-01-12 16:04:16Z letzel
45! Bugfix for nonparallel execution
46!
47! Initial version (2008/03/07)
48!
49! Description:
50! ------------
51! Imposing turbulence at the respective inflow using the turbulence
52! recycling method of Kataoka and Mizuno (2002).
53!------------------------------------------------------------------------------!
54
55    USE arrays_3d
56    USE control_parameters
57    USE cpulog
58    USE grid_variables
59    USE indices
60    USE interfaces
61    USE pegrid
62
63
64    IMPLICIT NONE
65
66    INTEGER ::  i, j, k, l, ngp_ifd, ngp_pr
67
68    REAL, DIMENSION(nzb:nzt+1,5,nbgp) ::  avpr, avpr_l
69    REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) ::  inflow_dist
70
71    CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
72
73!
74!-- Carry out spanwise averaging in the recycling plane
75    avpr_l = 0.0
76    ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp
77    ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp )
78
79!
80!-- First, local averaging within the recycling domain
81    i = recycling_plane
82
83#if defined( __parallel )
84    IF ( myidx == id_recycling )  THEN
85       
86       DO  l = 1, nbgp
87          DO  j = nys, nyn
88             DO  k = nzb, nzt + 1
89
90                avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
91                avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
92                avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
93                avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
94                avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
95
96             ENDDO
97          ENDDO
98          i = i + 1
99       ENDDO
100
101    ENDIF
102!
103!-- Now, averaging over all PEs
104    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
105    CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, &
106                        MPI_SUM, comm2d, ierr )
107
108#else
109    DO  l = 1, nbgp
110       DO  j = nys, nyn
111          DO  k = nzb, nzt + 1
112
113             avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
114             avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
115             avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
116             avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
117             avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
118
119          ENDDO
120       ENDDO
121       i = i + 1 
122    ENDDO
123   
124    avpr = avpr_l
125#endif
126
127    avpr = avpr / ( ny + 1 )
128!
129!-- Calculate the disturbances at the recycling plane
130    i = recycling_plane
131
132#if defined( __parallel )
133    IF ( myidx == id_recycling )  THEN
134       DO  l = 1, nbgp
135          DO  j = nysg, nyng
136             DO  k = nzb, nzt + 1
137
138                inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
139                inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
140                inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
141                inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
142                inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
143             
144            ENDDO
145          ENDDO
146          i = i + 1
147       ENDDO
148
149    ENDIF
150#else
151    DO  l = 1, nbgp
152       DO  j = nysg, nyng
153          DO  k = nzb, nzt+1
154
155             inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
156             inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
157             inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
158             inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
159             inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
160             
161          ENDDO
162       ENDDO
163       i = i + 1
164    ENDDO
165#endif
166
167!
168!-- For parallel runs, send the disturbances to the respective inflow PE
169#if defined( __parallel )
170    IF ( myidx == id_recycling  .AND.  myidx /= id_inflow )  THEN
171
172       CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
173                      id_inflow, 1, comm1dx, ierr )
174
175    ELSEIF ( myidx /= id_recycling  .AND.  myidx == id_inflow )  THEN
176
177       inflow_dist = 0.0
178       CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
179                      id_recycling, 1, comm1dx, status, ierr )
180
181    ENDIF
182#endif
183
184!
185!-- Add the disturbance at the inflow
186    IF ( nxl == 0 )  THEN
187
188       DO  j = nysg, nyng
189          DO  k = nzb, nzt + 1
190
191              u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + &
192                           inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k)
193              v(k,j,-nbgp:-1)  = mean_inflow_profiles(k,2) + &
194                           inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k)
195              w(k,j,-nbgp:-1)  =                             &
196                           inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k)
197              pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + &
198                           inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k)
199              e(k,j,-nbgp:-1)  = mean_inflow_profiles(k,5) + &
200                           inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k)
201              e(k,j,-nbgp:-1)  = MAX( e(k,j,-nbgp:-1), 0.0 )
202
203          ENDDO
204       ENDDO
205
206    ENDIF
207
208    CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' )
209
210
211 END SUBROUTINE inflow_turbulence
Note: See TracBrowser for help on using the repository browser.