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

Last change on this file since 1036 was 1036, checked in by raasch, 9 years ago

code has been put under the GNU General Public License (v3)

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