1 | SUBROUTINE inflow_turbulence |
---|
2 | |
---|
3 | !------------------------------------------------------------------------------! |
---|
4 | ! Actual revisions: |
---|
5 | ! ----------------- |
---|
6 | ! |
---|
7 | ! |
---|
8 | ! Former revisions: |
---|
9 | ! ----------------- |
---|
10 | ! $Id: inflow_turbulence.f90 151 2008-03-07 13:42:18Z letzel $ |
---|
11 | ! |
---|
12 | ! |
---|
13 | ! Description: |
---|
14 | ! ------------ |
---|
15 | ! Imposing turbulence at the respective inflow using the turbulence |
---|
16 | ! recycling method of Kataoka and Mizuno (2002). |
---|
17 | !------------------------------------------------------------------------------! |
---|
18 | |
---|
19 | USE arrays_3d |
---|
20 | USE control_parameters |
---|
21 | USE cpulog |
---|
22 | USE grid_variables |
---|
23 | USE indices |
---|
24 | USE interfaces |
---|
25 | USE pegrid |
---|
26 | |
---|
27 | |
---|
28 | IMPLICIT NONE |
---|
29 | |
---|
30 | INTEGER :: i, imax, j, k, ngp_ifd, ngp_pr |
---|
31 | |
---|
32 | REAL, DIMENSION(1:2) :: volume_flow_l, volume_flow_offset |
---|
33 | REAL, DIMENSION(nzb:nzt+1,5) :: avpr, avpr_l |
---|
34 | REAL, DIMENSION(nzb:nzt+1,nys-1:nyn+1,5) :: inflow_dist |
---|
35 | |
---|
36 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'start' ) |
---|
37 | |
---|
38 | ! |
---|
39 | !-- Carry out horizontal averaging in the recycling plane |
---|
40 | avpr_l = 0.0 |
---|
41 | ngp_pr = ( nzt - nzb + 2 ) * 5 |
---|
42 | ngp_ifd = ngp_pr * ( nyn - nys + 3 ) |
---|
43 | |
---|
44 | ! |
---|
45 | !-- First, local averaging within the recycling domain |
---|
46 | IF ( recycling_plane >= nxl ) THEN |
---|
47 | |
---|
48 | imax = MIN( nxr, recycling_plane ) |
---|
49 | |
---|
50 | DO i = nxl, imax |
---|
51 | DO j = nys, nyn |
---|
52 | DO k = nzb, nzt+1 |
---|
53 | |
---|
54 | avpr_l(k,1) = avpr_l(k,1) + u(k,j,i) |
---|
55 | avpr_l(k,2) = avpr_l(k,2) + v(k,j,i) |
---|
56 | avpr_l(k,3) = avpr_l(k,3) + w(k,j,i) |
---|
57 | avpr_l(k,4) = avpr_l(k,4) + pt(k,j,i) |
---|
58 | avpr_l(k,5) = avpr_l(k,5) + e(k,j,i) |
---|
59 | |
---|
60 | ENDDO |
---|
61 | ENDDO |
---|
62 | ENDDO |
---|
63 | |
---|
64 | ENDIF |
---|
65 | |
---|
66 | ! WRITE (9,*) '*** averaged profiles avpr_l' |
---|
67 | ! DO k = nzb, nzt+1 |
---|
68 | ! WRITE (9,'(F5.1,1X,F5.1,1X,F5.1,1X,F6.1,1X,F7.2)') avpr_l(k,1),avpr_l(k,2),avpr_l(k,3),avpr_l(k,4),avpr_l(k,5) |
---|
69 | ! ENDDO |
---|
70 | ! WRITE (9,*) ' ' |
---|
71 | |
---|
72 | #if defined( __parallel ) |
---|
73 | ! |
---|
74 | !-- Now, averaging over all PEs |
---|
75 | CALL MPI_ALLREDUCE( avpr_l(nzb,1), avpr(nzb,1), ngp_pr, MPI_REAL, MPI_SUM, & |
---|
76 | comm2d, ierr ) |
---|
77 | #else |
---|
78 | avpr = avpr_l |
---|
79 | #endif |
---|
80 | |
---|
81 | avpr = avpr / ( ( ny + 1 ) * ( recycling_plane + 1 ) ) |
---|
82 | |
---|
83 | ! WRITE (9,*) '*** averaged profiles' |
---|
84 | ! DO k = nzb, nzt+1 |
---|
85 | ! WRITE (9,'(F5.1,1X,F5.1,1X,F5.1,1X,F6.1,1X,F7.2)') avpr(k,1),avpr(k,2),avpr(k,3),avpr(k,4),avpr(k,5) |
---|
86 | ! ENDDO |
---|
87 | ! WRITE (9,*) ' ' |
---|
88 | |
---|
89 | ! |
---|
90 | !-- Calculate the disturbances at the recycling plane |
---|
91 | i = recycling_plane |
---|
92 | |
---|
93 | IF ( i >= nxl .AND. i <= nxr ) THEN |
---|
94 | |
---|
95 | DO j = nys-1, nyn+1 |
---|
96 | DO k = nzb, nzt+1 |
---|
97 | |
---|
98 | inflow_dist(k,j,1) = u(k,j,i+1) - avpr(k,1) |
---|
99 | inflow_dist(k,j,2) = v(k,j,i) - avpr(k,2) |
---|
100 | inflow_dist(k,j,3) = w(k,j,i) - avpr(k,3) |
---|
101 | inflow_dist(k,j,4) = pt(k,j,i) - avpr(k,4) |
---|
102 | inflow_dist(k,j,5) = e(k,j,i) - avpr(k,5) |
---|
103 | |
---|
104 | ENDDO |
---|
105 | ENDDO |
---|
106 | |
---|
107 | ENDIF |
---|
108 | |
---|
109 | ! |
---|
110 | !-- For parallel runs, send the disturbances to the respective inflow PE |
---|
111 | #if defined( __parallel ) |
---|
112 | IF ( i >= nxl .AND. i <= nxr .AND. myid /= id_inflow ) THEN |
---|
113 | |
---|
114 | ! print*, '*** sending id = ', myid, ' send to:', id_inflow |
---|
115 | CALL MPI_SEND( inflow_dist(nzb,nys-1,1), ngp_ifd, MPI_REAL, & |
---|
116 | id_inflow, 1, comm1dx, ierr ) |
---|
117 | |
---|
118 | ELSEIF ( ( i < nxl .OR. i > nxr ) .AND. myid == id_inflow ) THEN |
---|
119 | |
---|
120 | ! print*, '*** receiving id = ', myid |
---|
121 | CALL MPI_RECV( inflow_dist(nzb,nys-1,1), ngp_ifd, MPI_REAL, & |
---|
122 | MPI_ANY_SOURCE, 1, comm1dx, status, ierr ) |
---|
123 | |
---|
124 | ENDIF |
---|
125 | #endif |
---|
126 | |
---|
127 | ! |
---|
128 | !-- Add the disturbance at the inflow |
---|
129 | IF ( nxl == 0 ) THEN |
---|
130 | |
---|
131 | DO j = nys-1, nyn+1 |
---|
132 | DO k = nzb, nzt+1 |
---|
133 | |
---|
134 | ! WRITE (9,*) 'j=',j,' k=',k |
---|
135 | ! WRITE (9,*) 'mean_u = ', mean_inflow_profiles(k,1), ' dist_u = ',& |
---|
136 | ! inflow_dist(k,j,1) |
---|
137 | ! WRITE (9,*) 'mean_v = ', mean_inflow_profiles(k,2), ' dist_v = ',& |
---|
138 | ! inflow_dist(k,j,2) |
---|
139 | ! WRITE (9,*) 'mean_w = 0.0', ' dist_w = ',& |
---|
140 | ! inflow_dist(k,j,3) |
---|
141 | ! WRITE (9,*) 'mean_pt = ', mean_inflow_profiles(k,4), ' dist_pt = ',& |
---|
142 | ! inflow_dist(k,j,4) |
---|
143 | ! WRITE (9,*) 'mean_e = ', mean_inflow_profiles(k,5), ' dist_e = ',& |
---|
144 | ! inflow_dist(k,j,5) |
---|
145 | u(k,j,0) = mean_inflow_profiles(k,1) + & |
---|
146 | inflow_dist(k,j,1) * inflow_damping_factor(k) |
---|
147 | v(k,j,-1) = mean_inflow_profiles(k,2) + & |
---|
148 | inflow_dist(k,j,2) * inflow_damping_factor(k) |
---|
149 | w(k,j,-1) = inflow_dist(k,j,3) * inflow_damping_factor(k) |
---|
150 | pt(k,j,-1) = mean_inflow_profiles(k,4) + & |
---|
151 | inflow_dist(k,j,4) * inflow_damping_factor(k) |
---|
152 | e(k,j,-1) = mean_inflow_profiles(k,5) + & |
---|
153 | inflow_dist(k,j,5) * inflow_damping_factor(k) |
---|
154 | e(k,j,-1) = MAX( e(k,j,-1), 0.0 ) |
---|
155 | |
---|
156 | ENDDO |
---|
157 | ENDDO |
---|
158 | |
---|
159 | ENDIF |
---|
160 | |
---|
161 | ! |
---|
162 | !-- Conserve the volume flow at the inflow in order to avoid generation of |
---|
163 | !-- waves in the stable layer |
---|
164 | ! IF ( conserve_volume_flow .AND. inflow_l ) THEN |
---|
165 | |
---|
166 | ! volume_flow(1) = 0.0 |
---|
167 | ! volume_flow_l(1) = 0.0 |
---|
168 | |
---|
169 | ! i = 0 |
---|
170 | |
---|
171 | ! DO j = nys, nyn |
---|
172 | ! |
---|
173 | !-- Sum up the volume flow through the south/north boundary |
---|
174 | ! DO k = nzb_2d(j,i) + 1, nzt |
---|
175 | ! volume_flow_l(1) = volume_flow_l(1) + u(k,j,i) * dzu(k) |
---|
176 | ! ENDDO |
---|
177 | ! ENDDO |
---|
178 | |
---|
179 | #if defined( __parallel ) |
---|
180 | ! CALL MPI_ALLREDUCE( volume_flow_l(1), volume_flow(1), 1, MPI_REAL, & |
---|
181 | ! MPI_SUM, comm1dy, ierr ) |
---|
182 | #else |
---|
183 | ! volume_flow = volume_flow_l |
---|
184 | #endif |
---|
185 | ! volume_flow_offset(1) = ( volume_flow_initial(1) - volume_flow(1) ) & |
---|
186 | ! / volume_flow_area(1) |
---|
187 | |
---|
188 | ! DO j = nys-1, nyn+1 |
---|
189 | ! DO k = nzb_v_inner(j,i) + 1, nzt |
---|
190 | ! u(k,j,i) = u(k,j,i) + volume_flow_offset(1) |
---|
191 | ! ENDDO |
---|
192 | ! ENDDO |
---|
193 | |
---|
194 | ! ENDIF |
---|
195 | |
---|
196 | CALL cpu_log( log_point(40), 'inflow_turbulence', 'stop' ) |
---|
197 | |
---|
198 | |
---|
199 | END SUBROUTINE inflow_turbulence |
---|