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

Last change on this file since 1318 was 1318, checked in by raasch, 10 years ago

former files/routines cpu_log and cpu_statistics combined to one module,
which also includes the former data module cpulog from the modules-file,
module interfaces removed

  • 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! module interfaces removed
23!
24! Former revisions:
25! -----------------
26! $Id: inflow_turbulence.f90 1318 2014-03-17 13:35:16Z 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 pegrid
61
62
63    IMPLICIT NONE
64
65    INTEGER ::  i, j, k, l, ngp_ifd, ngp_pr
66
67    REAL, DIMENSION(nzb:nzt+1,5,nbgp) ::  avpr, avpr_l
68    REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) ::  inflow_dist
69
70    CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' )
71
72!
73!-- Carry out spanwise averaging in the recycling plane
74    avpr_l = 0.0
75    ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp
76    ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp )
77
78!
79!-- First, local averaging within the recycling domain
80    i = recycling_plane
81
82#if defined( __parallel )
83    IF ( myidx == id_recycling )  THEN
84       
85       DO  l = 1, nbgp
86          DO  j = nys, nyn
87             DO  k = nzb, nzt + 1
88
89                avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
90                avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
91                avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
92                avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
93                avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
94
95             ENDDO
96          ENDDO
97          i = i + 1
98       ENDDO
99
100    ENDIF
101!
102!-- Now, averaging over all PEs
103    IF ( collective_wait )  CALL MPI_BARRIER( comm2d, ierr )
104    CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, &
105                        MPI_SUM, comm2d, ierr )
106
107#else
108    DO  l = 1, nbgp
109       DO  j = nys, nyn
110          DO  k = nzb, nzt + 1
111
112             avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i)
113             avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i)
114             avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i)
115             avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i)
116             avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i)
117
118          ENDDO
119       ENDDO
120       i = i + 1 
121    ENDDO
122   
123    avpr = avpr_l
124#endif
125
126    avpr = avpr / ( ny + 1 )
127!
128!-- Calculate the disturbances at the recycling plane
129    i = recycling_plane
130
131#if defined( __parallel )
132    IF ( myidx == id_recycling )  THEN
133       DO  l = 1, nbgp
134          DO  j = nysg, nyng
135             DO  k = nzb, nzt + 1
136
137                inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
138                inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
139                inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
140                inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
141                inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
142             
143            ENDDO
144          ENDDO
145          i = i + 1
146       ENDDO
147
148    ENDIF
149#else
150    DO  l = 1, nbgp
151       DO  j = nysg, nyng
152          DO  k = nzb, nzt+1
153
154             inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l)
155             inflow_dist(k,j,2,l) = v(k,j,i)   - avpr(k,2,l)
156             inflow_dist(k,j,3,l) = w(k,j,i)   - avpr(k,3,l)
157             inflow_dist(k,j,4,l) = pt(k,j,i)  - avpr(k,4,l)
158             inflow_dist(k,j,5,l) = e(k,j,i)   - avpr(k,5,l)
159             
160          ENDDO
161       ENDDO
162       i = i + 1
163    ENDDO
164#endif
165
166!
167!-- For parallel runs, send the disturbances to the respective inflow PE
168#if defined( __parallel )
169    IF ( myidx == id_recycling  .AND.  myidx /= id_inflow )  THEN
170
171       CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
172                      id_inflow, 1, comm1dx, ierr )
173
174    ELSEIF ( myidx /= id_recycling  .AND.  myidx == id_inflow )  THEN
175
176       inflow_dist = 0.0
177       CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, &
178                      id_recycling, 1, comm1dx, status, ierr )
179
180    ENDIF
181#endif
182
183!
184!-- Add the disturbance at the inflow
185    IF ( nxl == 0 )  THEN
186
187       DO  j = nysg, nyng
188          DO  k = nzb, nzt + 1
189
190              u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + &
191                           inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k)
192              v(k,j,-nbgp:-1)  = mean_inflow_profiles(k,2) + &
193                           inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k)
194              w(k,j,-nbgp:-1)  =                             &
195                           inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k)
196              pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + &
197                           inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k)
198              e(k,j,-nbgp:-1)  = mean_inflow_profiles(k,5) + &
199                           inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k)
200              e(k,j,-nbgp:-1)  = MAX( e(k,j,-nbgp:-1), 0.0 )
201
202          ENDDO
203       ENDDO
204
205    ENDIF
206
207    CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' )
208
209
210 END SUBROUTINE inflow_turbulence
Note: See TracBrowser for help on using the repository browser.