-
Notifications
You must be signed in to change notification settings - Fork 67
/
rmsdiv.f90
60 lines (54 loc) · 1.65 KB
/
rmsdiv.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
!!
!! Copyright (C) 2009-2017 Johns Hopkins University
!!
!! This file is part of lesgo.
!!
!! lesgo is free software: you can redistribute it and/or modify
!! it under the terms of the GNU General Public License as published by
!! the Free Software Foundation, either version 3 of the License, or
!! (at your option) any later version.
!!
!! lesgo is distributed in the hope that it will be useful,
!! but WITHOUT ANY WARRANTY; without even the implied warranty of
!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
!! GNU General Public License for more details.
!!
!! You should have received a copy of the GNU General Public License
!! along with lesgo. If not, see <http://www.gnu.org/licenses/>.
!!
!*******************************************************************************
subroutine rmsdiv(rms)
!*******************************************************************************
!
! This subroutine calculates the velocity divergence metric. Currently using the
! L_1 norm ov the velocity divergence.
!
use types, only : rprec
use param
use sim_param, only : dudx, dvdy, dwdz
implicit none
integer :: jx, jy, jz, jz_max
real(rprec) :: rms
#ifdef PPMPI
real(rprec) :: rms_global
#endif
! Initialize variables
rms = 0._rprec
jz_max = nz - 1
! Calculate L1 norm of velocity divergence
do jz = 1, jz_max
do jy = 1, ny
do jx = 1, nx
rms = rms + abs( dudx(jx,jy,jz) + dvdy(jx,jy,jz) + dwdz(jx,jy,jz) )
end do
end do
end do
rms = rms / (nx*ny*(jz_max))
#ifdef PPMPI
! Transfer between processors
call mpi_reduce(rms, rms_global, 1, MPI_RPREC, MPI_SUM, 0, comm, ierr)
if (rank == 0) then
rms = rms_global/nproc
end if
#endif
end subroutine rmsdiv