Revert "SOURCES: Use workspace in refinement criterion calculation."

This reverts commit 1860fe97b093cb825171d495ab075bee0a51bc03.

This comming introduced a circular dependency.
This commit is contained in:
Grzegorz Kowal 2021-11-12 14:08:04 -03:00
parent 1860fe97b0
commit 14dd5039ab

View File

@ -606,13 +606,12 @@ module refinement
! !
function vorticity_magnitude(pdata) result(wmax) function vorticity_magnitude(pdata) result(wmax)
use blocks , only : block_data use blocks , only : block_data
use coordinates , only : nn => bcells use coordinates, only : nn => bcells
use coordinates , only : nbl, neu use coordinates, only : nbl, neu
use equations , only : ivx, ivz use equations , only : inx, inz
use iso_fortran_env, only : error_unit use equations , only : ivx, ivz
use mesh , only : work, nwork, work_in_use use operators , only : curl
use operators , only : curl
implicit none implicit none
@ -620,66 +619,24 @@ module refinement
real(kind=4) :: wmax real(kind=4) :: wmax
logical, save :: first = .true. integer :: i, j, k = 1
integer :: i, j, k = 1, status
real(kind=8) :: vort real(kind=8) :: vort
real(kind=8), dimension(3), save :: dh real(kind=8), dimension(3) :: dh = 1.0d+00
real(kind=8), dimension(:,:,:,:), pointer, save :: w
character(len=*), parameter :: loc = 'REFINEMENT:vorticity_magnitude()'
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
call curl(dh(:), pdata%q(ivx:ivz,:,:,:), pdata%du(inx:inz,:,:,:))
wmax = 0.0e+00 wmax = 0.0e+00
if (first) then
status = 0
if (work_in_use) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace is already occupied!"
return
else
i = 3 * nn**NDIMS
if (i > nwork) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace has too be increased!"
nwork = i
deallocate(work)
allocate(work(nwork), stat=status)
if (status /= 0) then
write(error_unit,"('[',a,']: ',a)") trim(loc), &
"Cannot increase the workspace's size!"
return
end if
end if
#if NDIMS == 3
w(1:3,1:nn,1:nn,1:nn) => work(1:i)
#else /* NDIMS == 3 */
w(1:3,1:nn,1:nn,1: 1) => work(1:i)
#endif /* NDIMS == 3 */
dh(:) = 1.0d+00
end if
first = .false.
end if
work_in_use = .true.
call curl(dh(:), pdata%q(ivx:ivz,:,:,:), w(:,:,:,:))
#if NDIMS == 3 #if NDIMS == 3
do k = nbl, neu do k = nbl, neu
#endif /* NDIMS == 3 */ #endif /* NDIMS == 3 */
do j = nbl, neu do j = nbl, neu
do i = nbl, neu do i = nbl, neu
vort = sum(w(:,i,j,k)**2) vort = sum(pdata%du(inx:inz,i,j,k)**2)
wmax = max(wmax, real(vort, kind=4)) wmax = max(wmax, real(vort, kind=4))
@ -689,8 +646,6 @@ module refinement
end do end do
#endif /* NDIMS == 3 */ #endif /* NDIMS == 3 */
work_in_use = .false.
wmax = sqrt(wmax) wmax = sqrt(wmax)
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
@ -713,14 +668,13 @@ module refinement
! !
function current_density_magnitude(pdata) result(jmax) function current_density_magnitude(pdata) result(jmax)
use blocks , only : block_data use blocks , only : block_data
use coordinates , only : nn => bcells use coordinates, only : nn => bcells
use coordinates , only : nbl, neu use coordinates, only : nbl, neu
use equations , only : magnetized use equations , only : magnetized
use equations , only : ibx, ibz use equations , only : inx, inz
use iso_fortran_env, only : error_unit use equations , only : ibx, ibz
use mesh , only : work, nwork, work_in_use use operators , only : curl
use operators , only : curl
implicit none implicit none
@ -728,81 +682,39 @@ module refinement
real(kind=4) :: jmax real(kind=4) :: jmax
logical, save :: first = .true. integer :: i, j, k = 1
integer :: i, j, k = 1, status
real(kind=8) :: jabs real(kind=8) :: jabs
real(kind=8), dimension(3), save :: dh real(kind=8), dimension(3) :: dh = 1.0d+00
real(kind=8), dimension(:,:,:,:), pointer, save :: w
character(len=*), parameter :: loc = 'REFINEMENT:current_density_magnitude()'
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
jmax = 0.0e+00 jmax = 0.0e+00
if (.not. magnetized) return if (magnetized) then
if (first) then call curl(dh(:), pdata%q(ibx:ibz,:,:,:), pdata%du(inx:inz,:,:,:))
status = 0
if (work_in_use) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace is already occupied!"
return
else
i = 3 * nn**NDIMS
if (i > nwork) then
write(error_unit,"('[',a,']: ',a,3i4,a)") trim(loc), &
"Workspace has too be increased!"
nwork = i
deallocate(work)
allocate(work(nwork), stat=status)
if (status /= 0) then
write(error_unit,"('[',a,']: ',a)") trim(loc), &
"Cannot increase the workspace's size!"
return
end if
end if
#if NDIMS == 3 #if NDIMS == 3
w(1:3,1:nn,1:nn,1:nn) => work(1:i) do k = nbl, neu
#else /* NDIMS == 3 */ #endif /* NDIMS == 3 */
w(1:3,1:nn,1:nn,1: 1) => work(1:i) do j = nbl, neu
do i = nbl, neu
jabs = sum(pdata%du(inx:inz,i,j,k)**2)
jmax = max(jmax, real(jabs, kind=4))
end do ! i = nbl, neu
end do ! j = nbl, neu
#if NDIMS == 3
end do ! k = nbl, neu
#endif /* NDIMS == 3 */ #endif /* NDIMS == 3 */
dh(:) = 1.0d+00 jmax = sqrt(jmax)
end if
first = .false.
end if end if
work_in_use = .true.
call curl(dh(:), pdata%q(ibx:ibz,:,:,:), w(:,:,:,:))
#if NDIMS == 3
do k = nbl, neu
#endif /* NDIMS == 3 */
do j = nbl, neu
do i = nbl, neu
jabs = sum(w(:,i,j,k)**2)
jmax = max(jmax, real(jabs, kind=4))
end do ! i = nbl, neu
end do ! j = nbl, neu
#if NDIMS == 3
end do ! k = nbl, neu
#endif /* NDIMS == 3 */
work_in_use = .false.
jmax = sqrt(jmax)
!------------------------------------------------------------------------------- !-------------------------------------------------------------------------------
! !
end function current_density_magnitude end function current_density_magnitude