SUBROUTINE inflow_turbulence !------------------------------------------------------------------------------! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: inflow_turbulence.f90 710 2011-03-30 09:45:27Z fricke $ ! ! 709 2011-03-30 09:31:40Z raasch ! formatting adjustments ! ! 667 2010-12-23 12:06:00Z suehring/gryschka ! Using nbgp recycling planes for a better resolution of the turbulent flow ! near the inflow. ! ! 622 2010-12-10 08:08:13Z raasch ! optional barriers included in order to speed up collective operations ! ! 222 2009-01-12 16:04:16Z letzel ! Bugfix for nonparallel execution ! ! Initial version (2008/03/07) ! ! Description: ! ------------ ! Imposing turbulence at the respective inflow using the turbulence ! recycling method of Kataoka and Mizuno (2002). !------------------------------------------------------------------------------! USE arrays_3d USE control_parameters USE cpulog USE grid_variables USE indices USE interfaces USE pegrid IMPLICIT NONE INTEGER :: i, imax, j, k, l, ngp_ifd, ngp_pr REAL, DIMENSION(1:2) :: volume_flow_l, volume_flow_offset REAL, DIMENSION(nzb:nzt+1,5,nbgp) :: avpr, avpr_l REAL, DIMENSION(nzb:nzt+1,nysg:nyng,5,nbgp) :: inflow_dist CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) ! !-- Carry out spanwise averaging in the recycling plane avpr_l = 0.0 ngp_pr = ( nzt - nzb + 2 ) * 5 * nbgp ngp_ifd = ngp_pr * ( nyn - nys + 1 + 2 * nbgp ) ! !-- First, local averaging within the recycling domain i = recycling_plane #if defined( __parallel ) IF ( myidx == id_recycling ) THEN DO l = 1, nbgp DO j = nys, nyn DO k = nzb, nzt + 1 avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) ENDDO ENDDO i = i + 1 ENDDO ENDIF ! !-- Now, averaging over all PEs IF ( collective_wait ) CALL MPI_BARRIER( comm2d, ierr ) CALL MPI_ALLREDUCE( avpr_l(nzb,1,1), avpr(nzb,1,1), ngp_pr, MPI_REAL, & MPI_SUM, comm2d, ierr ) #else DO l = 1, nbgp DO j = nys, nyn DO k = nzb, nzt + 1 avpr_l(k,1,l) = avpr_l(k,1,l) + u(k,j,i) avpr_l(k,2,l) = avpr_l(k,2,l) + v(k,j,i) avpr_l(k,3,l) = avpr_l(k,3,l) + w(k,j,i) avpr_l(k,4,l) = avpr_l(k,4,l) + pt(k,j,i) avpr_l(k,5,l) = avpr_l(k,5,l) + e(k,j,i) ENDDO ENDDO i = i + 1 ENDDO avpr = avpr_l #endif avpr = avpr / ( ny + 1 ) ! !-- Calculate the disturbances at the recycling plane i = recycling_plane #if defined( __parallel ) IF ( myidx == id_recycling ) THEN DO l = 1, nbgp DO j = nysg, nyng DO k = nzb, nzt + 1 inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) ENDDO ENDDO i = i + 1 ENDDO ENDIF #else DO l = 1, nbgp DO j = nysg, nyng DO k = nzb, nzt+1 inflow_dist(k,j,1,l) = u(k,j,i+1) - avpr(k,1,l) inflow_dist(k,j,2,l) = v(k,j,i) - avpr(k,2,l) inflow_dist(k,j,3,l) = w(k,j,i) - avpr(k,3,l) inflow_dist(k,j,4,l) = pt(k,j,i) - avpr(k,4,l) inflow_dist(k,j,5,l) = e(k,j,i) - avpr(k,5,l) ENDDO ENDDO i = i + 1 ENDDO #endif ! !-- For parallel runs, send the disturbances to the respective inflow PE #if defined( __parallel ) IF ( myidx == id_recycling .AND. myidx /= id_inflow ) THEN CALL MPI_SEND( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & id_inflow, 1, comm1dx, ierr ) ELSEIF ( myidx /= id_recycling .AND. myidx == id_inflow ) THEN inflow_dist = 0.0 CALL MPI_RECV( inflow_dist(nzb,nysg,1,1), ngp_ifd, MPI_REAL, & id_recycling, 1, comm1dx, status, ierr ) ENDIF #endif ! !-- Add the disturbance at the inflow IF ( nxl == 0 ) THEN DO j = nysg, nyng DO k = nzb, nzt + 1 u(k,j,-nbgp+1:0) = mean_inflow_profiles(k,1) + & inflow_dist(k,j,1,1:nbgp) * inflow_damping_factor(k) v(k,j,-nbgp:-1) = mean_inflow_profiles(k,2) + & inflow_dist(k,j,2,1:nbgp) * inflow_damping_factor(k) w(k,j,-nbgp:-1) = & inflow_dist(k,j,3,1:nbgp) * inflow_damping_factor(k) pt(k,j,-nbgp:-1) = mean_inflow_profiles(k,4) + & inflow_dist(k,j,4,1:nbgp) * inflow_damping_factor(k) e(k,j,-nbgp:-1) = mean_inflow_profiles(k,5) + & inflow_dist(k,j,5,1:nbgp) * inflow_damping_factor(k) e(k,j,-nbgp:-1) = MAX( e(k,j,-nbgp:-1), 0.0 ) ENDDO ENDDO ENDIF CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) END SUBROUTINE inflow_turbulence