[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 | ! ----------------- |
---|
[1093] | 22 | ! |
---|
[151] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: inflow_turbulence.f90 1310 2014-03-14 08:01:56Z heinze $ |
---|
| 27 | ! |
---|
[1093] | 28 | ! 1092 2013-02-02 11:24:22Z raasch |
---|
| 29 | ! unused variables removed |
---|
| 30 | ! |
---|
[1037] | 31 | ! 1036 2012-10-22 13:43:42Z raasch |
---|
| 32 | ! code put under GPL (PALM 3.9) |
---|
| 33 | ! |
---|
[710] | 34 | ! 709 2011-03-30 09:31:40Z raasch |
---|
| 35 | ! formatting adjustments |
---|
| 36 | ! |
---|
[668] | 37 | ! 667 2010-12-23 12:06:00Z suehring/gryschka |
---|
| 38 | ! Using nbgp recycling planes for a better resolution of the turbulent flow |
---|
| 39 | ! near the inflow. |
---|
| 40 | ! |
---|
[623] | 41 | ! 622 2010-12-10 08:08:13Z raasch |
---|
| 42 | ! optional barriers included in order to speed up collective operations |
---|
| 43 | ! |
---|
[226] | 44 | ! 222 2009-01-12 16:04:16Z letzel |
---|
| 45 | ! Bugfix for nonparallel execution |
---|
| 46 | ! |
---|
[198] | 47 | ! Initial version (2008/03/07) |
---|
[151] | 48 | ! |
---|
| 49 | ! Description: |
---|
| 50 | ! ------------ |
---|
| 51 | ! Imposing turbulence at the respective inflow using the turbulence |
---|
| 52 | ! recycling method of Kataoka and Mizuno (2002). |
---|
| 53 | !------------------------------------------------------------------------------! |
---|
| 54 | |
---|
| 55 | USE arrays_3d |
---|
| 56 | USE control_parameters |
---|
| 57 | USE cpulog |
---|
| 58 | USE grid_variables |
---|
| 59 | USE indices |
---|
| 60 | USE interfaces |
---|
| 61 | USE pegrid |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | IMPLICIT NONE |
---|
| 65 | |
---|
[1092] | 66 | INTEGER :: i, j, k, l, ngp_ifd, ngp_pr |
---|
[151] | 67 | |
---|
[667] | 68 | REAL, DIMENSION(nzb:nzt+1,5,nbgp) :: avpr, avpr_l |
---|
| 69 | REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) :: inflow_dist |
---|
[151] | 70 | |
---|
| 71 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
| 72 | |
---|
| 73 | ! |
---|
[667] | 74 | !-- Carry out spanwise averaging in the recycling plane |
---|
[151] | 75 | avpr_l = 0.0 |
---|
[667] | 76 | ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp |
---|
| 77 | ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) |
---|
[151] | 78 | |
---|
| 79 | ! |
---|
| 80 | !-- First, local averaging within the recycling domain |
---|
[667] | 81 | i = recycling_plane |
---|
[151] | 82 | |
---|
[667] | 83 | #if defined( __parallel ) |
---|
| 84 | IF ( myidx == id_recycling ) THEN |
---|
| 85 | |
---|
| 86 | DO l = 1, nbgp |
---|
[151] | 87 | DO j = nys, nyn |
---|
[667] | 88 | DO k = nzb, nzt + 1 |
---|
[151] | 89 | |
---|
[667] | 90 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 91 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 92 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 93 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 94 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[151] | 95 | |
---|
| 96 | ENDDO |
---|
| 97 | ENDDO |
---|
[667] | 98 | i = i + 1 |
---|
[151] | 99 | ENDDO |
---|
| 100 | |
---|
| 101 | ENDIF |
---|
| 102 | ! |
---|
| 103 | !-- Now, averaging over all PEs |
---|
[622] | 104 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 105 | CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & |
---|
| 106 | MPI_SUM, comm2d, ierr ) |
---|
[667] | 107 | |
---|
[151] | 108 | #else |
---|
[667] | 109 | DO l = 1, nbgp |
---|
| 110 | DO j = nys, nyn |
---|
| 111 | DO k = nzb, nzt + 1 |
---|
| 112 | |
---|
| 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) |
---|
| 118 | |
---|
| 119 | ENDDO |
---|
| 120 | ENDDO |
---|
| 121 | i = i + 1 |
---|
| 122 | ENDDO |
---|
| 123 | |
---|
[151] | 124 | avpr = avpr_l |
---|
| 125 | #endif |
---|
| 126 | |
---|
[667] | 127 | avpr = avpr / ( ny + 1 ) |
---|
[151] | 128 | ! |
---|
| 129 | !-- Calculate the disturbances at the recycling plane |
---|
| 130 | i = recycling_plane |
---|
| 131 | |
---|
[222] | 132 | #if defined( __parallel ) |
---|
[163] | 133 | IF ( myidx == id_recycling ) THEN |
---|
[667] | 134 | DO l = 1, nbgp |
---|
| 135 | DO j = nysg, nyng |
---|
| 136 | DO k = nzb, nzt + 1 |
---|
[151] | 137 | |
---|
[667] | 138 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 139 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 140 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 141 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 142 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
| 143 | |
---|
| 144 | ENDDO |
---|
[151] | 145 | ENDDO |
---|
[667] | 146 | i = i + 1 |
---|
[151] | 147 | ENDDO |
---|
| 148 | |
---|
| 149 | ENDIF |
---|
[222] | 150 | #else |
---|
[667] | 151 | DO l = 1, nbgp |
---|
| 152 | DO j = nysg, nyng |
---|
| 153 | DO k = nzb, nzt+1 |
---|
[151] | 154 | |
---|
[667] | 155 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 156 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 157 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 158 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 159 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
| 160 | |
---|
| 161 | ENDDO |
---|
[222] | 162 | ENDDO |
---|
[667] | 163 | i = i + 1 |
---|
[222] | 164 | ENDDO |
---|
| 165 | #endif |
---|
| 166 | |
---|
[151] | 167 | ! |
---|
| 168 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
| 169 | #if defined( __parallel ) |
---|
[163] | 170 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
[151] | 171 | |
---|
[667] | 172 | CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[151] | 173 | id_inflow, 1, comm1dx, ierr ) |
---|
| 174 | |
---|
[163] | 175 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
[151] | 176 | |
---|
[163] | 177 | inflow_dist = 0.0 |
---|
[667] | 178 | CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[163] | 179 | id_recycling, 1, comm1dx, status, ierr ) |
---|
[151] | 180 | |
---|
| 181 | ENDIF |
---|
| 182 | #endif |
---|
| 183 | |
---|
| 184 | ! |
---|
| 185 | !-- Add the disturbance at the inflow |
---|
| 186 | IF ( nxl == 0 ) THEN |
---|
| 187 | |
---|
[667] | 188 | DO j = nysg, nyng |
---|
| 189 | DO k = nzb, nzt + 1 |
---|
[151] | 190 | |
---|
[709] | 191 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
[667] | 192 | inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) |
---|
| 193 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
| 194 | inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) |
---|
[709] | 195 | w(k,j,-nbgp:-1) = & |
---|
| 196 | inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) |
---|
[667] | 197 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
| 198 | inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) |
---|
| 199 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
| 200 | inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) |
---|
| 201 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0 ) |
---|
[151] | 202 | |
---|
| 203 | ENDDO |
---|
| 204 | ENDDO |
---|
| 205 | |
---|
| 206 | ENDIF |
---|
| 207 | |
---|
| 208 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
| 209 | |
---|
| 210 | |
---|
| 211 | END SUBROUTINE inflow_turbulence |
---|