[1682] | 1 | !> @file inflow_turbulence.f90 |
---|
[1036] | 2 | !--------------------------------------------------------------------------------! |
---|
| 3 | ! This file is part of PALM. |
---|
| 4 | ! |
---|
| 5 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | ! either version 3 of the License, or (at your option) any later version. |
---|
| 8 | ! |
---|
| 9 | ! PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | ! WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | ! A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | ! |
---|
| 13 | ! You should have received a copy of the GNU General Public License along with |
---|
| 14 | ! PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | ! |
---|
[1310] | 16 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 17 | !--------------------------------------------------------------------------------! |
---|
| 18 | ! |
---|
[484] | 19 | ! Current revisions: |
---|
[151] | 20 | ! ----------------- |
---|
[1354] | 21 | ! |
---|
[1683] | 22 | ! |
---|
[151] | 23 | ! Former revisions: |
---|
| 24 | ! ----------------- |
---|
| 25 | ! $Id: inflow_turbulence.f90 1683 2015-10-07 23:57:51Z hoffmann $ |
---|
| 26 | ! |
---|
[1683] | 27 | ! 1682 2015-10-07 23:56:08Z knoop |
---|
| 28 | ! Code annotations made doxygen readable |
---|
| 29 | ! |
---|
[1616] | 30 | ! 1615 2015-07-08 18:49:19Z suehring |
---|
| 31 | ! Enable turbulent inflow for passive_scalar and humidity |
---|
| 32 | ! |
---|
[1561] | 33 | ! 1560 2015-03-06 10:48:54Z keck |
---|
| 34 | ! Option recycling_yshift added. If this option is switched on, the turbulence |
---|
| 35 | ! data, which is mapped from the recycling plane to the inflow, is shifted in |
---|
| 36 | ! y direction (by ny * dy / 2 ) |
---|
| 37 | ! |
---|
[1354] | 38 | ! 1353 2014-04-08 15:21:23Z heinze |
---|
| 39 | ! REAL constants provided with KIND-attribute |
---|
| 40 | ! |
---|
[1347] | 41 | ! 1346 2014-03-27 13:18:20Z heinze |
---|
| 42 | ! Bugfix: REAL constants provided with KIND-attribute especially in call of |
---|
| 43 | ! intrinsic function like MAX, MIN, SIGN |
---|
| 44 | ! |
---|
[1321] | 45 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 46 | ! ONLY-attribute added to USE-statements, |
---|
| 47 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 48 | ! kinds are defined in new module kinds, |
---|
| 49 | ! revision history before 2012 removed, |
---|
| 50 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 51 | ! all variable declaration statements |
---|
| 52 | ! |
---|
[1093] | 53 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 54 | ! unused variables removed |
---|
| 55 | ! |
---|
[1037] | 56 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 57 | ! code put under GPL (PALM 3.9) |
---|
| 58 | ! |
---|
[198] | 59 | ! Initial version (2008/03/07) |
---|
[151] | 60 | ! |
---|
| 61 | ! Description: |
---|
| 62 | ! ------------ |
---|
[1682] | 63 | !> Imposing turbulence at the respective inflow using the turbulence |
---|
| 64 | !> recycling method of Kataoka and Mizuno (2002). |
---|
[151] | 65 | !------------------------------------------------------------------------------! |
---|
[1682] | 66 | SUBROUTINE inflow_turbulence |
---|
| 67 | |
---|
[151] | 68 | |
---|
[1320] | 69 | USE arrays_3d, & |
---|
[1615] | 70 | ONLY: e, inflow_damping_factor, mean_inflow_profiles, pt, q, u, v, w |
---|
[1320] | 71 | |
---|
| 72 | USE control_parameters, & |
---|
[1615] | 73 | ONLY: humidity, passive_scalar, recycling_plane, recycling_yshift |
---|
[1320] | 74 | |
---|
| 75 | USE cpulog, & |
---|
| 76 | ONLY: cpu_log, log_point |
---|
| 77 | |
---|
| 78 | USE grid_variables, & |
---|
| 79 | ONLY: |
---|
| 80 | |
---|
| 81 | USE indices, & |
---|
| 82 | ONLY: nbgp, nxl, ny, nyn, nys, nyng, nysg, nzb, nzt |
---|
| 83 | |
---|
| 84 | USE kinds |
---|
| 85 | |
---|
[151] | 86 | USE pegrid |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | IMPLICIT NONE |
---|
| 90 | |
---|
[1682] | 91 | INTEGER(iwp) :: i !< |
---|
| 92 | INTEGER(iwp) :: j !< |
---|
| 93 | INTEGER(iwp) :: k !< |
---|
| 94 | INTEGER(iwp) :: l !< |
---|
| 95 | INTEGER(iwp) :: next !< |
---|
| 96 | INTEGER(iwp) :: ngp_ifd !< |
---|
| 97 | INTEGER(iwp) :: ngp_pr !< |
---|
| 98 | INTEGER(iwp) :: prev !< |
---|
[151] | 99 | |
---|
[1615] | 100 | REAL(wp), DIMENSION(nzb:nzt+1,6,nbgp) :: & |
---|
[1682] | 101 | avpr, avpr_l !< |
---|
[1615] | 102 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,6,nbgp) :: & |
---|
[1682] | 103 | inflow_dist, local_inflow_dist !< |
---|
[151] | 104 | |
---|
| 105 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
| 106 | |
---|
| 107 | ! |
---|
[667] | 108 | !-- Carry out spanwise averaging in the recycling plane |
---|
[1353] | 109 | avpr_l = 0.0_wp |
---|
[1615] | 110 | ngp_pr = ( nzt - nzb + 2 ) * 6 * nbgp |
---|
[667] | 111 | ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) |
---|
[151] | 112 | |
---|
| 113 | ! |
---|
| 114 | !-- First, local averaging within the recycling domain |
---|
[667] | 115 | i = recycling_plane |
---|
[151] | 116 | |
---|
[667] | 117 | #if defined( __parallel ) |
---|
| 118 | IF ( myidx == id_recycling ) THEN |
---|
| 119 | |
---|
| 120 | DO l = 1, nbgp |
---|
[151] | 121 | DO j = nys, nyn |
---|
[667] | 122 | DO k = nzb, nzt + 1 |
---|
[151] | 123 | |
---|
[667] | 124 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 125 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 126 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 127 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 128 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[1615] | 129 | IF ( humidity .OR. passive_scalar ) & |
---|
| 130 | avpr_l(k,6,l) = avpr_l(k,6,l) + q(k,j,i) |
---|
[151] | 131 | |
---|
| 132 | ENDDO |
---|
| 133 | ENDDO |
---|
[667] | 134 | i = i + 1 |
---|
[151] | 135 | ENDDO |
---|
| 136 | |
---|
| 137 | ENDIF |
---|
| 138 | ! |
---|
| 139 | !-- Now, averaging over all PEs |
---|
[622] | 140 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1615] | 141 | CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & |
---|
[709] | 142 | MPI_SUM, comm2d, ierr ) |
---|
[667] | 143 | |
---|
[151] | 144 | #else |
---|
[667] | 145 | DO l = 1, nbgp |
---|
| 146 | DO j = nys, nyn |
---|
| 147 | DO k = nzb, nzt + 1 |
---|
| 148 | |
---|
| 149 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 150 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 151 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 152 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 153 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[1615] | 154 | IF ( humidity .OR. passive_scalar ) & |
---|
| 155 | avpr_l(k,6,l) = avpr_l(k,6,l) + q(k,j,i) |
---|
[667] | 156 | |
---|
| 157 | ENDDO |
---|
| 158 | ENDDO |
---|
| 159 | i = i + 1 |
---|
| 160 | ENDDO |
---|
| 161 | |
---|
[151] | 162 | avpr = avpr_l |
---|
| 163 | #endif |
---|
| 164 | |
---|
[667] | 165 | avpr = avpr / ( ny + 1 ) |
---|
[151] | 166 | ! |
---|
| 167 | !-- Calculate the disturbances at the recycling plane |
---|
| 168 | i = recycling_plane |
---|
| 169 | |
---|
[222] | 170 | #if defined( __parallel ) |
---|
[163] | 171 | IF ( myidx == id_recycling ) THEN |
---|
[667] | 172 | DO l = 1, nbgp |
---|
| 173 | DO j = nysg, nyng |
---|
| 174 | DO k = nzb, nzt + 1 |
---|
[151] | 175 | |
---|
[667] | 176 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 177 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 178 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 179 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 180 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
[1615] | 181 | IF ( humidity .OR. passive_scalar ) & |
---|
| 182 | inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l) |
---|
[667] | 183 | ENDDO |
---|
[151] | 184 | ENDDO |
---|
[667] | 185 | i = i + 1 |
---|
[151] | 186 | ENDDO |
---|
| 187 | |
---|
| 188 | ENDIF |
---|
[222] | 189 | #else |
---|
[667] | 190 | DO l = 1, nbgp |
---|
| 191 | DO j = nysg, nyng |
---|
| 192 | DO k = nzb, nzt+1 |
---|
[151] | 193 | |
---|
[667] | 194 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 195 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 196 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 197 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 198 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
[1615] | 199 | IF ( humidity .OR. passive_scalar ) & |
---|
| 200 | inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l) |
---|
[667] | 201 | |
---|
| 202 | ENDDO |
---|
[222] | 203 | ENDDO |
---|
[667] | 204 | i = i + 1 |
---|
[222] | 205 | ENDDO |
---|
| 206 | #endif |
---|
| 207 | |
---|
[151] | 208 | ! |
---|
| 209 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
| 210 | #if defined( __parallel ) |
---|
[163] | 211 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
[151] | 212 | |
---|
[1560] | 213 | CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[151] | 214 | id_inflow, 1, comm1dx, ierr ) |
---|
| 215 | |
---|
[163] | 216 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
[151] | 217 | |
---|
[1353] | 218 | inflow_dist = 0.0_wp |
---|
[1560] | 219 | CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[163] | 220 | id_recycling, 1, comm1dx, status, ierr ) |
---|
[151] | 221 | |
---|
| 222 | ENDIF |
---|
[1560] | 223 | |
---|
| 224 | |
---|
| 225 | IF ( recycling_yshift .AND. myidx == id_inflow ) THEN |
---|
| 226 | |
---|
| 227 | IF ( pdims(2) >= 2 ) THEN |
---|
| 228 | |
---|
| 229 | IF ( myidy >= INT( pdims(2) / 2 ) ) THEN |
---|
| 230 | prev = myidy - INT( pdims(2) / 2 ) |
---|
| 231 | ELSE |
---|
| 232 | prev = pdims(2) - ( INT( pdims(2) / 2 ) - myidy ) |
---|
| 233 | ENDIF |
---|
| 234 | |
---|
| 235 | IF ( myidy < pdims(2) - INT( pdims(2) / 2 ) ) THEN |
---|
| 236 | next = myidy + INT( pdims(2) / 2 ) |
---|
| 237 | ELSE |
---|
| 238 | next = INT( pdims(2) / 2 ) - ( pdims(2) - myidy ) |
---|
| 239 | ENDIF |
---|
| 240 | |
---|
| 241 | ENDIF |
---|
| 242 | |
---|
| 243 | local_inflow_dist = 0.0_wp |
---|
| 244 | |
---|
| 245 | CALL MPI_SENDRECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
| 246 | next, 1, local_inflow_dist(nzb,nysg,1,1), ngp_ifd, & |
---|
| 247 | MPI_REAL, prev, 1, comm1dy, status, ierr ) |
---|
| 248 | |
---|
| 249 | ENDIF |
---|
| 250 | |
---|
[151] | 251 | #endif |
---|
| 252 | |
---|
| 253 | ! |
---|
| 254 | !-- Add the disturbance at the inflow |
---|
| 255 | IF ( nxl == 0 ) THEN |
---|
[1560] | 256 | |
---|
| 257 | IF ( recycling_yshift ) THEN |
---|
[151] | 258 | |
---|
[1560] | 259 | DO j = nysg, nyng |
---|
| 260 | DO k = nzb, nzt + 1 |
---|
[151] | 261 | |
---|
[1560] | 262 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
| 263 | local_inflow_dist(k,j,1,1:nbgp) * & |
---|
| 264 | inflow_damping_factor(k) |
---|
| 265 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
| 266 | local_inflow_dist(k,j,2,1:nbgp) * & |
---|
| 267 | inflow_damping_factor(k) |
---|
| 268 | w(k,j,-nbgp:-1) = & |
---|
| 269 | local_inflow_dist(k,j,3,1:nbgp) * & |
---|
| 270 | inflow_damping_factor(k) |
---|
| 271 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
| 272 | local_inflow_dist(k,j,4,1:nbgp) * & |
---|
| 273 | inflow_damping_factor(k) |
---|
| 274 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
| 275 | local_inflow_dist(k,j,5,1:nbgp) * & |
---|
| 276 | inflow_damping_factor(k) |
---|
| 277 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0_wp ) |
---|
| 278 | |
---|
[1615] | 279 | IF ( humidity .OR. passive_scalar ) & |
---|
| 280 | q(k,j,-nbgp:-1) = mean_inflow_profiles(k,6) + & |
---|
| 281 | local_inflow_dist(k,j,6,1:nbgp) * & |
---|
| 282 | inflow_damping_factor(k) |
---|
| 283 | |
---|
[1560] | 284 | ENDDO |
---|
| 285 | ENDDO |
---|
| 286 | |
---|
| 287 | ELSE |
---|
| 288 | |
---|
| 289 | DO j = nysg, nyng |
---|
| 290 | DO k = nzb, nzt + 1 |
---|
| 291 | |
---|
[1615] | 292 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
| 293 | inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) |
---|
| 294 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
| 295 | inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) |
---|
| 296 | w(k,j,-nbgp:-1) = & |
---|
[709] | 297 | inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) |
---|
[1615] | 298 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
[667] | 299 | inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) |
---|
[1615] | 300 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
[667] | 301 | inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) |
---|
[1615] | 302 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0_wp ) |
---|
[151] | 303 | |
---|
[1615] | 304 | IF ( humidity .OR. passive_scalar ) & |
---|
| 305 | q(k,j,-nbgp:-1) = mean_inflow_profiles(k,6) + & |
---|
| 306 | inflow_dist(k,j,6,1:nbgp) * inflow_damping_factor(k) |
---|
| 307 | |
---|
[1560] | 308 | ENDDO |
---|
[151] | 309 | ENDDO |
---|
| 310 | |
---|
[1560] | 311 | ENDIF |
---|
| 312 | |
---|
[151] | 313 | ENDIF |
---|
| 314 | |
---|
[1560] | 315 | |
---|
[151] | 316 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
| 317 | |
---|
| 318 | |
---|
| 319 | END SUBROUTINE inflow_turbulence |
---|