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