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

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

unused variables remove from several routines

  • Property svn:keywords set to Id
File size: 6.1 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! unused variables removed
23!
24! Former revisions:
25! -----------------
26! $Id: inflow_turbulence.f90 1092 2013-02-02 11:24: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, j, k, l, ngp_ifd, ngp_pr
64
65    REAL, DIMENSION(nzb:nzt+1,5,nbgp) ::  avpr, avpr_l
66    REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) ::  inflow_dist
67
68    CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
69
70!
71!-- Carry out spanwise averaging in the recycling plane
72    avpr_l = 0.0
73    ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp
74    ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp )
75
76!
77!-- First, local averaging within the recycling domain
78    i = recycling_plane
79
80#if defined( __parallel )
81    IF ( myidx == id_recycling )  THEN
82       
83       DO  l = 1, nbgp
84          DO  j = nys, nyn
85             DO  k = nzb, nzt + 1
86
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)
92
93             ENDDO
94          ENDDO
95          i = i + 1
96       ENDDO
97
98    ENDIF
99!
100!-- Now, averaging over all PEs
101    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
102    CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, &
103                        MPI_SUM, comm2d, ierr )
104
105#else
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   
121    avpr = avpr_l
122#endif
123
124    avpr = avpr / ( ny + 1 )
125!
126!-- Calculate the disturbances at the recycling plane
127    i = recycling_plane
128
129#if defined( __parallel )
130    IF ( myidx == id_recycling )  THEN
131       DO  l = 1, nbgp
132          DO  j = nysg, nyng
133             DO  k = nzb, nzt + 1
134
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
142          ENDDO
143          i = i + 1
144       ENDDO
145
146    ENDIF
147#else
148    DO  l = 1, nbgp
149       DO  j = nysg, nyng
150          DO  k = nzb, nzt+1
151
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
159       ENDDO
160       i = i + 1
161    ENDDO
162#endif
163
164!
165!-- For parallel runs, send the disturbances to the respective inflow PE
166#if defined( __parallel )
167    IF ( myidx == id_recycling  .AND.  myidx /= id_inflow )  THEN
168
169       CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
170                      id_inflow, 1, comm1dx, ierr )
171
172    ELSEIF ( myidx /= id_recycling  .AND.  myidx == id_inflow )  THEN
173
174       inflow_dist = 0.0
175       CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
176                      id_recycling, 1, comm1dx, status, ierr )
177
178    ENDIF
179#endif
180
181!
182!-- Add the disturbance at the inflow
183    IF ( nxl == 0 )  THEN
184
185       DO  j = nysg, nyng
186          DO  k = nzb, nzt + 1
187
188              u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + &
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)
192              w(k,j,-nbgp:-1)  =                             &
193                           inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k)
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 )
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.