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

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