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

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

unused variables remove from several routines

  • Property svn:keywords set to Id
File size: 6.1 KB
RevLine 
[151]1 SUBROUTINE inflow_turbulence
2
[1036]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!
[484]20! Current revisions:
[151]21! -----------------
[1092]22! unused variables removed
[151]23!
24! Former revisions:
25! -----------------
26! $Id: inflow_turbulence.f90 1092 2013-02-02 11:24:22Z raasch $
27!
[1037]28! 1036 2012-10-22 13:43:42Z raasch
29! code put under GPL (PALM 3.9)
30!
[710]31! 709 2011-03-30 09:31:40Z raasch
32! formatting adjustments
33!
[668]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!
[623]38! 622 2010-12-10 08:08:13Z raasch
39! optional barriers included in order to speed up collective operations
40!
[226]41! 222 2009-01-12 16:04:16Z letzel
42! Bugfix for nonparallel execution
43!
[198]44! Initial version (2008/03/07)
[151]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
[1092]63    INTEGER ::  i, j, k, l, ngp_ifd, ngp_pr
[151]64
[667]65    REAL, DIMENSION(nzb:nzt+1,5,nbgp) ::  avpr, avpr_l
66    REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) ::  inflow_dist
[151]67
68    CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
69
70!
[667]71!-- Carry out spanwise averaging in the recycling plane
[151]72    avpr_l = 0.0
[667]73    ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp
74    ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp )
[151]75
76!
77!-- First, local averaging within the recycling domain
[667]78    i = recycling_plane
[151]79
[667]80#if defined( __parallel )
81    IF ( myidx == id_recycling )  THEN
82       
83       DO  l = 1, nbgp
[151]84          DO  j = nys, nyn
[667]85             DO  k = nzb, nzt + 1
[151]86
[667]87                avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
88                avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
89                avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
90                avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
91                avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
[151]92
93             ENDDO
94          ENDDO
[667]95          i = i + 1
[151]96       ENDDO
97
98    ENDIF
99!
100!-- Now, averaging over all PEs
[622]101    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
[709]102    CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, &
103                        MPI_SUM, comm2d, ierr )
[667]104
[151]105#else
[667]106    DO  l = 1, nbgp
107       DO  j = nys, nyn
108          DO  k = nzb, nzt + 1
109
110             avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
111             avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
112             avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
113             avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
114             avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
115
116          ENDDO
117       ENDDO
118       i = i + 1 
119    ENDDO
120   
[151]121    avpr = avpr_l
122#endif
123
[667]124    avpr = avpr / ( ny + 1 )
[151]125!
126!-- Calculate the disturbances at the recycling plane
127    i = recycling_plane
128
[222]129#if defined( __parallel )
[163]130    IF ( myidx == id_recycling )  THEN
[667]131       DO  l = 1, nbgp
132          DO  j = nysg, nyng
133             DO  k = nzb, nzt + 1
[151]134
[667]135                inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
136                inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
137                inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
138                inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
139                inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
140             
141            ENDDO
[151]142          ENDDO
[667]143          i = i + 1
[151]144       ENDDO
145
146    ENDIF
[222]147#else
[667]148    DO  l = 1, nbgp
149       DO  j = nysg, nyng
150          DO  k = nzb, nzt+1
[151]151
[667]152             inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
153             inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
154             inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
155             inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
156             inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
157             
158          ENDDO
[222]159       ENDDO
[667]160       i = i + 1
[222]161    ENDDO
162#endif
163
[151]164!
165!-- For parallel runs, send the disturbances to the respective inflow PE
166#if defined( __parallel )
[163]167    IF ( myidx == id_recycling  .AND.  myidx /= id_inflow )  THEN
[151]168
[667]169       CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
[151]170                      id_inflow, 1, comm1dx, ierr )
171
[163]172    ELSEIF ( myidx /= id_recycling  .AND.  myidx == id_inflow )  THEN
[151]173
[163]174       inflow_dist = 0.0
[667]175       CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
[163]176                      id_recycling, 1, comm1dx, status, ierr )
[151]177
178    ENDIF
179#endif
180
181!
182!-- Add the disturbance at the inflow
183    IF ( nxl == 0 )  THEN
184
[667]185       DO  j = nysg, nyng
186          DO  k = nzb, nzt + 1
[151]187
[709]188              u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + &
[667]189                           inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k)
190              v(k,j,-nbgp:-1)  = mean_inflow_profiles(k,2) + &
191                           inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k)
[709]192              w(k,j,-nbgp:-1)  =                             &
193                           inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k)
[667]194              pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + &
195                           inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k)
196              e(k,j,-nbgp:-1)  = mean_inflow_profiles(k,5) + &
197                           inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k)
198              e(k,j,-nbgp:-1)  = MAX( e(k,j,-nbgp:-1), 0.0 )
[151]199
200          ENDDO
201       ENDDO
202
203    ENDIF
204
205    CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' )
206
207
208 END SUBROUTINE inflow_turbulence
Note: See TracBrowser for help on using the repository browser.