[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 | ! ----------------- |
---|
[1318] | 22 | ! module interfaces removed |
---|
[151] | 23 | ! |
---|
| 24 | ! Former revisions: |
---|
| 25 | ! ----------------- |
---|
| 26 | ! $Id: inflow_turbulence.f90 1318 2014-03-17 13:35:16Z raasch $ |
---|
| 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 pegrid |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | IMPLICIT NONE |
---|
| 64 | |
---|
[1092] | 65 | INTEGER :: i, j, k, l, ngp_ifd, ngp_pr |
---|
[151] | 66 | |
---|
[667] | 67 | REAL, DIMENSION(nzb:nzt+1,5,nbgp) :: avpr, avpr_l |
---|
| 68 | REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) :: inflow_dist |
---|
[151] | 69 | |
---|
| 70 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
| 71 | |
---|
| 72 | ! |
---|
[667] | 73 | !-- Carry out spanwise averaging in the recycling plane |
---|
[151] | 74 | avpr_l = 0.0 |
---|
[667] | 75 | ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp |
---|
| 76 | ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) |
---|
[151] | 77 | |
---|
| 78 | ! |
---|
| 79 | !-- First, local averaging within the recycling domain |
---|
[667] | 80 | i = recycling_plane |
---|
[151] | 81 | |
---|
[667] | 82 | #if defined( __parallel ) |
---|
| 83 | IF ( myidx == id_recycling ) THEN |
---|
| 84 | |
---|
| 85 | DO l = 1, nbgp |
---|
[151] | 86 | DO j = nys, nyn |
---|
[667] | 87 | DO k = nzb, nzt + 1 |
---|
[151] | 88 | |
---|
[667] | 89 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 90 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 91 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 92 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 93 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
[151] | 94 | |
---|
| 95 | ENDDO |
---|
| 96 | ENDDO |
---|
[667] | 97 | i = i + 1 |
---|
[151] | 98 | ENDDO |
---|
| 99 | |
---|
| 100 | ENDIF |
---|
| 101 | ! |
---|
| 102 | !-- Now, averaging over all PEs |
---|
[622] | 103 | IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) |
---|
[709] | 104 | CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & |
---|
| 105 | MPI_SUM, comm2d, ierr ) |
---|
[667] | 106 | |
---|
[151] | 107 | #else |
---|
[667] | 108 | DO l = 1, nbgp |
---|
| 109 | DO j = nys, nyn |
---|
| 110 | DO k = nzb, nzt + 1 |
---|
| 111 | |
---|
| 112 | avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) |
---|
| 113 | avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) |
---|
| 114 | avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) |
---|
| 115 | avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) |
---|
| 116 | avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) |
---|
| 117 | |
---|
| 118 | ENDDO |
---|
| 119 | ENDDO |
---|
| 120 | i = i + 1 |
---|
| 121 | ENDDO |
---|
| 122 | |
---|
[151] | 123 | avpr = avpr_l |
---|
| 124 | #endif |
---|
| 125 | |
---|
[667] | 126 | avpr = avpr / ( ny + 1 ) |
---|
[151] | 127 | ! |
---|
| 128 | !-- Calculate the disturbances at the recycling plane |
---|
| 129 | i = recycling_plane |
---|
| 130 | |
---|
[222] | 131 | #if defined( __parallel ) |
---|
[163] | 132 | IF ( myidx == id_recycling ) THEN |
---|
[667] | 133 | DO l = 1, nbgp |
---|
| 134 | DO j = nysg, nyng |
---|
| 135 | DO k = nzb, nzt + 1 |
---|
[151] | 136 | |
---|
[667] | 137 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 138 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 139 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 140 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 141 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
| 142 | |
---|
| 143 | ENDDO |
---|
[151] | 144 | ENDDO |
---|
[667] | 145 | i = i + 1 |
---|
[151] | 146 | ENDDO |
---|
| 147 | |
---|
| 148 | ENDIF |
---|
[222] | 149 | #else |
---|
[667] | 150 | DO l = 1, nbgp |
---|
| 151 | DO j = nysg, nyng |
---|
| 152 | DO k = nzb, nzt+1 |
---|
[151] | 153 | |
---|
[667] | 154 | inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) |
---|
| 155 | inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) |
---|
| 156 | inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) |
---|
| 157 | inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) |
---|
| 158 | inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) |
---|
| 159 | |
---|
| 160 | ENDDO |
---|
[222] | 161 | ENDDO |
---|
[667] | 162 | i = i + 1 |
---|
[222] | 163 | ENDDO |
---|
| 164 | #endif |
---|
| 165 | |
---|
[151] | 166 | ! |
---|
| 167 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
| 168 | #if defined( __parallel ) |
---|
[163] | 169 | IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN |
---|
[151] | 170 | |
---|
[667] | 171 | CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[151] | 172 | id_inflow, 1, comm1dx, ierr ) |
---|
| 173 | |
---|
[163] | 174 | ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN |
---|
[151] | 175 | |
---|
[163] | 176 | inflow_dist = 0.0 |
---|
[667] | 177 | CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & |
---|
[163] | 178 | id_recycling, 1, comm1dx, status, ierr ) |
---|
[151] | 179 | |
---|
| 180 | ENDIF |
---|
| 181 | #endif |
---|
| 182 | |
---|
| 183 | ! |
---|
| 184 | !-- Add the disturbance at the inflow |
---|
| 185 | IF ( nxl == 0 ) THEN |
---|
| 186 | |
---|
[667] | 187 | DO j = nysg, nyng |
---|
| 188 | DO k = nzb, nzt + 1 |
---|
[151] | 189 | |
---|
[709] | 190 | u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & |
---|
[667] | 191 | inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) |
---|
| 192 | v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & |
---|
| 193 | inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) |
---|
[709] | 194 | w(k,j,-nbgp:-1) = & |
---|
| 195 | inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) |
---|
[667] | 196 | pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & |
---|
| 197 | inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) |
---|
| 198 | e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & |
---|
| 199 | inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) |
---|
| 200 | e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0 ) |
---|
[151] | 201 | |
---|
| 202 | ENDDO |
---|
| 203 | ENDDO |
---|
| 204 | |
---|
| 205 | ENDIF |
---|
| 206 | |
---|
| 207 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
| 208 | |
---|
| 209 | |
---|
| 210 | END SUBROUTINE inflow_turbulence |
---|