[1682] | 1 | !> @file inflow_turbulence.f90 |
---|
[2000] | 2 | !------------------------------------------------------------------------------! |
---|
[2696] | 3 | ! This file is part of the PALM model system. |
---|
[1036] | 4 | ! |
---|
[2000] | 5 | ! PALM is free software: you can redistribute it and/or modify it under the |
---|
| 6 | ! terms of the GNU General Public License as published by the Free Software |
---|
| 7 | ! Foundation, either version 3 of the License, or (at your option) any later |
---|
| 8 | ! version. |
---|
[1036] | 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 | ! |
---|
[4360] | 17 | ! Copyright 1997-2020 Leibniz Universitaet Hannover |
---|
[2000] | 18 | !------------------------------------------------------------------------------! |
---|
[1036] | 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[151] | 21 | ! ----------------- |
---|
[1354] | 22 | ! |
---|
[2001] | 23 | ! |
---|
[151] | 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: inflow_turbulence.f90 4429 2020-02-27 15:24:30Z suehring $ |
---|
[4429] | 27 | ! bugfix: cpp-directives added for serial mode |
---|
| 28 | ! |
---|
| 29 | ! 4360 2020-01-07 11:25:50Z suehring |
---|
[4301] | 30 | ! use y_shift instead of old parameter recycling_yshift |
---|
| 31 | ! |
---|
| 32 | ! 4297 2019-11-21 10:37:50Z oliver.maas |
---|
[4297] | 33 | ! changed recycling_yshift so that the y-shift can be a multiple of PE |
---|
| 34 | ! instead of y-shift of a half domain width |
---|
| 35 | ! |
---|
| 36 | ! 4183 2019-08-23 07:33:16Z oliver.maas |
---|
[4183] | 37 | ! simplified steering of recycling of absolute values by initialization |
---|
| 38 | ! parameter recycling_method_for_thermodynamic_quantities |
---|
| 39 | ! |
---|
| 40 | ! 4182 2019-08-22 15:20:23Z scharf |
---|
[4182] | 41 | ! Corrected "Former revisions" section |
---|
| 42 | ! |
---|
| 43 | ! 4172 2019-08-20 11:55:33Z oliver.maas |
---|
[4172] | 44 | ! added optional recycling of absolute values for pt and q |
---|
| 45 | ! |
---|
| 46 | ! 3655 2019-01-07 16:51:22Z knoop |
---|
[2716] | 47 | ! Corrected "Former revisions" section |
---|
[151] | 48 | ! |
---|
[4182] | 49 | ! Initial version (2008/03/07) |
---|
| 50 | ! |
---|
[151] | 51 | ! Description: |
---|
| 52 | ! ------------ |
---|
[1682] | 53 | !> Imposing turbulence at the respective inflow using the turbulence |
---|
| 54 | !> recycling method of Kataoka and Mizuno (2002). |
---|
[151] | 55 | !------------------------------------------------------------------------------! |
---|
[1682] | 56 | SUBROUTINE inflow_turbulence |
---|
| 57 | |
---|
[151] | 58 | |
---|
[1320] | 59 | USE arrays_3d, & |
---|
[1960] | 60 | ONLY: e, inflow_damping_factor, mean_inflow_profiles, pt, q, s, u, v, w |
---|
[1320] | 61 | |
---|
[4429] | 62 | #if defined( __parallel ) |
---|
[1320] | 63 | USE control_parameters, & |
---|
[4429] | 64 | ONLY: humidity, passive_scalar, recycling_plane, y_shift, & |
---|
[4183] | 65 | recycling_method_for_thermodynamic_quantities |
---|
[4429] | 66 | #else |
---|
| 67 | USE control_parameters, & |
---|
| 68 | ONLY: humidity, passive_scalar, recycling_plane, & |
---|
| 69 | recycling_method_for_thermodynamic_quantities |
---|
| 70 | #endif |
---|
[1320] | 71 | |
---|
| 72 | USE cpulog, & |
---|
| 73 | ONLY: cpu_log, log_point |
---|
| 74 | |
---|
| 75 | USE indices, & |
---|
| 76 | ONLY: nbgp, nxl, ny, nyn, nys, nyng, nysg, nzb, nzt |
---|
| 77 | |
---|
| 78 | USE kinds |
---|
| 79 | |
---|
[151] | 80 | USE pegrid |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | IMPLICIT NONE |
---|
[4172] | 84 | |
---|
[1806] | 85 | INTEGER(iwp) :: i !< loop index |
---|
| 86 | INTEGER(iwp) :: j !< loop index |
---|
| 87 | INTEGER(iwp) :: k !< loop index |
---|
| 88 | INTEGER(iwp) :: l !< loop index |
---|
| 89 | INTEGER(iwp) :: ngp_ifd !< number of grid points stored in avpr |
---|
| 90 | INTEGER(iwp) :: ngp_pr !< number of grid points stored in inflow_dist |
---|
[4429] | 91 | #if defined( __parallel ) |
---|
| 92 | INTEGER(iwp) :: next !< ID of receiving PE for y-shift |
---|
[1806] | 93 | INTEGER(iwp) :: prev !< ID of sending PE for y-shift |
---|
[4429] | 94 | #endif |
---|
[151] | 95 | |
---|
[1960] | 96 | REAL(wp), DIMENSION(nzb:nzt+1,7,nbgp) :: & |
---|
[1806] | 97 | avpr !< stores averaged profiles at recycling plane |
---|
[1960] | 98 | REAL(wp), DIMENSION(nzb:nzt+1,7,nbgp) :: & |
---|
[1806] | 99 | avpr_l !< auxiliary variable to calculate avpr |
---|
[1960] | 100 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: & |
---|
[1806] | 101 | inflow_dist !< turbulence signal of vars, added at inflow boundary |
---|
[4429] | 102 | #if defined( __parallel ) |
---|
[1960] | 103 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: & |
---|
[4301] | 104 | local_inflow_dist !< auxiliary variable for inflow_dist, used for y-shift |
---|
[4429] | 105 | #endif |
---|
[4172] | 106 | |
---|
[151] | 107 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
[4172] | 108 | |
---|
[151] | 109 | ! |
---|
[667] | 110 | !-- Carry out spanwise averaging in the recycling plane |
---|
[1353] | 111 | avpr_l = 0.0_wp |
---|
[1960] | 112 | ngp_pr = ( nzt - nzb + 2 ) * 7 * nbgp |
---|
[667] | 113 | ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) |
---|
[151] | 114 | |
---|
| 115 | ! |
---|
| 116 | !-- First, local averaging within the recycling domain |
---|
[667] | 117 | i = recycling_plane |
---|
[151] | 118 | |
---|
[667] | 119 | #if defined( __parallel ) |
---|
| 120 | IF ( myidx == id_recycling ) THEN |
---|
| 121 | |
---|
| 122 | DO l = 1, nbgp |
---|
[151] | 123 | DO j = nys, nyn |
---|
[667] | 124 | DO k = nzb, nzt + 1 |
---|
[151] | 125 | |
---|
[667] | 126 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 127 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 128 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 129 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 130 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[1960] | 131 | IF ( humidity ) & |
---|
[1615] | 132 | avpr_l(k,6,l) = avpr_l(k,6,l) + q(k,j,i) |
---|
[1960] | 133 | IF ( passive_scalar ) & |
---|
| 134 | avpr_l(k,7,l) = avpr_l(k,7,l) + s(k,j,i) |
---|
[151] | 135 | |
---|
| 136 | ENDDO |
---|
| 137 | ENDDO |
---|
[667] | 138 | i = i + 1 |
---|
[151] | 139 | ENDDO |
---|
| 140 | |
---|
| 141 | ENDIF |
---|
| 142 | ! |
---|
| 143 | !-- Now, averaging over all PEs |
---|
[622] | 144 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[1615] | 145 | CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & |
---|
[709] | 146 | MPI_SUM, comm2d, ierr ) |
---|
[667] | 147 | |
---|
[151] | 148 | #else |
---|
[667] | 149 | DO l = 1, nbgp |
---|
| 150 | DO j = nys, nyn |
---|
| 151 | DO k = nzb, nzt + 1 |
---|
| 152 | |
---|
| 153 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 154 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 155 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 156 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 157 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[1960] | 158 | IF ( humidity ) & |
---|
[1615] | 159 | avpr_l(k,6,l) = avpr_l(k,6,l) + q(k,j,i) |
---|
[1960] | 160 | IF ( passive_scalar ) & |
---|
| 161 | avpr_l(k,7,l) = avpr_l(k,7,l) + s(k,j,i) |
---|
[667] | 162 | |
---|
| 163 | ENDDO |
---|
| 164 | ENDDO |
---|
| 165 | i = i + 1 |
---|
| 166 | ENDDO |
---|
| 167 | |
---|
[151] | 168 | avpr = avpr_l |
---|
| 169 | #endif |
---|
| 170 | |
---|
[667] | 171 | avpr = avpr / ( ny + 1 ) |
---|
[151] | 172 | ! |
---|
| 173 | !-- Calculate the disturbances at the recycling plane |
---|
[4172] | 174 | !-- for recycling of absolute quantities, the disturbance is defined as the absolute value |
---|
| 175 | !-- (and not as the deviation from the mean profile) |
---|
[151] | 176 | i = recycling_plane |
---|
| 177 | |
---|
[222] | 178 | #if defined( __parallel ) |
---|
[163] | 179 | IF ( myidx == id_recycling ) THEN |
---|
[667] | 180 | DO l = 1, nbgp |
---|
| 181 | DO j = nysg, nyng |
---|
| 182 | DO k = nzb, nzt + 1 |
---|
| 183 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 184 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 185 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
[4183] | 186 | IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 187 | == 'turbulent_fluctuation' ) THEN |
---|
| 188 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 189 | ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 190 | == 'absolute_value' ) THEN |
---|
[4172] | 191 | inflow_dist(k,j,4,l) = pt(k,j,i) |
---|
| 192 | ENDIF |
---|
[667] | 193 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
[4172] | 194 | IF ( humidity ) THEN |
---|
[4183] | 195 | IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 196 | == 'turbulent_fluctuation' ) THEN |
---|
| 197 | inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l) |
---|
| 198 | ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 199 | == 'absolute_value' ) THEN |
---|
[4172] | 200 | inflow_dist(k,j,6,l) = q(k,j,i) |
---|
| 201 | ENDIF |
---|
| 202 | ENDIF |
---|
[1960] | 203 | IF ( passive_scalar ) & |
---|
| 204 | inflow_dist(k,j,7,l) = s(k,j,i) - avpr(k,7,l) |
---|
[667] | 205 | ENDDO |
---|
[151] | 206 | ENDDO |
---|
[667] | 207 | i = i + 1 |
---|
[151] | 208 | ENDDO |
---|
| 209 | |
---|
| 210 | ENDIF |
---|
[222] | 211 | #else |
---|
[667] | 212 | DO l = 1, nbgp |
---|
| 213 | DO j = nysg, nyng |
---|
| 214 | DO k = nzb, nzt+1 |
---|
| 215 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 216 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 217 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
[4183] | 218 | IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 219 | == 'turbulent_fluctuation' ) THEN |
---|
| 220 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 221 | ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 222 | == 'absolute_value' ) THEN |
---|
[4172] | 223 | inflow_dist(k,j,4,l) = pt(k,j,i) |
---|
| 224 | ENDIF |
---|
[667] | 225 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
[4172] | 226 | IF ( humidity ) THEN |
---|
[4183] | 227 | IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 228 | == 'turbulent_fluctuation' ) THEN |
---|
| 229 | inflow_dist(k,j,6,l) = q(k,j,i) - avpr(k,6,l) |
---|
| 230 | ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 231 | == 'absolute_value' ) THEN |
---|
[4172] | 232 | inflow_dist(k,j,6,l) = q(k,j,i) |
---|
| 233 | ENDIF |
---|
| 234 | ENDIF |
---|
[1960] | 235 | IF ( passive_scalar ) & |
---|
| 236 | inflow_dist(k,j,7,l) = s(k,j,i) - avpr(k,7,l) |
---|
[667] | 237 | |
---|
| 238 | ENDDO |
---|
[222] | 239 | ENDDO |
---|
[667] | 240 | i = i + 1 |
---|
[222] | 241 | ENDDO |
---|
| 242 | #endif |
---|
| 243 | |
---|
[151] | 244 | ! |
---|
| 245 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
| 246 | #if defined( __parallel ) |
---|
[163] | 247 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
[151] | 248 | |
---|
[1560] | 249 | CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[151] | 250 | id_inflow, 1, comm1dx, ierr ) |
---|
| 251 | |
---|
[163] | 252 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
[151] | 253 | |
---|
[1353] | 254 | inflow_dist = 0.0_wp |
---|
[1560] | 255 | CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[163] | 256 | id_recycling, 1, comm1dx, status, ierr ) |
---|
[151] | 257 | |
---|
| 258 | ENDIF |
---|
[1560] | 259 | |
---|
[1806] | 260 | ! |
---|
| 261 | !-- y-shift for inflow_dist |
---|
[4297] | 262 | !-- Shift inflow_dist in positive y direction by a number of |
---|
[4301] | 263 | !-- PEs equal to y_shift |
---|
| 264 | IF ( ( y_shift /= 0 ) .AND. myidx == id_inflow ) THEN |
---|
[4297] | 265 | |
---|
[1806] | 266 | ! |
---|
| 267 | !-- Calculate the ID of the PE which sends data to this PE (prev) and of the |
---|
| 268 | !-- PE which receives data from this PE (next). |
---|
[4301] | 269 | prev = MODULO(myidy - y_shift , pdims(2)) |
---|
| 270 | next = MODULO(myidy + y_shift , pdims(2)) |
---|
[4297] | 271 | |
---|
[1560] | 272 | local_inflow_dist = 0.0_wp |
---|
[1806] | 273 | |
---|
[1560] | 274 | CALL MPI_SENDRECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
| 275 | next, 1, local_inflow_dist(nzb,nysg,1,1), ngp_ifd, & |
---|
| 276 | MPI_REAL, prev, 1, comm1dy, status, ierr ) |
---|
[1806] | 277 | |
---|
| 278 | inflow_dist = local_inflow_dist |
---|
| 279 | |
---|
[1560] | 280 | ENDIF |
---|
| 281 | |
---|
[151] | 282 | #endif |
---|
| 283 | |
---|
| 284 | ! |
---|
| 285 | !-- Add the disturbance at the inflow |
---|
| 286 | IF ( nxl == 0 ) THEN |
---|
| 287 | |
---|
[1806] | 288 | DO j = nysg, nyng |
---|
| 289 | DO k = nzb, nzt + 1 |
---|
[151] | 290 | |
---|
[4183] | 291 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
[1806] | 292 | inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) |
---|
[4183] | 293 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
[1806] | 294 | inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) |
---|
[4183] | 295 | w(k,j,-nbgp:-1) = & |
---|
[1806] | 296 | inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) |
---|
[4183] | 297 | IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 298 | == 'turbulent_fluctuation' ) THEN |
---|
| 299 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
| 300 | inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) |
---|
| 301 | ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 302 | == 'absolute_value' ) THEN |
---|
[4172] | 303 | pt(k,j,-nbgp:-1) = inflow_dist(k,j,4,1:nbgp) |
---|
| 304 | ENDIF |
---|
[4183] | 305 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
[1806] | 306 | inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) |
---|
| 307 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0_wp ) |
---|
[4172] | 308 | IF ( humidity ) THEN |
---|
[4183] | 309 | IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 310 | == 'turbulent_fluctuation' ) THEN |
---|
| 311 | q(k,j,-nbgp:-1) = mean_inflow_profiles(k,6) + & |
---|
| 312 | inflow_dist(k,j,6,1:nbgp) * inflow_damping_factor(k) |
---|
| 313 | ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & |
---|
| 314 | == 'absolute_value' ) THEN |
---|
[4172] | 315 | q(k,j,-nbgp:-1) = inflow_dist(k,j,6,1:nbgp) |
---|
| 316 | ENDIF |
---|
| 317 | ENDIF |
---|
[4183] | 318 | IF ( passive_scalar ) & |
---|
| 319 | s(k,j,-nbgp:-1) = mean_inflow_profiles(k,7) + & |
---|
[1960] | 320 | inflow_dist(k,j,7,1:nbgp) * inflow_damping_factor(k) |
---|
[4183] | 321 | |
---|
[1560] | 322 | ENDDO |
---|
[1806] | 323 | ENDDO |
---|
[1560] | 324 | |
---|
[151] | 325 | ENDIF |
---|
| 326 | |
---|
[1560] | 327 | |
---|
[151] | 328 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
| 329 | |
---|
| 330 | |
---|
| 331 | END SUBROUTINE inflow_turbulence |
---|