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