Move maxspeed() to module EQUATIONS.

This commit is contained in:
Grzegorz Kowal 2012-08-01 12:16:38 -03:00
parent fca524da42
commit 2413de249f
4 changed files with 183 additions and 92 deletions

View File

@ -311,6 +311,93 @@ module equations
!
!===============================================================================
!
! function MAXSPEED:
! -----------------
!
! Function scans the variable array and returns the maximum speed in the
! system.
!
! Arguments:
!
! q - the array of primitive variables;
!
!
!===============================================================================
!
function maxspeed(q)
! include external procedures and variables
!
use coordinates, only : im, jm, km, ib, ie, jb, je, kb, ke
use variables , only : nt
use variables , only : ivx, ivz
#ifdef ADI
use variables , only : idn, ipr
#endif /* ADI */
! local variables are not implicit by default
!
implicit none
! input arguments
!
real, dimension(nt,im,jm,km), intent(in) :: q
! return variable
!
real :: maxspeed
! local variables
!
integer :: i, j, k
real :: vv, v, c
!
!-------------------------------------------------------------------------------
!
! reset the maximum speed
!
maxspeed = 0.0d0
! iterate over all positions
!
do k = kb, ke
do j = jb, je
do i = ib, ie
! calculate the velocity amplitude
!
vv = sum(q(ivx:ivz,i,j,k) * q(ivx:ivz,i,j,k))
v = sqrt(vv)
#ifdef ADI
! calculate the adiabatic speed of sound
!
c = sqrt(gamma * q(ipr,i,j,k) / q(idn,i,j,k))
#endif /* ADI */
! calculate the maximum speed
!
#ifdef ISO
maxspeed = max(maxspeed, v + csnd)
#endif /* ISO */
#ifdef ADI
maxspeed = max(maxspeed, v + c)
#endif /* ADI */
end do
end do
end do
! return the value
!
return
!-------------------------------------------------------------------------------
!
end function maxspeed
!
!===============================================================================
!
! subroutine UPDATE_PRIMITIVE_VARIABLES:
! -------------------------------------
!
@ -631,6 +718,92 @@ module equations
!-------------------------------------------------------------------------------
!
end subroutine fluxspeed
!
!===============================================================================
!
! function MAXSPEED:
! -----------------
!
! Function scans the variable array and returns the maximum speed in the
! system.
!
! Arguments:
!
! q - the array of primitive variables;
!
!
!===============================================================================
!
function maxspeed()
! include external procedures and variables
!
use mesh , only : im, jm, km, ib, ie, jb, je, kb, ke
use variables , only : nt
use variables , only : idn, ivx, ivz, ibx, ibz
#ifdef ADI
use variables , only : ipr
#endif /* ADI */
! local variables are not implicit by default
!
implicit none
! input arguments
!
real, dimension(nt,im,jm,km), intent(in) :: q
! return variable
!
real :: maxspeed
! local variables
!
integer :: i, j, k
real :: vv, bb, v, c
!
!-------------------------------------------------------------------------------
!
! reset the maximum speed
!
maxspeed = 0.0d0
! iterate over all positions
!
do k = kb, ke
do j = jb, je
do i = ib, ie
! calculate the velocity amplitude
!
vv = sum(q(ivx:ivz,i,j,k) * q(ivx:ivz,i,j,k))
v = sqrt(vv)
bb = sum(q(ibx:ibz,i,j,k) * q(ibx:ibz,i,j,k))
! calculate the fast magnetosonic speed
!
#ifdef ISO
c = sqrt(csnd2 + bb / q(idn,i,j,k))
#endif /* ISO */
#ifdef ADI
c = sqrt((gamma * q(ipr,i,j,k) + bb) / q(idn,i,j,k))
#endif /* ADI */
! calculate the maximum of speed
!
maxspeed = max(maxspeed, v + c)
end do
end do
end do
! return the value
!
return
!-------------------------------------------------------------------------------
!
end function maxspeed
#endif /* MHD */
!===============================================================================

View File

@ -493,10 +493,11 @@ module evolution
use blocks , only : block_meta, block_data, list_meta, list_data
use coordinates, only : toplev
use coordinates, only : adx, ady, adz
use equations , only : maxspeed
#ifdef MPI
use mpitools , only : reduce_maximum_real
#endif /* MPI */
use scheme , only : maxspeed, cmax
use variables , only : cmax
implicit none

View File

@ -29,10 +29,6 @@ module scheme
implicit none
! the maximal speed in the system
!
real, save :: cmax
contains
#ifdef CONSERVATIVE
!
@ -616,6 +612,7 @@ module scheme
use variables , only : ibx, iby, ibz
#ifdef GLM
use variables , only : iph
use variables , only : cmax
#endif /* GLM */
#endif /* MHD */
@ -943,6 +940,7 @@ module scheme
use variables , only : ibx, iby, ibz
#ifdef GLM
use variables , only : iph
use variables , only : cmax
#endif /* GLM */
implicit none
@ -1192,6 +1190,7 @@ module scheme
use variables , only : ibx, iby, ibz
#ifdef GLM
use variables , only : iph
use variables , only : cmax
#endif /* GLM */
implicit none
@ -1545,6 +1544,7 @@ module scheme
use variables , only : ibx, iby, ibz
#ifdef GLM
use variables , only : iph
use variables , only : cmax
#endif /* GLM */
#endif /* MHD */
@ -2032,93 +2032,6 @@ module scheme
#endif /* ISO */
#endif /* MHD */
#endif /* ROE */
!
!===============================================================================
!
! maxspeed: function to calculate maximum speed in the system
!
!===============================================================================
!
function maxspeed(q)
use coordinates, only : im, jm, km, ib, ie, jb, je, kb, ke
#ifdef ADI
use equations , only : gamma
#endif /* ADI */
#ifdef ISO
use equations , only : csnd, csnd2
#endif /* ISO */
use variables , only : nvr, nqt
use variables , only : idn, ivx, ivz
#ifdef ADI
use variables , only : ipr
#endif /* ADI */
#ifdef MHD
use variables , only : ibx, iby, ibz
#endif /* MHD */
implicit none
! input arguments
!
real, dimension(nqt,im,jm,km), intent(in) :: q
! local variables
!
integer :: i, j, k
real :: vv, v, c
#ifdef MHD
real :: bb
#endif /* MHD */
real :: maxspeed
!
!-------------------------------------------------------------------------------
!
maxspeed = 0.0
! iterate over all points and calculate maximum speed
!
do k = kb, ke
do j = jb, je
do i = ib, ie
! calculate the velocity
!
vv = sum(q(ivx:ivz,i,j,k)**2)
v = sqrt(vv)
#ifdef MHD
bb = sum(q(ibx:ibz,i,j,k)**2)
#endif /* MHD */
! calculate the maximum characteristic speed
!
#ifdef MHD
#ifdef ADI
c = sqrt((gamma * q(ipr,i,j,k) + bb) / q(idn,i,j,k))
#endif /* ADI */
#ifdef ISO
c = sqrt(csnd2 + bb / q(idn,i,j,k))
#endif /* ISO */
#else /* MHD */
#ifdef ADI
c = sqrt(gamma * q(ipr,i,j,k) / q(idn,i,j,k))
#endif /* ADI */
#ifdef ISO
c = csnd
#endif /* ISO */
#endif /* MHD */
! calculate maximum of the speed
!
maxspeed = max(maxspeed, v + c)
end do
end do
end do
!
!-------------------------------------------------------------------------------
!
end function maxspeed
!===============================================================================
!

View File

@ -55,6 +55,10 @@ module variables
#endif /* MHD */
integer(kind=4), parameter :: nvr = nqt
integer(kind=4), parameter :: nt = nqt
! the maximum characteristic speed in the domain
!
real , save :: cmax = 0.0d+0
!
!===============================================================================
!