Changeset 4646 for palm/trunk/SOURCE/inflow_turbulence.f90
- Timestamp:
- Aug 24, 2020 4:02:40 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SOURCE/inflow_turbulence.f90
r4429 r4646 1 1 !> @file inflow_turbulence.f90 2 !------------------------------------------------------------------------------ !2 !--------------------------------------------------------------------------------------------------! 3 3 ! This file is part of the PALM model system. 4 4 ! 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. 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/>. 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. 8 ! 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. 12 ! 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/>. 16 15 ! 17 16 ! Copyright 1997-2020 Leibniz Universitaet Hannover 18 !------------------------------------------------------------------------------ !17 !--------------------------------------------------------------------------------------------------! 19 18 ! 20 19 ! Current revisions: 21 20 ! ----------------- 22 ! 23 ! 21 ! 22 ! 24 23 ! Former revisions: 25 24 ! ----------------- 26 25 ! $Id$ 26 ! file re-formatted to follow the PALM coding standard 27 ! 28 ! 4429 2020-02-27 15:24:30Z raasch 27 29 ! bugfix: cpp-directives added for serial mode 28 ! 30 ! 29 31 ! 4360 2020-01-07 11:25:50Z suehring 30 32 ! use y_shift instead of old parameter recycling_yshift 31 ! 33 ! 32 34 ! 4297 2019-11-21 10:37:50Z oliver.maas 33 ! changed recycling_yshift so that the y-shift can be a multiple of PE 34 ! instead of y-shift of a halfdomain width35 ! 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 ! 36 38 ! 4183 2019-08-23 07:33:16Z oliver.maas 37 ! simplified steering of recycling of absolute values by initialization 38 ! parameterrecycling_method_for_thermodynamic_quantities39 ! 39 ! simplified steering of recycling of absolute values by initialization parameter 40 ! recycling_method_for_thermodynamic_quantities 41 ! 40 42 ! 4182 2019-08-22 15:20:23Z scharf 41 43 ! Corrected "Former revisions" section 42 ! 44 ! 43 45 ! 4172 2019-08-20 11:55:33Z oliver.maas 44 46 ! added optional recycling of absolute values for pt and q 45 ! 47 ! 46 48 ! 3655 2019-01-07 16:51:22Z knoop 47 49 ! Corrected "Former revisions" section … … 51 53 ! Description: 52 54 ! ------------ 53 !> Imposing turbulence at the respective inflow using the turbulence 54 !> recycling method ofKataoka and Mizuno (2002).55 !------------------------------------------------------------------------------ !55 !> Imposing turbulence at the respective inflow using the turbulence recycling method of 56 !> Kataoka and Mizuno (2002). 57 !--------------------------------------------------------------------------------------------------! 56 58 SUBROUTINE inflow_turbulence 57 58 59 USE arrays_3d, &59 60 61 USE arrays_3d, & 60 62 ONLY: e, inflow_damping_factor, mean_inflow_profiles, pt, q, s, u, v, w 61 62 #if defined( __parallel ) 63 USE control_parameters, & 64 ONLY: humidity, passive_scalar, recycling_plane, y_shift, & 65 recycling_method_for_thermodynamic_quantities 63 64 #if defined( __parallel ) 65 USE control_parameters, & 66 ONLY: humidity, passive_scalar, recycling_method_for_thermodynamic_quantities, & 67 recycling_plane, y_shift 68 66 69 #else 67 USE control_parameters, & 68 ONLY: humidity, passive_scalar, recycling_plane, & 69 recycling_method_for_thermodynamic_quantities 70 #endif 71 72 USE cpulog, & 70 USE control_parameters, & 71 ONLY: humidity, passive_scalar, recycling_method_for_thermodynamic_quantities, & 72 recycling_plane 73 74 #endif 75 76 USE cpulog, & 73 77 ONLY: cpu_log, log_point 74 75 USE indices, &78 79 USE indices, & 76 80 ONLY: nbgp, nxl, ny, nyn, nys, nyng, nysg, nzb, nzt 77 81 78 82 USE kinds 79 83 80 84 USE pegrid 81 85 82 86 83 87 IMPLICIT NONE 84 88 85 89 INTEGER(iwp) :: i !< loop index 86 90 INTEGER(iwp) :: j !< loop index … … 94 98 #endif 95 99 96 REAL(wp), DIMENSION(nzb:nzt+1,7,nbgp) :: & 97 avpr !< stores averaged profiles at recycling plane 98 REAL(wp), DIMENSION(nzb:nzt+1,7,nbgp) :: & 99 avpr_l !< auxiliary variable to calculate avpr 100 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: & 101 inflow_dist !< turbulence signal of vars, added at inflow boundary 102 #if defined( __parallel ) 103 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: & 104 local_inflow_dist !< auxiliary variable for inflow_dist, used for y-shift 105 #endif 106 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 104 #if defined( __parallel ) 105 REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) :: local_inflow_dist !< auxiliary variable for inflow_dist, used for y-shift 106 #endif 107 107 108 CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) 108 109 109 110 ! 110 111 !-- Carry out spanwise averaging in the recycling plane … … 119 120 #if defined( __parallel ) 120 121 IF ( myidx == id_recycling ) THEN 121 122 122 123 DO l = 1, nbgp 123 124 DO j = nys, nyn … … 129 130 avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) 130 131 avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) 131 IF ( humidity ) & 132 avpr_l(k,6,l) = avpr_l(k,6,l) + q(k,j,i) 133 IF ( passive_scalar ) & 134 avpr_l(k,7,l) = avpr_l(k,7,l) + s(k,j,i) 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) 135 134 136 135 ENDDO … … 143 142 !-- Now, averaging over all PEs 144 143 IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) 145 CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & 146 MPI_SUM, comm2d, ierr ) 144 CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, MPI_SUM, comm2d, ierr ) 147 145 148 146 #else … … 156 154 avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) 157 155 avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) 158 IF ( humidity ) & 159 avpr_l(k,6,l) = avpr_l(k,6,l) + q(k,j,i) 160 IF ( passive_scalar ) & 161 avpr_l(k,7,l) = avpr_l(k,7,l) + s(k,j,i) 162 163 ENDDO 164 ENDDO 165 i = i + 1 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) 158 159 ENDDO 160 ENDDO 161 i = i + 1 166 162 ENDDO 167 163 168 164 avpr = avpr_l 169 165 #endif … … 171 167 avpr = avpr / ( ny + 1 ) 172 168 ! 173 !-- Calculate the disturbances at the recycling plane 174 !-- for recycling of absolute quantities, the disturbance is defined as the absolute value 175 !-- (and not as the deviation from the mean profile) 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). 176 171 i = recycling_plane 177 172 … … 184 179 inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) 185 180 inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) 186 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) &187 == 'turbulent_fluctuation' ) THEN181 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 182 == 'turbulent_fluctuation' ) THEN 188 183 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' ) THEN184 ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 185 == 'absolute_value' ) THEN 191 186 inflow_dist(k,j,4,l) = pt(k,j,i) 192 187 ENDIF 193 188 inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) 194 189 IF ( humidity ) THEN 195 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) &196 == 'turbulent_fluctuation' ) THEN190 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 191 == 'turbulent_fluctuation' ) THEN 197 192 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' ) THEN193 ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 194 == 'absolute_value' ) THEN 200 195 inflow_dist(k,j,6,l) = q(k,j,i) 201 196 ENDIF 202 197 ENDIF 203 IF ( passive_scalar ) &198 IF ( passive_scalar ) & 204 199 inflow_dist(k,j,7,l) = s(k,j,i) - avpr(k,7,l) 205 200 ENDDO … … 216 211 inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) 217 212 inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) 218 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) &213 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 219 214 == 'turbulent_fluctuation' ) THEN 220 215 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' ) THEN216 ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 217 == 'absolute_value' ) THEN 223 218 inflow_dist(k,j,4,l) = pt(k,j,i) 224 219 ENDIF 225 220 inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) 226 221 IF ( humidity ) THEN 227 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) &228 222 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 223 == 'turbulent_fluctuation' ) THEN 229 224 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' ) THEN225 ELSEIF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 226 == 'absolute_value' ) THEN 232 227 inflow_dist(k,j,6,l) = q(k,j,i) 233 228 ENDIF 234 229 ENDIF 235 IF ( passive_scalar ) &230 IF ( passive_scalar ) & 236 231 inflow_dist(k,j,7,l) = s(k,j,i) - avpr(k,7,l) 237 232 238 233 ENDDO 239 234 ENDDO … … 247 242 IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN 248 243 249 CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & 250 id_inflow, 1, comm1dx, ierr ) 244 CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, id_inflow, 1, comm1dx, ierr ) 251 245 252 246 ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN 253 247 254 248 inflow_dist = 0.0_wp 255 CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, 256 id_recycling, 1, comm1dx,status, ierr )249 CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, id_recycling, 1, comm1dx, & 250 status, ierr ) 257 251 258 252 ENDIF … … 262 256 !-- Shift inflow_dist in positive y direction by a number of 263 257 !-- PEs equal to y_shift 264 IF ( ( y_shift /= 0 ) .AND. myidx == id_inflow )THEN265 266 ! 267 !-- Calculate the ID of the PE which sends data to this PE (prev) and of the 268 !-- PE which receivesdata from this PE (next).258 IF ( ( y_shift /= 0 ) .AND. myidx == id_inflow ) THEN 259 260 ! 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). 269 263 prev = MODULO(myidy - y_shift , pdims(2)) 270 264 next = MODULO(myidy + y_shift , pdims(2)) 271 265 272 266 local_inflow_dist = 0.0_wp 273 267 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 )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 ) 277 271 278 272 inflow_dist = local_inflow_dist … … 289 283 DO k = nzb, nzt + 1 290 284 291 u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & 292 inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) 293 v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & 294 inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) 295 w(k,j,-nbgp:-1) = & 296 inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) 297 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 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 ) & 298 291 == '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' ) THEN292 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 303 296 pt(k,j,-nbgp:-1) = inflow_dist(k,j,4,1:nbgp) 304 297 ENDIF 305 e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + &306 inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k)298 e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & 299 inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) 307 300 e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0_wp ) 308 301 IF ( humidity ) THEN 309 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) &302 IF ( TRIM( recycling_method_for_thermodynamic_quantities ) & 310 303 == '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' ) THEN304 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 315 308 q(k,j,-nbgp:-1) = inflow_dist(k,j,6,1:nbgp) 316 309 ENDIF 317 310 ENDIF 318 IF ( passive_scalar ) &319 s(k,j,-nbgp:-1) = mean_inflow_profiles(k,7) + &320 inflow_dist(k,j,7,1:nbgp) * inflow_damping_factor(k)321 322 ENDDO 323 ENDDO 324 325 ENDIF 326 327 328 CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' )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 315 ENDDO 316 ENDDO 317 318 ENDIF 319 320 321 CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) 329 322 330 323
Note: See TracChangeset
for help on using the changeset viewer.