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