2010-10-13 03:32:10 -03:00
|
|
|
!!******************************************************************************
|
2008-11-11 16:12:26 -06:00
|
|
|
!!
|
2008-12-08 13:59:57 -06:00
|
|
|
!! module: problem - handling the initial problem definition
|
2008-11-11 16:12:26 -06:00
|
|
|
!!
|
2010-10-13 03:32:10 -03:00
|
|
|
!! Copyright (C) 2008-2010 Grzegorz Kowal <grzegorz@gkowal.info>
|
2008-11-11 16:12:26 -06:00
|
|
|
!!
|
2010-10-13 03:32:10 -03:00
|
|
|
!!******************************************************************************
|
2008-11-11 16:12:26 -06:00
|
|
|
!!
|
|
|
|
!! This file is part of Godunov-AMR.
|
|
|
|
!!
|
|
|
|
!! Godunov-AMR 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.
|
|
|
|
!!
|
|
|
|
!! Godunov-AMR 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
!!
|
2010-10-13 03:32:10 -03:00
|
|
|
!!******************************************************************************
|
2008-11-11 16:12:26 -06:00
|
|
|
!!
|
|
|
|
!
|
|
|
|
module problem
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
contains
|
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-22 15:34:02 -06:00
|
|
|
! init_domain: subroutine initializes the domain for a given problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_domain
|
|
|
|
|
|
|
|
use config, only : problem
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
select case(trim(problem))
|
2009-09-26 15:44:25 -03:00
|
|
|
#if NDIMS == 2
|
2010-02-12 00:05:02 -02:00
|
|
|
case("blast")
|
|
|
|
call domain_blast()
|
2009-09-26 15:44:25 -03:00
|
|
|
#endif /* NDIMS == 2 */
|
2008-12-22 15:34:02 -06:00
|
|
|
case default
|
|
|
|
call domain_default()
|
|
|
|
end select
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine init_domain
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2008-11-11 16:12:26 -06:00
|
|
|
! init_problem: subroutine initializes the variables according to
|
|
|
|
! the studied problem
|
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
|
|
|
subroutine init_problem(pblock)
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
use blocks, only : block_data
|
2008-12-18 10:20:15 -06:00
|
|
|
use config, only : problem
|
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
2008-12-18 10:20:15 -06:00
|
|
|
|
|
|
|
! local arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer :: pb
|
2008-12-18 10:20:15 -06:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
pb => pblock
|
|
|
|
|
|
|
|
select case(trim(problem))
|
|
|
|
case("blast")
|
|
|
|
call init_blast(pb)
|
|
|
|
case("implosion")
|
|
|
|
call init_implosion(pb)
|
2008-12-18 11:09:42 -06:00
|
|
|
case("binaries")
|
|
|
|
call init_binaries(pb)
|
2010-12-01 21:08:45 -02:00
|
|
|
case("reconnection")
|
|
|
|
call init_reconnection(pb)
|
2008-12-18 10:20:15 -06:00
|
|
|
end select
|
|
|
|
|
|
|
|
nullify(pb)
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine init_problem
|
2008-12-18 12:18:36 -06:00
|
|
|
#ifdef SHAPE
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! shapes: subroutine resets the update for a give shape
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine update_shapes(pblock, du)
|
|
|
|
|
2009-09-11 21:52:18 -03:00
|
|
|
use blocks, only : block_data
|
2008-12-18 12:18:36 -06:00
|
|
|
use config, only : problem
|
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
|
|
|
real, dimension(:,:,:,:) , intent(inout) :: du
|
2008-12-18 12:18:36 -06:00
|
|
|
|
|
|
|
! local arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer :: pb
|
2008-12-18 12:18:36 -06:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
pb => pblock
|
|
|
|
|
|
|
|
select case(trim(problem))
|
|
|
|
case("binaries")
|
|
|
|
call shape_binaries(pb, du)
|
|
|
|
case default
|
|
|
|
end select
|
|
|
|
|
|
|
|
nullify(pb)
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine update_shapes
|
|
|
|
#endif /* SHAPE */
|
2008-12-18 10:20:15 -06:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2008-12-22 15:34:02 -06:00
|
|
|
! domain_default: subroutine initializes the default domain of 2x2 blocks in
|
|
|
|
! 'N' configuration
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine domain_default
|
|
|
|
|
2009-09-13 22:58:55 -03:00
|
|
|
use blocks, only : block_meta, block_data, append_metablock &
|
2009-09-11 21:52:18 -03:00
|
|
|
, append_datablock, associate_blocks, metablock_setleaf &
|
|
|
|
, metablock_setconfig, metablock_setlevel &
|
2010-10-11 22:46:07 -03:00
|
|
|
, metablock_set_coord, metablock_setbounds &
|
|
|
|
, nsides, nfaces
|
2009-09-10 18:23:18 -03:00
|
|
|
use config, only : xlbndry, xubndry, ylbndry, yubndry, zlbndry, zubndry &
|
2009-09-10 17:46:36 -03:00
|
|
|
, xmin, xmax, ymin, ymax, zmin, zmax
|
2008-12-22 15:34:02 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2009-09-10 18:23:18 -03:00
|
|
|
integer :: i, j
|
2008-12-22 15:34:02 -06:00
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
type(block_meta), pointer :: pmeta
|
|
|
|
type(block_data), pointer :: pdata
|
2008-12-22 15:34:02 -06:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2009-09-10 17:25:28 -03:00
|
|
|
! create root meta blocks
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
call append_metablock(pmeta)
|
2009-09-10 17:25:28 -03:00
|
|
|
|
2009-09-10 18:15:30 -03:00
|
|
|
! mark block as a leaf
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
call metablock_setleaf(pmeta)
|
2009-09-10 18:15:30 -03:00
|
|
|
|
|
|
|
! set block config flag
|
|
|
|
!
|
2009-10-03 20:11:03 -03:00
|
|
|
call metablock_setconfig(pmeta, 12)
|
2009-09-10 18:15:30 -03:00
|
|
|
|
|
|
|
! set block level
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
call metablock_setlevel(pmeta, 1)
|
|
|
|
|
2010-10-11 22:46:07 -03:00
|
|
|
! set block coordinates
|
|
|
|
!
|
|
|
|
call metablock_set_coord(pmeta, 0, 0, 0)
|
|
|
|
|
2009-09-26 14:27:47 -03:00
|
|
|
! set block bounds
|
|
|
|
!
|
|
|
|
call metablock_setbounds(pmeta, xmin, xmax, ymin, ymax, zmin, zmax)
|
2009-09-10 18:15:30 -03:00
|
|
|
|
2009-09-10 18:23:18 -03:00
|
|
|
! if periodic boundary conditions set all neighbors to itself
|
|
|
|
!
|
|
|
|
if (xlbndry .eq. 'periodic' .and. xubndry .eq. 'periodic') then
|
2009-09-11 21:52:18 -03:00
|
|
|
do j = 1, nfaces
|
|
|
|
do i = 1, nsides
|
2009-09-26 14:27:47 -03:00
|
|
|
pmeta%neigh(1,i,j)%ptr => pmeta
|
2009-09-10 18:23:18 -03:00
|
|
|
end do
|
|
|
|
end do
|
2009-09-27 03:07:23 -03:00
|
|
|
end if
|
2009-09-10 18:23:18 -03:00
|
|
|
if (ylbndry .eq. 'periodic' .and. yubndry .eq. 'periodic') then
|
2009-09-11 21:52:18 -03:00
|
|
|
do j = 1, nfaces
|
|
|
|
do i = 1, nsides
|
2009-09-26 14:27:47 -03:00
|
|
|
pmeta%neigh(2,i,j)%ptr => pmeta
|
2009-09-10 18:23:18 -03:00
|
|
|
end do
|
|
|
|
end do
|
2009-09-27 03:07:23 -03:00
|
|
|
end if
|
2009-09-11 21:52:18 -03:00
|
|
|
#if NDIMS == 3
|
2009-09-10 18:23:18 -03:00
|
|
|
if (zlbndry .eq. 'periodic' .and. zubndry .eq. 'periodic') then
|
2009-09-11 21:52:18 -03:00
|
|
|
do j = 1, nfaces
|
|
|
|
do i = 1, nsides
|
2009-09-26 14:27:47 -03:00
|
|
|
pmeta%neigh(3,i,j)%ptr => pmeta
|
2009-09-10 18:23:18 -03:00
|
|
|
end do
|
|
|
|
end do
|
2009-09-27 03:07:23 -03:00
|
|
|
end if
|
2009-09-11 21:52:18 -03:00
|
|
|
#endif /* NDIMS == 3 */
|
2009-09-10 18:23:18 -03:00
|
|
|
|
2009-09-25 11:41:19 -03:00
|
|
|
! create root data block
|
2009-09-10 17:46:36 -03:00
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
call append_datablock(pdata)
|
2008-12-22 15:34:02 -06:00
|
|
|
|
2009-09-10 17:46:36 -03:00
|
|
|
! associate root blocks
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
call associate_blocks(pmeta, pdata)
|
2009-09-10 17:25:28 -03:00
|
|
|
!
|
2008-12-22 15:34:02 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine domain_default
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2009-09-22 17:30:53 -03:00
|
|
|
! domain_default: subroutine initializes the default domain of 2x2 blocks in
|
|
|
|
! 'N' configuration
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine domain_blast
|
|
|
|
|
|
|
|
use blocks, only : block_meta, block_data, pointer_meta, append_metablock &
|
|
|
|
, append_datablock, associate_blocks, metablock_setleaf &
|
|
|
|
, metablock_setconfig, metablock_setlevel &
|
2010-10-11 22:46:07 -03:00
|
|
|
, metablock_setbounds, metablock_set_coord &
|
|
|
|
, nsides, nfaces, res
|
2009-09-22 17:30:53 -03:00
|
|
|
use config, only : xlbndry, xubndry, ylbndry, yubndry, zlbndry, zubndry &
|
2010-10-11 22:46:07 -03:00
|
|
|
, xmin, xmax, ymin, ymax, zmin, zmax, rdims, maxlev, ncells
|
2009-09-22 17:30:53 -03:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2010-10-11 22:46:07 -03:00
|
|
|
integer :: i, j, ih, jl, ju
|
2009-09-22 17:30:53 -03:00
|
|
|
real :: xm, yl, yu
|
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
type(block_meta), pointer :: pmeta
|
|
|
|
type(block_data), pointer :: pdata
|
2009-09-22 17:30:53 -03:00
|
|
|
|
|
|
|
! local pointer array
|
|
|
|
!
|
|
|
|
type(pointer_meta) :: block_array(2,3)
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
!! TO DO:
|
|
|
|
!!
|
|
|
|
!! create a general way to initiate NxM blocks at level 1
|
|
|
|
!!
|
|
|
|
!!
|
|
|
|
! create root meta blocks
|
|
|
|
!
|
|
|
|
call append_metablock(block_array(1,1)%ptr)
|
|
|
|
call append_metablock(block_array(2,1)%ptr)
|
|
|
|
call append_metablock(block_array(2,2)%ptr)
|
|
|
|
call append_metablock(block_array(1,2)%ptr)
|
|
|
|
call append_metablock(block_array(1,3)%ptr)
|
|
|
|
call append_metablock(block_array(2,3)%ptr)
|
|
|
|
|
|
|
|
! mark block as a leaf
|
|
|
|
!
|
|
|
|
call metablock_setleaf(block_array(1,1)%ptr)
|
|
|
|
call metablock_setleaf(block_array(2,1)%ptr)
|
|
|
|
call metablock_setleaf(block_array(2,2)%ptr)
|
|
|
|
call metablock_setleaf(block_array(1,2)%ptr)
|
|
|
|
call metablock_setleaf(block_array(1,3)%ptr)
|
|
|
|
call metablock_setleaf(block_array(2,3)%ptr)
|
|
|
|
|
|
|
|
! set block config flag
|
|
|
|
!
|
2009-10-03 20:11:03 -03:00
|
|
|
call metablock_setconfig(block_array(1,1)%ptr, 12)
|
|
|
|
call metablock_setconfig(block_array(2,1)%ptr, 13)
|
|
|
|
call metablock_setconfig(block_array(2,2)%ptr, 13)
|
|
|
|
call metablock_setconfig(block_array(1,2)%ptr, 43)
|
|
|
|
call metablock_setconfig(block_array(1,3)%ptr, 12)
|
|
|
|
call metablock_setconfig(block_array(2,3)%ptr, 12)
|
2009-09-22 17:30:53 -03:00
|
|
|
|
|
|
|
! set block level
|
|
|
|
!
|
|
|
|
call metablock_setlevel(block_array(1,1)%ptr, 1)
|
|
|
|
call metablock_setlevel(block_array(2,1)%ptr, 1)
|
|
|
|
call metablock_setlevel(block_array(2,2)%ptr, 1)
|
|
|
|
call metablock_setlevel(block_array(1,2)%ptr, 1)
|
|
|
|
call metablock_setlevel(block_array(1,3)%ptr, 1)
|
|
|
|
call metablock_setlevel(block_array(2,3)%ptr, 1)
|
|
|
|
|
|
|
|
! set boundary conditions
|
|
|
|
!
|
|
|
|
block_array(1,1)%ptr%neigh(1,1,1)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(1,1,2)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(1,2,1)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(1,2,2)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(2,1,1)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(2,1,2)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(2,2,1)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(1,1)%ptr%neigh(2,2,2)%ptr => block_array(1,2)%ptr
|
|
|
|
|
|
|
|
block_array(1,2)%ptr%neigh(1,1,1)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(1,1,2)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(1,2,1)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(1,2,2)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(2,1,1)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(2,1,2)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(2,2,1)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(1,2)%ptr%neigh(2,2,2)%ptr => block_array(1,3)%ptr
|
|
|
|
|
|
|
|
block_array(1,3)%ptr%neigh(1,1,1)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(1,1,2)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(1,2,1)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(1,2,2)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(2,1,1)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(2,1,2)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(2,2,1)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(1,3)%ptr%neigh(2,2,2)%ptr => block_array(1,1)%ptr
|
|
|
|
|
|
|
|
block_array(2,1)%ptr%neigh(1,1,1)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(1,1,2)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(1,2,1)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(1,2,2)%ptr => block_array(1,1)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(2,1,1)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(2,1,2)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(2,2,1)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(2,1)%ptr%neigh(2,2,2)%ptr => block_array(2,2)%ptr
|
|
|
|
|
|
|
|
block_array(2,2)%ptr%neigh(1,1,1)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(1,1,2)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(1,2,1)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(1,2,2)%ptr => block_array(1,2)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(2,1,1)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(2,1,2)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(2,2,1)%ptr => block_array(2,3)%ptr
|
|
|
|
block_array(2,2)%ptr%neigh(2,2,2)%ptr => block_array(2,3)%ptr
|
|
|
|
|
|
|
|
block_array(2,3)%ptr%neigh(1,1,1)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(1,1,2)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(1,2,1)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(1,2,2)%ptr => block_array(1,3)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(2,1,1)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(2,1,2)%ptr => block_array(2,2)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(2,2,1)%ptr => block_array(2,1)%ptr
|
|
|
|
block_array(2,3)%ptr%neigh(2,2,2)%ptr => block_array(2,1)%ptr
|
|
|
|
|
2010-10-11 22:46:07 -03:00
|
|
|
! prepare the coordinates
|
|
|
|
!
|
|
|
|
ih = res(1)
|
|
|
|
jl = res(1)
|
|
|
|
ju = res(1) + jl
|
|
|
|
|
|
|
|
! set the coordinates
|
|
|
|
!
|
|
|
|
call metablock_set_coord(block_array(1,1)%ptr, 0, 0, 0)
|
|
|
|
call metablock_set_coord(block_array(2,1)%ptr, ih, 0, 0)
|
|
|
|
call metablock_set_coord(block_array(1,2)%ptr, 0, jl, 0)
|
|
|
|
call metablock_set_coord(block_array(2,2)%ptr, ih, jl, 0)
|
|
|
|
call metablock_set_coord(block_array(1,3)%ptr, 0, ju, 0)
|
|
|
|
call metablock_set_coord(block_array(2,3)%ptr, ih, ju, 0)
|
|
|
|
|
2009-09-25 11:41:19 -03:00
|
|
|
! calculate bounds
|
|
|
|
!
|
|
|
|
xm = 0.5 * (xmin + xmax)
|
|
|
|
yl = (ymax - ymin) / 3.0 + ymin
|
|
|
|
yu = (ymax - ymin) / 3.0 + yl
|
|
|
|
|
|
|
|
! set block bounds
|
|
|
|
!
|
|
|
|
call metablock_setbounds(block_array(1,1)%ptr, xmin, xm , ymin, yl , zmin, zmax)
|
|
|
|
call metablock_setbounds(block_array(2,1)%ptr, xm , xmax, ymin, yl , zmin, zmax)
|
|
|
|
call metablock_setbounds(block_array(2,2)%ptr, xm , xmax, yl , yu , zmin, zmax)
|
|
|
|
call metablock_setbounds(block_array(1,2)%ptr, xmin, xm , yl , yu , zmin, zmax)
|
|
|
|
call metablock_setbounds(block_array(1,3)%ptr, xmin, xm , yu , ymax, zmin, zmax)
|
|
|
|
call metablock_setbounds(block_array(2,3)%ptr, xm , xmax, yu , ymax, zmin, zmax)
|
|
|
|
|
2009-09-22 17:30:53 -03:00
|
|
|
! create root data block
|
|
|
|
!
|
2009-09-26 14:27:47 -03:00
|
|
|
call append_datablock(pdata)
|
|
|
|
call associate_blocks(block_array(1,1)%ptr, pdata)
|
|
|
|
call append_datablock(pdata)
|
|
|
|
call associate_blocks(block_array(2,1)%ptr, pdata)
|
|
|
|
call append_datablock(pdata)
|
|
|
|
call associate_blocks(block_array(2,2)%ptr, pdata)
|
|
|
|
call append_datablock(pdata)
|
|
|
|
call associate_blocks(block_array(1,2)%ptr, pdata)
|
|
|
|
call append_datablock(pdata)
|
|
|
|
call associate_blocks(block_array(1,3)%ptr, pdata)
|
|
|
|
call append_datablock(pdata)
|
|
|
|
call associate_blocks(block_array(2,3)%ptr, pdata)
|
2009-09-22 17:30:53 -03:00
|
|
|
|
2010-10-11 22:46:07 -03:00
|
|
|
! set the block dimensions for the lowest level
|
2009-09-22 17:30:53 -03:00
|
|
|
!
|
|
|
|
rdims(1) = 2
|
|
|
|
rdims(2) = 3
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine domain_blast
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
! init_blast: subroutine initializes the variables for the blast problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_blast(pblock)
|
|
|
|
|
2010-12-01 09:25:30 -02:00
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : in, jn, kn, im, jm, km, ng &
|
|
|
|
, gamma, csnd2, rcut, dens, dnrat
|
|
|
|
use scheme , only : prim2cons
|
|
|
|
use variables, only : nvr, nqt, idn, ivx, ivy, ivz
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2010-12-01 09:25:30 -02:00
|
|
|
use variables, only : ipr
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2010-02-11 23:30:46 -02:00
|
|
|
#ifdef MHD
|
2010-12-01 12:42:17 -02:00
|
|
|
use variables, only : ibx, iby, ibz
|
|
|
|
#ifdef FLUXCT
|
|
|
|
use variables, only : icx, icy, icz
|
|
|
|
#endif /* FLUXCT */
|
|
|
|
#ifdef GLM
|
|
|
|
use variables, only : iph
|
|
|
|
#endif /* GLM */
|
2010-02-11 23:30:46 -02:00
|
|
|
#endif /* MHD */
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer(kind=4), dimension(3) :: dm
|
|
|
|
integer :: i, j, k
|
2009-09-22 17:30:53 -03:00
|
|
|
real :: r, dx, dy, dz, pr
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2010-02-28 18:35:57 -03:00
|
|
|
real, dimension(im) :: x
|
|
|
|
real, dimension(jm) :: y
|
|
|
|
real, dimension(km) :: z
|
|
|
|
real, dimension(nvr,im) :: q, u
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-09 14:51:33 -06:00
|
|
|
! calculate parameters
|
|
|
|
!
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2009-09-22 17:30:53 -03:00
|
|
|
pr = dens * csnd2 / gamma
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2008-12-09 14:51:33 -06:00
|
|
|
|
2008-11-11 16:12:26 -06:00
|
|
|
! calculate cell sizes
|
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
dx = (pblock%meta%xmax - pblock%meta%xmin) / in
|
|
|
|
dy = (pblock%meta%ymax - pblock%meta%ymin) / jn
|
2008-12-08 15:31:35 -06:00
|
|
|
#if NDIMS == 3
|
2009-09-25 11:41:19 -03:00
|
|
|
dz = (pblock%meta%zmax - pblock%meta%zmin) / kn
|
2008-12-08 15:31:35 -06:00
|
|
|
#else /* NDIMS == 3 */
|
2008-11-11 16:12:26 -06:00
|
|
|
dz = 1.0
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
! generate coordinates
|
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng - 0.5) * dx + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng - 0.5) * dy + pblock%meta%ymin
|
2008-12-08 15:31:35 -06:00
|
|
|
#if NDIMS == 3
|
2009-09-25 11:41:19 -03:00
|
|
|
z(:) = ((/(k, k = 1, km)/) - ng - 0.5) * dz + pblock%meta%zmin
|
2008-12-08 15:31:35 -06:00
|
|
|
#else /* NDIMS == 3 */
|
2008-11-11 16:12:26 -06:00
|
|
|
z(1) = 0.0
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
! set variables
|
|
|
|
!
|
2009-09-22 17:30:53 -03:00
|
|
|
q(idn,:) = dens
|
|
|
|
q(ivx,:) = 0.0d0
|
|
|
|
q(ivy,:) = 0.0d0
|
|
|
|
q(ivz,:) = 0.0d0
|
2009-10-28 00:12:18 -02:00
|
|
|
#ifdef MHD
|
|
|
|
q(ibx,:) = 0.70710678118654752440
|
|
|
|
q(iby,:) = 0.70710678118654752440
|
|
|
|
q(ibz,:) = 0.0d0
|
2010-02-28 18:35:57 -03:00
|
|
|
#ifdef FLUXCT
|
|
|
|
q(icx,:) = 0.70710678118654752440
|
|
|
|
q(icy,:) = 0.70710678118654752440
|
|
|
|
q(icz,:) = 0.0d0
|
|
|
|
#endif /* FLUXCT */
|
2010-12-01 12:42:17 -02:00
|
|
|
#ifdef GLM
|
|
|
|
q(iph,:) = 0.0d0
|
|
|
|
#endif /* GLM */
|
2009-10-28 00:12:18 -02:00
|
|
|
#endif /* MHD */
|
2008-11-11 16:12:26 -06:00
|
|
|
|
|
|
|
! set initial pressure
|
|
|
|
!
|
2008-12-13 21:05:51 -06:00
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
2010-02-28 18:35:57 -03:00
|
|
|
|
|
|
|
! fill out the pressure profile
|
|
|
|
!
|
2008-12-13 21:05:51 -06:00
|
|
|
do i = 1, im
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
r = sqrt(x(i)**2 + y(j)**2 + z(k)**2)
|
2009-09-22 17:30:53 -03:00
|
|
|
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ISO
|
|
|
|
if (r .lt. rcut) then
|
|
|
|
q(idn,i) = dens * dnrat
|
|
|
|
else
|
|
|
|
q(idn,i) = dens
|
|
|
|
end if
|
|
|
|
#endif /* ISO */
|
|
|
|
#ifdef ADI
|
2009-09-22 17:30:53 -03:00
|
|
|
if (r .lt. rcut) then
|
|
|
|
q(ipr,i) = pr * dnrat
|
2008-12-18 10:20:15 -06:00
|
|
|
else
|
2009-09-22 17:30:53 -03:00
|
|
|
q(ipr,i) = pr
|
2010-02-28 18:35:57 -03:00
|
|
|
end if
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2008-12-18 10:20:15 -06:00
|
|
|
|
|
|
|
end do
|
2009-09-22 17:30:53 -03:00
|
|
|
|
|
|
|
! convert primitive variables to conserved
|
|
|
|
!
|
2010-02-28 18:35:57 -03:00
|
|
|
call prim2cons(im, q, u)
|
|
|
|
|
|
|
|
! copy conservative variables to the current block
|
|
|
|
!
|
|
|
|
pblock%u(1:nqt,1:im,j,k) = u(1:nqt,1:im)
|
2009-09-22 17:30:53 -03:00
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine init_blast
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! init_implosion: subroutine initializes variables for the implosion problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_implosion(pblock)
|
|
|
|
|
2010-12-01 09:25:30 -02:00
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : in, jn, kn, im, jm, km, ng, dens, pres, rmid, gammam1i
|
|
|
|
use variables, only : idn, imx, imy, imz
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2010-12-01 09:25:30 -02:00
|
|
|
use variables, only : ien
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2008-12-18 10:20:15 -06:00
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
2008-12-18 10:20:15 -06:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer(kind=4), dimension(3) :: dm
|
|
|
|
integer :: i, j, k
|
|
|
|
real :: dx, dy, dxh, dyh, rc, rl, ru, ds, dl, dr
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real, dimension(:), allocatable :: x, y
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! allocate coordinates
|
|
|
|
!
|
|
|
|
allocate(x(im))
|
|
|
|
allocate(y(jm))
|
|
|
|
|
|
|
|
! calculate cell sizes
|
2008-12-16 22:34:54 -06:00
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
dx = (pblock%meta%xmax - pblock%meta%xmin) / in
|
|
|
|
dy = (pblock%meta%ymax - pblock%meta%ymin) / jn
|
2008-12-18 10:20:15 -06:00
|
|
|
dxh = 0.5d0 * dx
|
|
|
|
dyh = 0.5d0 * dy
|
|
|
|
ds = dx * dy
|
2008-12-16 22:34:54 -06:00
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
! generate coordinates
|
2008-12-16 22:34:54 -06:00
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng) * dx - dxh + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng) * dy - dyh + pblock%meta%ymin
|
2008-12-18 10:20:15 -06:00
|
|
|
|
|
|
|
! set variables
|
|
|
|
!
|
|
|
|
pblock%u(idn,:,:,:) = dens
|
|
|
|
pblock%u(imx,:,:,:) = 0.0d0
|
|
|
|
pblock%u(imy,:,:,:) = 0.0d0
|
|
|
|
pblock%u(imz,:,:,:) = 0.0d0
|
2008-12-06 20:11:36 -06:00
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
! set initial pressure
|
|
|
|
!
|
|
|
|
do j = 1, jm
|
|
|
|
do i = 1, im
|
|
|
|
rc = x(i) + y(j)
|
|
|
|
rl = rc - dxh - dyh
|
|
|
|
ru = rc + dxh + dyh
|
|
|
|
|
|
|
|
if (ru .le. rmid) then
|
|
|
|
pblock%u(idn,i,j,:) = 0.125d0
|
|
|
|
#ifdef ADI
|
|
|
|
pblock%u(ien,i,j,:) = gammam1i * 0.140d0
|
|
|
|
#endif /* ADI */
|
|
|
|
else if (rl .ge. rmid) then
|
|
|
|
pblock%u(idn,i,j,:) = 1.0d0
|
|
|
|
#ifdef ADI
|
|
|
|
pblock%u(ien,i,j,:) = gammam1i
|
|
|
|
#endif /* ADI */
|
|
|
|
else
|
|
|
|
if (rc .ge. rmid) then
|
|
|
|
dl = 0.125d0 * (rmid - rl)**2 / ds
|
|
|
|
dr = 1.0d0 - dl
|
2008-11-11 16:12:26 -06:00
|
|
|
else
|
2008-12-18 10:20:15 -06:00
|
|
|
dr = 0.125d0 * (ru - rmid)**2 / ds
|
|
|
|
dl = 1.0d0 - dr
|
2008-11-11 16:12:26 -06:00
|
|
|
endif
|
2008-12-18 10:20:15 -06:00
|
|
|
pblock%u(idn,i,j,:) = 0.125d0 * dl + dr
|
|
|
|
#ifdef ADI
|
|
|
|
pblock%u(ien,i,j,:) = gammam1i * (0.140d0 * dl + dr)
|
|
|
|
#endif /* ADI */
|
|
|
|
endif
|
2008-11-11 16:12:26 -06:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! deallocate coordinates
|
|
|
|
!
|
|
|
|
deallocate(x)
|
|
|
|
deallocate(y)
|
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
end subroutine init_implosion
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
!===============================================================================
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
2008-12-18 11:09:42 -06:00
|
|
|
! init_binaries: subroutine initializes the variables for the binary star
|
|
|
|
! problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_binaries(pblock)
|
|
|
|
|
2010-12-01 09:25:30 -02:00
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : ng, in, jn, kn, im, jm, km, dens, pres, dnfac, dnrat &
|
|
|
|
, x1c, y1c, z1c, r1c, x2c, y2c, z2c, r2c, v1ini, v2ini &
|
|
|
|
, csnd2, gamma, gammam1i
|
|
|
|
use variables, only : idn, imx, imy, imz
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2010-12-01 09:25:30 -02:00
|
|
|
use variables, only : ien
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2008-12-18 11:09:42 -06:00
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
2008-12-18 11:09:42 -06:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i, j, k
|
2008-12-31 12:57:31 -06:00
|
|
|
real :: dx, dy, dz, dnamb, enamb, ekin
|
2008-12-18 11:09:42 -06:00
|
|
|
real :: dnstar1, enstar1, x1l, y1l, z1l, r1
|
|
|
|
real :: dnstar2, enstar2, x2l, y2l, z2l, r2
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real, dimension(:), allocatable :: x, y, z
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! calculate pressure from sound speed
|
|
|
|
!
|
|
|
|
#ifdef ISO
|
|
|
|
pres = csnd2 * dens
|
|
|
|
#endif /* ISO */
|
|
|
|
#ifdef ADI
|
|
|
|
pres = csnd2 * dens / gamma
|
|
|
|
#endif /* ADI */
|
|
|
|
|
|
|
|
! calculate parameters
|
|
|
|
!
|
|
|
|
dnamb = dens
|
|
|
|
dnstar2 = dnamb*dnfac
|
|
|
|
dnstar1 = dnstar2*dnrat
|
|
|
|
enamb = gammam1i*pres
|
|
|
|
enstar1 = enamb*dnfac
|
|
|
|
enstar2 = enstar1/dnrat
|
|
|
|
|
|
|
|
! allocate coordinates
|
|
|
|
!
|
|
|
|
allocate(x(im))
|
|
|
|
allocate(y(jm))
|
|
|
|
allocate(z(km))
|
|
|
|
|
|
|
|
! calculate cell sizes
|
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
dx = (pblock%meta%xmax - pblock%meta%xmin) / in
|
|
|
|
dy = (pblock%meta%ymax - pblock%meta%ymin) / jn
|
2008-12-18 11:09:42 -06:00
|
|
|
#if NDIMS == 3
|
2009-09-25 11:41:19 -03:00
|
|
|
dz = (pblock%meta%zmax - pblock%meta%zmin) / kn
|
2008-12-18 11:09:42 -06:00
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
dz = 1.0
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! generate coordinates
|
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng - 0.5) * dx + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng - 0.5) * dy + pblock%meta%ymin
|
2008-12-18 11:09:42 -06:00
|
|
|
#if NDIMS == 3
|
2009-09-25 11:41:19 -03:00
|
|
|
z(:) = ((/(k, k = 1, km)/) - ng - 0.5) * dz + pblock%meta%zmin
|
2008-12-18 11:09:42 -06:00
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
z(1) = 0.0
|
2008-12-31 12:57:31 -06:00
|
|
|
|
|
|
|
z1l = 0.0
|
|
|
|
z2l = 0.0
|
2008-12-18 11:09:42 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! set variables
|
|
|
|
!
|
|
|
|
pblock%u(idn,:,:,:) = dnamb
|
|
|
|
pblock%u(imx,:,:,:) = 0.0d0
|
|
|
|
pblock%u(imy,:,:,:) = 0.0d0
|
|
|
|
pblock%u(imz,:,:,:) = 0.0d0
|
|
|
|
#ifdef ADI
|
|
|
|
pblock%u(ien,:,:,:) = enamb
|
|
|
|
#endif /* ADI */
|
|
|
|
|
|
|
|
! set initial pressure
|
|
|
|
!
|
|
|
|
do k = 1, km
|
2008-12-31 12:57:31 -06:00
|
|
|
#if NDIMS == 3
|
2008-12-18 11:09:42 -06:00
|
|
|
z1l = z(k) - z1c
|
|
|
|
z2l = z(k) - z2c
|
2008-12-31 12:57:31 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-18 11:09:42 -06:00
|
|
|
|
|
|
|
do j = 1, jm
|
|
|
|
y1l = y(j) - y1c
|
|
|
|
y2l = y(j) - y2c
|
|
|
|
|
|
|
|
do i = 1, im
|
|
|
|
x1l = x(i) - x1c
|
|
|
|
x2l = x(i) - x2c
|
|
|
|
|
|
|
|
r1 = sqrt(x1l**2 + y1l**2 + z1l**2)
|
|
|
|
r2 = sqrt(x2l**2 + y2l**2 + z2l**2)
|
|
|
|
|
|
|
|
if (r1 .le. r1c) then
|
|
|
|
pblock%u(idn,i,j,k) = dnstar1
|
2008-12-31 12:57:31 -06:00
|
|
|
pblock%u(imx,i,j,k) = dnstar1*v1ini*x1l
|
|
|
|
pblock%u(imy,i,j,k) = dnstar1*v1ini*y1l
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%u(imz,i,j,k) = dnstar1*v1ini*z1l
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
ekin = 0.5 * dnstar1 * v1ini**2 * (x1l**2 + y1l**2 + z1l**2)
|
2008-12-18 11:09:42 -06:00
|
|
|
#ifdef ADI
|
2008-12-31 12:57:31 -06:00
|
|
|
pblock%u(ien,i,j,k) = enstar1 + ekin
|
2008-12-18 11:09:42 -06:00
|
|
|
#endif /* ADI */
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (r2 .le. r2c) then
|
|
|
|
pblock%u(idn,i,j,k) = dnstar2
|
2008-12-31 12:57:31 -06:00
|
|
|
pblock%u(imx,i,j,k) = dnstar2*v2ini*x2l
|
|
|
|
pblock%u(imy,i,j,k) = dnstar2*v2ini*y2l
|
|
|
|
#if NDIMS == 3
|
|
|
|
pblock%u(imz,i,j,k) = dnstar2*v2ini*z2l
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
ekin = 0.5 * dnstar2 * v2ini**2 * (x2l**2 + y2l**2 + z2l**2)
|
2008-12-18 11:09:42 -06:00
|
|
|
#ifdef ADI
|
2008-12-31 12:57:31 -06:00
|
|
|
pblock%u(ien,i,j,k) = enstar2 + ekin
|
2008-12-18 11:09:42 -06:00
|
|
|
#endif /* ADI */
|
|
|
|
endif
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! deallocate coordinates
|
|
|
|
!
|
|
|
|
deallocate(x)
|
|
|
|
deallocate(y)
|
|
|
|
deallocate(z)
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine init_binaries
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! init_reconnection: subroutine initializes the variables for the reconnection
|
|
|
|
! problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_reconnection(pblock)
|
|
|
|
|
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : in, jn, kn, im, jm, km, ng &
|
2010-12-02 09:54:17 -02:00
|
|
|
, xmin, xmax, dens, pres, bamp, bper, ydel, ycut
|
2010-12-01 21:08:45 -02:00
|
|
|
use scheme , only : prim2cons
|
2010-12-02 09:54:17 -02:00
|
|
|
use variables, only : nvr, nqt
|
|
|
|
use variables, only : idn, ivx, ivy, ivz
|
2010-12-01 21:08:45 -02:00
|
|
|
#ifdef ADI
|
|
|
|
use variables, only : ipr
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
use variables, only : ibx, iby, ibz
|
|
|
|
#ifdef FLUXCT
|
|
|
|
use variables, only : icx, icy, icz
|
|
|
|
#endif /* FLUXCT */
|
|
|
|
#ifdef GLM
|
|
|
|
use variables, only : iph
|
|
|
|
#endif /* GLM */
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer(kind=4), dimension(3) :: dm
|
|
|
|
integer :: i, j, k
|
2010-12-02 09:54:17 -02:00
|
|
|
real :: xlen, dx, dy, dz
|
2010-12-01 21:08:45 -02:00
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real, dimension(im) :: x
|
|
|
|
real, dimension(jm) :: y
|
|
|
|
real, dimension(km) :: z
|
|
|
|
real, dimension(nvr,im) :: q, u
|
|
|
|
|
|
|
|
! parameters
|
|
|
|
!
|
2010-12-02 09:54:17 -02:00
|
|
|
real, parameter :: pi = 3.1415926535897931159979634685442d0
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2010-12-02 09:54:17 -02:00
|
|
|
! calculate the length of the box
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
2010-12-02 09:54:17 -02:00
|
|
|
xlen = xmax - xmin
|
2010-12-01 21:08:45 -02:00
|
|
|
|
2010-12-02 09:54:17 -02:00
|
|
|
! calculate the cell sizes
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
|
|
|
dx = (pblock%meta%xmax - pblock%meta%xmin) / in
|
|
|
|
dy = (pblock%meta%ymax - pblock%meta%ymin) / jn
|
|
|
|
#if NDIMS == 3
|
|
|
|
dz = (pblock%meta%zmax - pblock%meta%zmin) / kn
|
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
dz = 1.0
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
2010-12-02 09:54:17 -02:00
|
|
|
! generate the coordinates
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng - 0.5) * dx + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng - 0.5) * dy + pblock%meta%ymin
|
|
|
|
#if NDIMS == 3
|
|
|
|
z(:) = ((/(k, k = 1, km)/) - ng - 0.5) * dz + pblock%meta%zmin
|
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
z(1) = 0.0
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! set variables
|
|
|
|
!
|
|
|
|
q(idn,:) = dens
|
|
|
|
q(ivx,:) = 0.0d0
|
|
|
|
q(ivy,:) = 0.0d0
|
|
|
|
q(ivz,:) = 0.0d0
|
2010-12-02 09:54:17 -02:00
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,:) = pres
|
|
|
|
#endif /* ADI */
|
2010-12-01 21:08:45 -02:00
|
|
|
#ifdef MHD
|
|
|
|
q(ibx,:) = 0.0d0
|
|
|
|
q(iby,:) = 0.0d0
|
|
|
|
q(ibz,:) = 0.0d0
|
|
|
|
#ifdef FLUXCT
|
|
|
|
q(ibx,:) = 0.0d0
|
|
|
|
q(iby,:) = 0.0d0
|
|
|
|
q(ibz,:) = 0.0d0
|
|
|
|
#endif /* FLUXCT */
|
|
|
|
#ifdef GLM
|
|
|
|
q(iph,:) = 0.0d0
|
|
|
|
#endif /* GLM */
|
|
|
|
#endif /* MHD */
|
|
|
|
|
2010-12-02 09:54:17 -02:00
|
|
|
! set the initial profiles
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
|
|
|
|
2010-12-02 09:54:17 -02:00
|
|
|
! initialize the magnetic field components
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
|
|
|
do i = 1, im
|
2010-12-02 09:54:17 -02:00
|
|
|
q(ibx,i) = bamp * tanh(y(j) / ydel)
|
|
|
|
q(iby,i) = bper * sin(pi * x(i) / xlen) &
|
|
|
|
* exp(- 0.5d0 * (y(j) / ycut)**2)
|
2010-12-01 21:08:45 -02:00
|
|
|
end do
|
|
|
|
|
|
|
|
! convert primitive variables to conserved
|
|
|
|
!
|
2010-12-02 09:54:17 -02:00
|
|
|
call prim2cons(im, q(:,:), u(:,:))
|
2010-12-01 21:08:45 -02:00
|
|
|
|
|
|
|
! copy conservative variables to the current block
|
|
|
|
!
|
|
|
|
pblock%u(1:nqt,1:im,j,k) = u(1:nqt,1:im)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine init_reconnection
|
2008-12-18 12:18:36 -06:00
|
|
|
#ifdef SHAPE
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! shape_binaries: subroutine initializes the variables for the binary star
|
|
|
|
! problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine shape_binaries(pblock, du)
|
|
|
|
|
2010-12-01 09:25:30 -02:00
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : ng, in, jn, kn, im, jm, km, dens, pres, dnfac, dnrat &
|
|
|
|
, x1c, y1c, z1c, r1c, x2c, y2c, z2c, r2c &
|
|
|
|
, csnd2, gamma, gammam1i
|
|
|
|
use variables, only : idn, imx, imy, imz, ien
|
2008-12-18 12:18:36 -06:00
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
|
|
|
real, dimension(:,:,:,:) , intent(inout) :: du
|
2008-12-18 12:18:36 -06:00
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
|
|
|
integer :: i, j, k
|
|
|
|
real :: dx, dy, dz
|
|
|
|
real :: x1l, y1l, z1l, r1
|
|
|
|
real :: x2l, y2l, z2l, r2
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real, dimension(:), allocatable :: x, y, z
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! allocate coordinates
|
|
|
|
!
|
|
|
|
allocate(x(im))
|
|
|
|
allocate(y(jm))
|
|
|
|
allocate(z(km))
|
|
|
|
|
|
|
|
! calculate cell sizes
|
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
dx = (pblock%meta%xmax - pblock%meta%xmin) / in
|
|
|
|
dy = (pblock%meta%ymax - pblock%meta%ymin) / jn
|
2008-12-18 12:18:36 -06:00
|
|
|
#if NDIMS == 3
|
2009-09-25 11:41:19 -03:00
|
|
|
dz = (pblock%meta%zmax - pblock%meta%zmin) / kn
|
2008-12-18 12:18:36 -06:00
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
dz = 1.0
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! generate coordinates
|
|
|
|
!
|
2009-09-25 11:41:19 -03:00
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng - 0.5) * dx + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng - 0.5) * dy + pblock%meta%ymin
|
2008-12-18 12:18:36 -06:00
|
|
|
#if NDIMS == 3
|
2009-09-25 11:41:19 -03:00
|
|
|
z(:) = ((/(k, k = 1, km)/) - ng - 0.5) * dz + pblock%meta%zmin
|
2008-12-18 12:18:36 -06:00
|
|
|
#else /* NDIMS == 3 */
|
|
|
|
z(1) = 0.0
|
2008-12-31 12:57:31 -06:00
|
|
|
|
|
|
|
z1l = 0.0
|
|
|
|
z2l = 0.0
|
2008-12-18 12:18:36 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! reset update
|
|
|
|
!
|
|
|
|
do k = 1, km
|
2008-12-31 12:57:31 -06:00
|
|
|
#if NDIMS == 3
|
2008-12-18 12:18:36 -06:00
|
|
|
z1l = z(k) - z1c
|
|
|
|
z2l = z(k) - z2c
|
2008-12-31 12:57:31 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-18 12:18:36 -06:00
|
|
|
|
|
|
|
do j = 1, jm
|
|
|
|
y1l = y(j) - y1c
|
|
|
|
y2l = y(j) - y2c
|
|
|
|
|
|
|
|
do i = 1, im
|
|
|
|
x1l = x(i) - x1c
|
|
|
|
x2l = x(i) - x2c
|
|
|
|
|
|
|
|
r1 = sqrt(x1l**2 + y1l**2 + z1l**2)
|
|
|
|
r2 = sqrt(x2l**2 + y2l**2 + z2l**2)
|
|
|
|
|
|
|
|
if (r1 .le. r1c) then
|
|
|
|
du(:,i,j,k) = 0.0
|
|
|
|
endif
|
|
|
|
|
|
|
|
if (r2 .le. r2c) then
|
|
|
|
du(:,i,j,k) = 0.0
|
|
|
|
endif
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! deallocate coordinates
|
|
|
|
!
|
|
|
|
deallocate(x)
|
|
|
|
deallocate(y)
|
|
|
|
deallocate(z)
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine shape_binaries
|
|
|
|
#endif /* SHAPE */
|
2008-12-18 11:09:42 -06:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2008-11-29 22:19:02 -06:00
|
|
|
! check_ref: function checks refinement criterium and returns +1 if
|
|
|
|
! the criterium fullfiled and block is selected for
|
|
|
|
! refinement, 0 there is no need for refinement, and -1 if
|
|
|
|
! block is selected for refinement
|
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
!===============================================================================
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
|
|
|
function check_ref(pblock)
|
|
|
|
|
2010-12-01 09:25:30 -02:00
|
|
|
use blocks , only : block_data
|
2010-12-01 15:57:58 -02:00
|
|
|
use config , only : im, jm, km, ibl, ieu, jbl, jeu, kbl, keu &
|
2010-12-01 09:25:30 -02:00
|
|
|
, crefmin, crefmax
|
2010-12-01 15:57:58 -02:00
|
|
|
use scheme , only : cons2prim
|
|
|
|
use variables, only : nvr, nqt
|
|
|
|
use variables, only : idn
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2010-12-01 15:57:58 -02:00
|
|
|
use variables, only : ipr
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2010-12-01 15:57:58 -02:00
|
|
|
#ifdef MHD
|
|
|
|
use variables, only : ibx, iby, ibz
|
|
|
|
#endif /* MHD */
|
2008-11-29 22:19:02 -06:00
|
|
|
|
|
|
|
! input arguments
|
|
|
|
!
|
2009-09-11 21:52:18 -03:00
|
|
|
type(block_data), pointer, intent(inout) :: pblock
|
2008-11-29 22:19:02 -06:00
|
|
|
|
|
|
|
! return variable
|
|
|
|
!
|
|
|
|
integer(kind=1) :: check_ref
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2009-09-29 15:56:25 -03:00
|
|
|
integer :: i, j, k
|
2010-12-01 15:57:58 -02:00
|
|
|
real :: dpmax
|
|
|
|
real :: dnl, dnr, ddndx, ddndy, ddndz, ddn
|
|
|
|
#ifdef ADI
|
|
|
|
real :: prl, prr, dprdx, dprdy, dprdz, dpr
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
real :: bxl, bxr, dbxdx, dbxdy, dbxdz, dbx
|
|
|
|
real :: byl, byr, dbydx, dbydy, dbydz, dby
|
|
|
|
real :: bzl, bzr, dbzdx, dbzdy, dbzdz, dbz
|
|
|
|
#endif /* MHD */
|
2009-09-29 15:56:25 -03:00
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2010-12-01 15:57:58 -02:00
|
|
|
real, dimension(nvr,im) :: u, q
|
|
|
|
real, dimension(im,jm,km) :: dn
|
|
|
|
#ifdef ADI
|
|
|
|
real, dimension(im,jm,km) :: pr
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
real, dimension(im,jm,km) :: bx, by, bz
|
|
|
|
#endif /* MHD */
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
2008-12-18 10:20:15 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2010-12-01 15:57:58 -02:00
|
|
|
!
|
|
|
|
! convert conserved variables to primitive ones
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
2008-12-13 15:08:18 -06:00
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
2010-12-01 15:57:58 -02:00
|
|
|
dn(1:im,j,k) = pblock%u(idn,1:im,j,k)
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2010-12-01 15:57:58 -02:00
|
|
|
u(1:nqt,1:im) = pblock%u(1:nqt,1:im,j,k)
|
|
|
|
|
|
|
|
call cons2prim(im, u(:,:), q(:,:))
|
|
|
|
|
|
|
|
pr(1:im,j,k) = q(ipr,1:im)
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2010-12-01 15:57:58 -02:00
|
|
|
#ifdef MHD
|
|
|
|
bx(1:im,j,k) = pblock%u(ibx,1:im,j,k)
|
|
|
|
by(1:im,j,k) = pblock%u(iby,1:im,j,k)
|
|
|
|
bz(1:im,j,k) = pblock%u(ibz,1:im,j,k)
|
|
|
|
#endif /* MHD */
|
2008-12-13 15:08:18 -06:00
|
|
|
end do
|
|
|
|
end do
|
2008-11-29 22:19:02 -06:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! reset indicators
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
|
|
|
dpmax = 0.0d0
|
2010-12-01 15:57:58 -02:00
|
|
|
ddn = 0.0d0
|
|
|
|
#ifdef ADI
|
|
|
|
dpr = 0.0d0
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
dbx = 0.0d0
|
|
|
|
dby = 0.0d0
|
|
|
|
dbz = 0.0d0
|
|
|
|
#endif /* MHD */
|
|
|
|
|
2008-11-29 22:19:02 -06:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! check gradients of selected variables
|
|
|
|
!
|
2009-09-09 14:21:46 -03:00
|
|
|
do k = kbl, keu
|
|
|
|
do j = jbl, jeu
|
|
|
|
do i = ibl, ieu
|
2010-02-11 23:30:46 -02:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! density
|
|
|
|
!
|
2008-12-16 13:40:34 -06:00
|
|
|
dnl = dn(i-1,j,k)
|
|
|
|
dnr = dn(i+1,j,k)
|
2010-12-01 15:57:58 -02:00
|
|
|
ddndx = abs(dnr - dnl) / (dnr + dnl)
|
2008-12-16 13:40:34 -06:00
|
|
|
dnl = dn(i,j-1,k)
|
|
|
|
dnr = dn(i,j+1,k)
|
2010-12-01 15:57:58 -02:00
|
|
|
ddndy = abs(dnr - dnl) / (dnr + dnl)
|
|
|
|
#if NDIMS == 2
|
|
|
|
|
|
|
|
ddn = sqrt(ddndx**2 + ddndy**2)
|
|
|
|
#else /* NDIMS == 2 */
|
2009-09-29 15:56:25 -03:00
|
|
|
dnl = dn(i,j,k-1)
|
|
|
|
dnr = dn(i,j,k+1)
|
2010-12-01 15:57:58 -02:00
|
|
|
ddndz = abs(dnr - dnl) / (dnr + dnl)
|
2009-09-29 15:56:25 -03:00
|
|
|
|
|
|
|
ddn = sqrt(ddndx**2 + ddndy**2 + ddndz**2)
|
2010-12-01 15:57:58 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
2008-12-16 13:40:34 -06:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! update the indicator
|
|
|
|
!
|
2010-03-30 23:23:49 -03:00
|
|
|
dpmax = max(dpmax, ddn)
|
|
|
|
|
|
|
|
#ifdef ADI
|
2010-12-01 15:57:58 -02:00
|
|
|
! pressure
|
|
|
|
!
|
2008-12-16 13:40:34 -06:00
|
|
|
prl = pr(i-1,j,k)
|
|
|
|
prr = pr(i+1,j,k)
|
2010-12-01 15:57:58 -02:00
|
|
|
dprdx = abs(prr - prl) / (prr + prl)
|
2008-12-16 13:40:34 -06:00
|
|
|
prl = pr(i,j-1,k)
|
|
|
|
prr = pr(i,j+1,k)
|
2010-12-01 15:57:58 -02:00
|
|
|
dprdy = abs(prr - prl) / (prr + prl)
|
|
|
|
#if NDIMS == 2
|
|
|
|
|
|
|
|
dpr = sqrt(dprdx**2 + dprdy**2)
|
|
|
|
#else /* NDIMS == 2 */
|
2009-09-29 15:56:25 -03:00
|
|
|
prl = pr(i,j,k-1)
|
|
|
|
prr = pr(i,j,k+1)
|
2010-12-01 15:57:58 -02:00
|
|
|
dprdz = abs(prr - prl) / (prr + prl)
|
2009-09-29 15:56:25 -03:00
|
|
|
|
|
|
|
dpr = sqrt(dprdx**2 + dprdy**2 + dprdz**2)
|
2010-12-01 15:57:58 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
2008-12-16 13:40:34 -06:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! update the indicator
|
|
|
|
!
|
2010-03-30 23:23:49 -03:00
|
|
|
dpmax = max(dpmax, dpr)
|
|
|
|
#endif /* ADI */
|
2008-12-16 13:40:34 -06:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
#ifdef MHD
|
|
|
|
! X magnetic component
|
|
|
|
!
|
|
|
|
bxl = bx(i-1,j,k)
|
|
|
|
bxr = bx(i+1,j,k)
|
|
|
|
dbxdx = abs(bxr - bxl) / max(1.0d-16, abs(bxr) + abs(bxl))
|
|
|
|
bxl = bx(i,j-1,k)
|
|
|
|
bxr = bx(i,j+1,k)
|
|
|
|
dbxdy = abs(bxr - bxl) / max(1.0d-16, abs(bxr) + abs(bxl))
|
|
|
|
#if NDIMS == 2
|
|
|
|
|
|
|
|
dbx = sqrt(dbxdx**2 + dbxdy**2)
|
|
|
|
#else /* NDIMS == 2 */
|
|
|
|
bxl = bx(i,j,k-1)
|
|
|
|
bxr = bx(i,j,k+1)
|
|
|
|
dbxdz = abs(bxr - bxl) / max(1.0d-16, abs(bxr) + abs(bxl))
|
|
|
|
|
|
|
|
dbx = sqrt(dbxdx**2 + dbxdy**2 + dbxdz**2)
|
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
|
|
|
|
! Y magnetic component
|
|
|
|
!
|
|
|
|
byl = by(i-1,j,k)
|
|
|
|
byr = by(i+1,j,k)
|
|
|
|
dbydx = abs(byr - byl) / max(1.0d-16, abs(byr) + abs(byl))
|
|
|
|
byl = by(i,j-1,k)
|
|
|
|
byr = by(i,j+1,k)
|
|
|
|
dbydy = abs(byr - byl) / max(1.0d-16, abs(byr) + abs(byl))
|
|
|
|
#if NDIMS == 2
|
|
|
|
|
|
|
|
dby = sqrt(dbydx**2 + dbydy**2)
|
|
|
|
#else /* NDIMS == 2 */
|
|
|
|
byl = by(i,j,k-1)
|
|
|
|
byr = by(i,j,k+1)
|
|
|
|
dbydz = abs(byr - byl) / max(1.0d-16, abs(byr) + abs(byl))
|
|
|
|
|
|
|
|
dby = sqrt(dbydx**2 + dbydy**2 + dbydz**2)
|
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
|
|
|
|
! Z magnetic component
|
|
|
|
!
|
|
|
|
bzl = bz(i-1,j,k)
|
|
|
|
bzr = bz(i+1,j,k)
|
|
|
|
dbzdx = abs(bzr - bzl) / max(1.0d-16, abs(bzr) + abs(bzl))
|
|
|
|
bzl = bz(i,j-1,k)
|
|
|
|
bzr = bz(i,j+1,k)
|
|
|
|
dbzdy = abs(bzr - bzl) / max(1.0d-16, abs(bzr) + abs(bzl))
|
|
|
|
#if NDIMS == 2
|
|
|
|
|
|
|
|
dbz = sqrt(dbzdx**2 + dbzdy**2)
|
|
|
|
#else /* NDIMS == 2 */
|
|
|
|
bzl = bz(i,j,k-1)
|
|
|
|
bzr = bz(i,j,k+1)
|
|
|
|
dbzdz = abs(bzr - bzl) / max(1.0d-16, abs(bzr) + abs(bzl))
|
|
|
|
|
|
|
|
dbz = sqrt(dbzdx**2 + dbzdy**2 + dbzdz**2)
|
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
|
|
|
|
! update the indicator
|
|
|
|
!
|
|
|
|
dpmax = max(dpmax, dbx, dby, dbz)
|
|
|
|
#endif /* MHD */
|
|
|
|
|
2008-11-29 22:19:02 -06:00
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! return the refinement flag depending on the condition value
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
|
|
|
check_ref = 0
|
|
|
|
|
2010-03-08 19:09:49 -03:00
|
|
|
if (dpmax .ge. crefmax) then
|
2008-11-29 22:19:02 -06:00
|
|
|
check_ref = 1
|
2010-03-08 19:09:49 -03:00
|
|
|
end if
|
|
|
|
if (dpmax .le. crefmin) then
|
|
|
|
check_ref = -1
|
|
|
|
end if
|
2008-11-29 22:19:02 -06:00
|
|
|
|
|
|
|
return
|
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
2008-11-29 22:19:02 -06:00
|
|
|
!
|
|
|
|
end function check_ref
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2008-12-18 10:20:15 -06:00
|
|
|
!===============================================================================
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
|
|
|
end module
|