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