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 1354 2014-04-08 15:22:57Z keck $ |
---|
27 | ! |
---|
28 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
29 | ! REAL constants provided with KIND-attribute |
---|
30 | ! |
---|
31 | ! 1346 2014-03-27 13:18:20Z heinze |
---|
32 | ! Bugfix: REAL constants provided with KIND-attribute especially in call of |
---|
33 | ! intrinsic function like MAX, MIN, SIGN |
---|
34 | ! |
---|
35 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
36 | ! ONLY-attribute added to USE-statements, |
---|
37 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
38 | ! kinds are defined in new module kinds, |
---|
39 | ! revision history before 2012 removed, |
---|
40 | ! comment fields (!:) to be used for variable explanations added to |
---|
41 | ! all variable declaration statements |
---|
42 | ! |
---|
43 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
44 | ! unused variables removed |
---|
45 | ! |
---|
46 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
47 | ! code put under GPL (PALM 3.9) |
---|
48 | ! |
---|
49 | ! Initial version (2008/03/07) |
---|
50 | ! |
---|
51 | ! Description: |
---|
52 | ! ------------ |
---|
53 | ! Imposing turbulence at the respective inflow using the turbulence |
---|
54 | ! recycling method of Kataoka and Mizuno (2002). |
---|
55 | !------------------------------------------------------------------------------! |
---|
56 | |
---|
57 | USE arrays_3d, & |
---|
58 | ONLY: e, inflow_damping_factor, mean_inflow_profiles, pt, u, v, w |
---|
59 | |
---|
60 | USE control_parameters, & |
---|
61 | ONLY: recycling_plane |
---|
62 | |
---|
63 | USE cpulog, & |
---|
64 | ONLY: cpu_log, log_point |
---|
65 | |
---|
66 | USE grid_variables, & |
---|
67 | ONLY: |
---|
68 | |
---|
69 | USE indices, & |
---|
70 | ONLY: nbgp, nxl, ny, nyn, nys, nyng, nysg, nzb, nzt |
---|
71 | |
---|
72 | USE kinds |
---|
73 | |
---|
74 | USE pegrid |
---|
75 | |
---|
76 | |
---|
77 | IMPLICIT NONE |
---|
78 | |
---|
79 | INTEGER(iwp) :: i !: |
---|
80 | INTEGER(iwp) :: j !: |
---|
81 | INTEGER(iwp) :: k !: |
---|
82 | INTEGER(iwp) :: l !: |
---|
83 | INTEGER(iwp) :: ngp_ifd !: |
---|
84 | INTEGER(iwp) :: ngp_pr !: |
---|
85 | |
---|
86 | REAL(wp), DIMENSION(nzb:nzt+1,5,nbgp) :: & |
---|
87 | avpr, avpr_l !: |
---|
88 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) :: & |
---|
89 | inflow_dist !: |
---|
90 | |
---|
91 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
92 | |
---|
93 | ! |
---|
94 | !-- Carry out spanwise averaging in the recycling plane |
---|
95 | avpr_l = 0.0_wp |
---|
96 | ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp |
---|
97 | ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) |
---|
98 | |
---|
99 | ! |
---|
100 | !-- First, local averaging within the recycling domain |
---|
101 | i = recycling_plane |
---|
102 | |
---|
103 | #if defined( __parallel ) |
---|
104 | IF ( myidx == id_recycling ) THEN |
---|
105 | |
---|
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 | ENDIF |
---|
122 | ! |
---|
123 | !-- Now, averaging over all PEs |
---|
124 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
125 | CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & |
---|
126 | MPI_SUM, comm2d, ierr ) |
---|
127 | |
---|
128 | #else |
---|
129 | DO l = 1, nbgp |
---|
130 | DO j = nys, nyn |
---|
131 | DO k = nzb, nzt + 1 |
---|
132 | |
---|
133 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
134 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
135 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
136 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
137 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
138 | |
---|
139 | ENDDO |
---|
140 | ENDDO |
---|
141 | i = i + 1 |
---|
142 | ENDDO |
---|
143 | |
---|
144 | avpr = avpr_l |
---|
145 | #endif |
---|
146 | |
---|
147 | avpr = avpr / ( ny + 1 ) |
---|
148 | ! |
---|
149 | !-- Calculate the disturbances at the recycling plane |
---|
150 | i = recycling_plane |
---|
151 | |
---|
152 | #if defined( __parallel ) |
---|
153 | IF ( myidx == id_recycling ) THEN |
---|
154 | DO l = 1, nbgp |
---|
155 | DO j = nysg, nyng |
---|
156 | DO k = nzb, nzt + 1 |
---|
157 | |
---|
158 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
159 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
160 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
161 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
162 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
163 | |
---|
164 | ENDDO |
---|
165 | ENDDO |
---|
166 | i = i + 1 |
---|
167 | ENDDO |
---|
168 | |
---|
169 | ENDIF |
---|
170 | #else |
---|
171 | DO l = 1, nbgp |
---|
172 | DO j = nysg, nyng |
---|
173 | DO k = nzb, nzt+1 |
---|
174 | |
---|
175 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
176 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
177 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
178 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
179 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
180 | |
---|
181 | ENDDO |
---|
182 | ENDDO |
---|
183 | i = i + 1 |
---|
184 | ENDDO |
---|
185 | #endif |
---|
186 | |
---|
187 | ! |
---|
188 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
189 | #if defined( __parallel ) |
---|
190 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
191 | |
---|
192 | CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
193 | id_inflow, 1, comm1dx, ierr ) |
---|
194 | |
---|
195 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
196 | |
---|
197 | inflow_dist = 0.0_wp |
---|
198 | CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
199 | id_recycling, 1, comm1dx, status, ierr ) |
---|
200 | |
---|
201 | ENDIF |
---|
202 | #endif |
---|
203 | |
---|
204 | ! |
---|
205 | !-- Add the disturbance at the inflow |
---|
206 | IF ( nxl == 0 ) THEN |
---|
207 | |
---|
208 | DO j = nysg, nyng |
---|
209 | DO k = nzb, nzt + 1 |
---|
210 | |
---|
211 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
212 | inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) |
---|
213 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
214 | inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) |
---|
215 | w(k,j,-nbgp:-1) = & |
---|
216 | inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) |
---|
217 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
218 | inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) |
---|
219 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
220 | inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) |
---|
221 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0_wp ) |
---|
222 | |
---|
223 | ENDDO |
---|
224 | ENDDO |
---|
225 | |
---|
226 | ENDIF |
---|
227 | |
---|
228 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
229 | |
---|
230 | |
---|
231 | END SUBROUTINE inflow_turbulence |
---|