source: palm/trunk/SOURCE/outflow_turbulence.f90 @ 2050

Last change on this file since 2050 was 2050, checked in by gronemeier, 7 years ago

Implement turbulent outflow condition

  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1!> @file outflow_turbulence.f90
2!------------------------------------------------------------------------------!
3! This file is part of PALM.
4!
5! PALM is free software: you can redistribute it and/or modify it under the
6! terms of the GNU General Public License as published by the Free Software
7! Foundation, either version 3 of the License, or (at your option) any later
8! 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-2016 Leibniz Universitaet Hannover
18!------------------------------------------------------------------------------!
19!
20! Current revisions:
21! -----------------
22! Initial version
23!
24! Former revisions:
25! -----------------
26! $Id: outflow_turbulence.f90 2050 2016-11-08 15:00:55Z gronemeier $
27!
28!
29! Description:
30! ------------
31!> Routine based on inflow_turbulence.f90. Copies values of 3d data from a 2d
32!> vertical source plane (defined by outflow_source_plane) to the outflow
33!> boundary.
34!------------------------------------------------------------------------------!
35 SUBROUTINE outflow_turbulence
36
37    USE arrays_3d,                                                             &
38        ONLY:  e, pt, q, s, u, v, w
39
40    USE control_parameters,                                                    &
41        ONLY:  humidity, passive_scalar, outflow_source_plane
42
43    USE cpulog,                                                                &
44        ONLY:  cpu_log, log_point
45
46    USE grid_variables,                                                        &
47        ONLY:  ddx
48
49    USE indices,                                                               &
50        ONLY:  nbgp, nx, nxr, ny, nyn, nys, nyng, nysg, nzb, nzt
51
52    USE kinds
53
54    USE pegrid!,                                                                &
55        !ONLY:  comm1dx, id_outflow, id_outflow_source, ierr, myidx, status
56
57    IMPLICIT NONE
58
59    INTEGER(iwp) ::  i        !< loop index
60    INTEGER(iwp) ::  j        !< loop index
61    INTEGER(iwp) ::  k        !< loop index
62    INTEGER(iwp) ::  l        !< loop index
63    INTEGER(iwp) ::  ngp_ofv  !< number of grid points stored in outflow_val
64
65    REAL(wp), DIMENSION(nzb:nzt+1,nysg:nyng,7,nbgp) ::                         &
66       outflow_val            !< values to be copied to the outflow boundary
67
68
69    CALL cpu_log( log_point(56), 'outflow_turbulence', 'start' )
70!
71!-- Get number of grid points stored in outflow_val
72    ngp_ofv = ( nzt - nzb + 2 ) * ( nyn - nys + 1 + 2 * nbgp ) * 7 * nbgp
73!
74!-- Get position of the source plane inside the palm grid
75    i = outflow_source_plane * ddx
76!
77!-- Use instantaneous values instead of averaged profiles
78#if defined( __parallel )
79    IF ( myidx == id_outflow_source )  THEN
80       DO  l = 1, nbgp
81          DO  j = nysg, nyng
82             DO  k = nzb, nzt + 1
83
84                outflow_val(k,j,1,l) = u(k,j,i)
85                outflow_val(k,j,2,l) = v(k,j,i)
86                outflow_val(k,j,3,l) = w(k,j,i)
87                outflow_val(k,j,4,l) = pt(k,j,i)
88                outflow_val(k,j,5,l) = e(k,j,i)
89                IF ( humidity  )                                               &
90                   outflow_val(k,j,6,l) = q(k,j,i)
91                IF ( passive_scalar )                                          &
92                   outflow_val(k,j,7,l) = s(k,j,i)
93
94            ENDDO
95          ENDDO
96          i = i + 1
97       ENDDO
98
99    ENDIF
100#else
101    DO  l = 1, nbgp
102       DO  j = nysg, nyng
103          DO  k = nzb, nzt+1
104
105             outflow_val(k,j,1,l) = u(k,j,i)
106             outflow_val(k,j,2,l) = v(k,j,i)
107             outflow_val(k,j,3,l) = w(k,j,i)
108             outflow_val(k,j,4,l) = pt(k,j,i)
109             outflow_val(k,j,5,l) = e(k,j,i)
110             IF ( humidity  )                                                  &
111                outflow_val(k,j,6,l) = q(k,j,i)
112             IF ( passive_scalar )                                             &
113                outflow_val(k,j,7,l) = s(k,j,i)
114
115          ENDDO
116       ENDDO
117       i = i + 1
118    ENDDO
119#endif
120
121!
122!-- For parallel runs, send the values to the respective outflow PE
123#if defined( __parallel )
124    IF ( myidx == id_outflow_source  .AND.  myidx /= id_outflow )  THEN
125
126       CALL MPI_SEND( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL,            &
127                      id_outflow, 1, comm1dx, ierr )
128
129    ELSEIF ( myidx /= id_outflow_source  .AND.  myidx == id_outflow )  THEN
130
131       outflow_val = 0.0_wp
132       CALL MPI_RECV( outflow_val(nzb,nysg,1,1), ngp_ofv, MPI_REAL,            &
133                      id_outflow_source, 1, comm1dx, status, ierr )
134
135    ENDIF
136#endif
137
138!
139!-- Copy values to the outflow
140    IF ( nxr == nx )  THEN
141
142       DO  j = nysg, nyng
143          DO  k = nzb, nzt + 1
144
145             u(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,1,1:nbgp)
146             v(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,2,1:nbgp)
147             w(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,3,1:nbgp)
148             pt(k,j,nx+1:nx+nbgp) = outflow_val(k,j,4,1:nbgp)
149             e(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,5,1:nbgp)
150             e(k,j,nx+1:nx+nbgp)  = MAX( e(k,j,nx+1:nx+nbgp), 0.0_wp )
151
152             IF ( humidity )                                                   &
153                q(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,6,1:nbgp)
154             IF ( passive_scalar )                                             &
155                s(k,j,nx+1:nx+nbgp)  = outflow_val(k,j,7,1:nbgp)
156
157          ENDDO
158       ENDDO
159
160
161    ENDIF
162
163    CALL cpu_log( log_point(56), 'outflow_turbulence', 'stop' )
164
165 END SUBROUTINE outflow_turbulence
Note: See TracBrowser for help on using the repository browser.