[151] | 1 | SUBROUTINE inflow_turbulence |
---|
| 2 | |
---|
[1036] | 3 | !--------------------------------------------------------------------------------! |
---|
| 4 | ! This file is part of PALM. |
---|
| 5 | ! |
---|
| 6 | ! PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 7 | ! of the GNU General Public License as published by the Free Software Foundation, |
---|
| 8 | ! either version 3 of the License, or (at your option) any later 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/>. |
---|
| 16 | ! |
---|
[1310] | 17 | ! Copyright 1997-2014 Leibniz Universitaet Hannover |
---|
[1036] | 18 | !--------------------------------------------------------------------------------! |
---|
| 19 | ! |
---|
[484] | 20 | ! Current revisions: |
---|
[151] | 21 | ! ----------------- |
---|
[1321] | 22 | ! |
---|
[151] | 23 | ! |
---|
[1320] | 24 | ! module interfaces removed |
---|
[1319] | 25 | ! |
---|
[151] | 26 | ! Former revisions: |
---|
| 27 | ! ----------------- |
---|
| 28 | ! $Id: inflow_turbulence.f90 1321 2014-03-20 09:40:40Z heinze $ |
---|
| 29 | ! |
---|
[1321] | 30 | ! 1320 2014-03-20 08:40:49Z raasch |
---|
| 31 | ! ONLY-attribute added to USE-statements, |
---|
| 32 | ! kind-parameters added to all INTEGER and REAL declaration statements, |
---|
| 33 | ! kinds are defined in new module kinds, |
---|
| 34 | ! revision history before 2012 removed, |
---|
| 35 | ! comment fields (!:) to be used for variable explanations added to |
---|
| 36 | ! all variable declaration statements |
---|
| 37 | ! |
---|
[1093] | 38 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 39 | ! unused variables removed |
---|
| 40 | ! |
---|
[1037] | 41 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 42 | ! code put under GPL (PALM 3.9) |
---|
| 43 | ! |
---|
[198] | 44 | ! Initial version (2008/03/07) |
---|
[151] | 45 | ! |
---|
| 46 | ! Description: |
---|
| 47 | ! ------------ |
---|
| 48 | ! Imposing turbulence at the respective inflow using the turbulence |
---|
| 49 | ! recycling method of Kataoka and Mizuno (2002). |
---|
| 50 | !------------------------------------------------------------------------------! |
---|
| 51 | |
---|
[1320] | 52 | USE arrays_3d, & |
---|
| 53 | ONLY: e, inflow_damping_factor, mean_inflow_profiles, pt, u, v, w |
---|
| 54 | |
---|
| 55 | USE control_parameters, & |
---|
| 56 | ONLY: recycling_plane |
---|
| 57 | |
---|
| 58 | USE cpulog, & |
---|
| 59 | ONLY: cpu_log, log_point |
---|
| 60 | |
---|
| 61 | USE grid_variables, & |
---|
| 62 | ONLY: |
---|
| 63 | |
---|
| 64 | USE indices, & |
---|
| 65 | ONLY: nbgp, nxl, ny, nyn, nys, nyng, nysg, nzb, nzt |
---|
| 66 | |
---|
| 67 | USE kinds |
---|
| 68 | |
---|
[151] | 69 | USE pegrid |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | IMPLICIT NONE |
---|
| 73 | |
---|
[1320] | 74 | INTEGER(iwp) :: i !: |
---|
| 75 | INTEGER(iwp) :: j !: |
---|
| 76 | INTEGER(iwp) :: k !: |
---|
| 77 | INTEGER(iwp) :: l !: |
---|
| 78 | INTEGER(iwp) :: ngp_ifd !: |
---|
| 79 | INTEGER(iwp) :: ngp_pr !: |
---|
[151] | 80 | |
---|
[1320] | 81 | REAL(wp), DIMENSION(nzb:nzt+1,5,nbgp) :: & |
---|
| 82 | avpr, avpr_l !: |
---|
| 83 | REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) :: & |
---|
| 84 | inflow_dist !: |
---|
[151] | 85 | |
---|
| 86 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
| 87 | |
---|
| 88 | ! |
---|
[667] | 89 | !-- Carry out spanwise averaging in the recycling plane |
---|
[151] | 90 | avpr_l = 0.0 |
---|
[667] | 91 | ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp |
---|
| 92 | ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) |
---|
[151] | 93 | |
---|
| 94 | ! |
---|
| 95 | !-- First, local averaging within the recycling domain |
---|
[667] | 96 | i = recycling_plane |
---|
[151] | 97 | |
---|
[667] | 98 | #if defined( __parallel ) |
---|
| 99 | IF ( myidx == id_recycling ) THEN |
---|
| 100 | |
---|
| 101 | DO l = 1, nbgp |
---|
[151] | 102 | DO j = nys, nyn |
---|
[667] | 103 | DO k = nzb, nzt + 1 |
---|
[151] | 104 | |
---|
[667] | 105 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 106 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 107 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 108 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 109 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[151] | 110 | |
---|
| 111 | ENDDO |
---|
| 112 | ENDDO |
---|
[667] | 113 | i = i + 1 |
---|
[151] | 114 | ENDDO |
---|
| 115 | |
---|
| 116 | ENDIF |
---|
| 117 | ! |
---|
| 118 | !-- Now, averaging over all PEs |
---|
[622] | 119 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 120 | CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & |
---|
| 121 | MPI_SUM, comm2d, ierr ) |
---|
[667] | 122 | |
---|
[151] | 123 | #else |
---|
[667] | 124 | DO l = 1, nbgp |
---|
| 125 | DO j = nys, nyn |
---|
| 126 | DO k = nzb, nzt + 1 |
---|
| 127 | |
---|
| 128 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 129 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 130 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 131 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 132 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
| 133 | |
---|
| 134 | ENDDO |
---|
| 135 | ENDDO |
---|
| 136 | i = i + 1 |
---|
| 137 | ENDDO |
---|
| 138 | |
---|
[151] | 139 | avpr = avpr_l |
---|
| 140 | #endif |
---|
| 141 | |
---|
[667] | 142 | avpr = avpr / ( ny + 1 ) |
---|
[151] | 143 | ! |
---|
| 144 | !-- Calculate the disturbances at the recycling plane |
---|
| 145 | i = recycling_plane |
---|
| 146 | |
---|
[222] | 147 | #if defined( __parallel ) |
---|
[163] | 148 | IF ( myidx == id_recycling ) THEN |
---|
[667] | 149 | DO l = 1, nbgp |
---|
| 150 | DO j = nysg, nyng |
---|
| 151 | DO k = nzb, nzt + 1 |
---|
[151] | 152 | |
---|
[667] | 153 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 154 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 155 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 156 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 157 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
| 158 | |
---|
| 159 | ENDDO |
---|
[151] | 160 | ENDDO |
---|
[667] | 161 | i = i + 1 |
---|
[151] | 162 | ENDDO |
---|
| 163 | |
---|
| 164 | ENDIF |
---|
[222] | 165 | #else |
---|
[667] | 166 | DO l = 1, nbgp |
---|
| 167 | DO j = nysg, nyng |
---|
| 168 | DO k = nzb, nzt+1 |
---|
[151] | 169 | |
---|
[667] | 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) |
---|
| 173 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 174 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
| 175 | |
---|
| 176 | ENDDO |
---|
[222] | 177 | ENDDO |
---|
[667] | 178 | i = i + 1 |
---|
[222] | 179 | ENDDO |
---|
| 180 | #endif |
---|
| 181 | |
---|
[151] | 182 | ! |
---|
| 183 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
| 184 | #if defined( __parallel ) |
---|
[163] | 185 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
[151] | 186 | |
---|
[667] | 187 | CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[151] | 188 | id_inflow, 1, comm1dx, ierr ) |
---|
| 189 | |
---|
[163] | 190 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
[151] | 191 | |
---|
[163] | 192 | inflow_dist = 0.0 |
---|
[667] | 193 | CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[163] | 194 | id_recycling, 1, comm1dx, status, ierr ) |
---|
[151] | 195 | |
---|
| 196 | ENDIF |
---|
| 197 | #endif |
---|
| 198 | |
---|
| 199 | ! |
---|
| 200 | !-- Add the disturbance at the inflow |
---|
| 201 | IF ( nxl == 0 ) THEN |
---|
| 202 | |
---|
[667] | 203 | DO j = nysg, nyng |
---|
| 204 | DO k = nzb, nzt + 1 |
---|
[151] | 205 | |
---|
[709] | 206 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
[667] | 207 | inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) |
---|
| 208 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
| 209 | inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) |
---|
[709] | 210 | w(k,j,-nbgp:-1) = & |
---|
| 211 | inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) |
---|
[667] | 212 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
| 213 | inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) |
---|
| 214 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
| 215 | inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) |
---|
| 216 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0 ) |
---|
[151] | 217 | |
---|
| 218 | ENDDO |
---|
| 219 | ENDDO |
---|
| 220 | |
---|
| 221 | ENDIF |
---|
| 222 | |
---|
| 223 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
| 224 | |
---|
| 225 | |
---|
| 226 | END SUBROUTINE inflow_turbulence |
---|