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
|
|
|
!!
|
2011-02-27 22:45:54 -03:00
|
|
|
!! Copyright (C) 2008-2011 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
|
|
|
!!
|
2011-04-25 13:44:34 -03:00
|
|
|
!! This file is part of AMUN.
|
2008-11-11 16:12:26 -06:00
|
|
|
!!
|
2011-04-25 13:44:34 -03:00
|
|
|
!! AMUN is free software; you can redistribute it and/or modify
|
2008-11-11 16:12:26 -06:00
|
|
|
!! 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.
|
|
|
|
!!
|
2011-04-25 13:44:34 -03:00
|
|
|
!! AMUN is distributed in the hope that it will be useful,
|
2008-11-11 16:12:26 -06:00
|
|
|
!! 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
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2011-02-26 14:08:10 -03:00
|
|
|
subroutine init_domain()
|
2008-12-22 15:34:02 -06:00
|
|
|
|
|
|
|
use config, only : problem
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
select case(trim(problem))
|
|
|
|
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)
|
2011-03-18 14:00:27 -03:00
|
|
|
case("multi_current_sheet")
|
|
|
|
call init_multi_current_sheet(pb)
|
2010-12-08 22:05:18 -02:00
|
|
|
case("turbulence")
|
|
|
|
call init_turbulence(pb)
|
2011-03-24 19:26:57 -03:00
|
|
|
case("orszag_tang")
|
|
|
|
call init_orszag_tang(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
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
! domain_default: subroutine initializes the default domain of N1xN2xN3 blocks
|
|
|
|
! in the proper configuration; the dimensions N1xN2xN3 are set
|
|
|
|
! in variable rdims
|
2008-12-22 15:34:02 -06:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
subroutine domain_default()
|
2008-12-22 15:34:02 -06:00
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
use blocks, only : pointer_meta, 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 &
|
2010-12-21 20:25:17 -02:00
|
|
|
, nsides, nfaces, res
|
2009-09-10 18:23:18 -03:00
|
|
|
use config, only : xlbndry, xubndry, ylbndry, yubndry, zlbndry, zubndry &
|
2010-12-21 20:25:17 -02:00
|
|
|
, xmin, xmax, ymin, ymax, zmin, zmax, rdims
|
2008-12-22 15:34:02 -06:00
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
integer :: i, j, k, n, p, il, jl, kl
|
2010-12-21 20:25:17 -02:00
|
|
|
real :: xl, xmn, xmx, yl, ymn, ymx, zl, zmn, zmx
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
integer, dimension(3) :: loc, del
|
2008-12-22 15:34:02 -06:00
|
|
|
|
|
|
|
! local pointers
|
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
type(block_meta), pointer :: pmeta, pnext
|
2009-09-26 14:27:47 -03:00
|
|
|
type(block_data), pointer :: pdata
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! allocatable arrays
|
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
integer, dimension(:,:,:), allocatable :: cfg
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! local pointer array
|
|
|
|
!
|
|
|
|
type(pointer_meta), dimension(:,:,:), allocatable :: block_array
|
2008-12-22 15:34:02 -06:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
! obtain the number of blocks
|
|
|
|
!
|
|
|
|
n = product(rdims(:))
|
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
!! PREPARE BLOCK CONFIGURATION ARRAY
|
|
|
|
!!
|
|
|
|
! allocate the configuration array
|
2010-12-21 20:25:17 -02:00
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
allocate(cfg(rdims(1),rdims(2),rdims(3)))
|
2010-12-21 20:25:17 -02:00
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
! set the block configurations
|
2010-12-21 20:25:17 -02:00
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
cfg(1:rdims(1),1:rdims(2):2,1:rdims(3):2) = 12
|
2010-12-21 20:25:17 -02:00
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
if (rdims(2) .gt. 1) then
|
|
|
|
cfg(1:rdims(1),2:rdims(2):2,1:rdims(3):2) = 43
|
|
|
|
cfg( rdims(1),1:rdims(2) ,1:rdims(3):2) = 13
|
2010-12-21 20:25:17 -02:00
|
|
|
end if
|
2011-02-16 11:28:50 -02:00
|
|
|
|
|
|
|
if (rdims(3) .gt. 1) then
|
|
|
|
cfg(1:rdims(1),1:rdims(2):2,2:rdims(3):2) = 65
|
|
|
|
if (rdims(2) .gt. 1) then
|
|
|
|
cfg(1:rdims(1),2:rdims(2):2,2:rdims(3):2) = 78
|
|
|
|
cfg( rdims(1),1:rdims(2) ,2:rdims(3):2) = 75
|
|
|
|
end if
|
|
|
|
if (rdims(1) .eq. 1 .or. mod(rdims(2),2) .eq. 1) then
|
|
|
|
cfg( rdims(1), rdims(2) ,1:rdims(3) ) = 15
|
2010-12-21 20:25:17 -02:00
|
|
|
else
|
2011-02-16 11:28:50 -02:00
|
|
|
cfg( 1 , rdims(2) ,1:rdims(3) ) = 48
|
2010-12-21 20:25:17 -02:00
|
|
|
end if
|
|
|
|
end if
|
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
!! ALLOCATE AND GENERATE META BLOCK CHAIN AND SET BLOCK CONFIGURATIONS
|
|
|
|
!!
|
|
|
|
! allocate the block pointer array
|
|
|
|
!
|
|
|
|
allocate(block_array(rdims(1),rdims(2),rdims(3)))
|
|
|
|
|
|
|
|
! generate the gray code for a given configuration and link the block in
|
|
|
|
! the proper order
|
2010-12-21 20:25:17 -02:00
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
loc(:) = (/ 0, 0, 0 /)
|
|
|
|
del(:) = (/ 1, 1, 1 /)
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
p = 1
|
2011-02-16 11:28:50 -02:00
|
|
|
do k = 1, rdims(3)
|
|
|
|
if (del(3) .eq. 1) loc(3) = loc(3) + del(3)
|
|
|
|
do j = 1, rdims(2)
|
|
|
|
if (del(2) .eq. 1) loc(2) = loc(2) + del(2)
|
|
|
|
do i = 1, rdims(1)
|
|
|
|
if (del(1) .eq. 1) loc(1) = loc(1) + del(1)
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! append a new metablock
|
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
call append_metablock(block_array(loc(1),loc(2),loc(3))%ptr)
|
2010-12-21 20:25:17 -02:00
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
! set the configuration type
|
2010-12-21 20:25:17 -02:00
|
|
|
!
|
2011-02-16 11:28:50 -02:00
|
|
|
call metablock_setconfig(block_array(loc(1),loc(2),loc(3))%ptr &
|
|
|
|
, cfg(loc(1),loc(2),loc(3)))
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! increase the block number
|
|
|
|
!
|
|
|
|
p = p + 1
|
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
if (del(1) .eq. -1) loc(1) = loc(1) + del(1)
|
2010-12-21 20:25:17 -02:00
|
|
|
end do
|
2011-02-16 11:28:50 -02:00
|
|
|
if (del(2) .eq. -1) loc(2) = loc(2) + del(2)
|
|
|
|
del(1) = - del(1)
|
2010-12-21 20:25:17 -02:00
|
|
|
end do
|
2011-02-16 11:28:50 -02:00
|
|
|
if (del(3) .eq. -1) loc(3) = loc(3) + del(3)
|
|
|
|
del(2) = - del(2)
|
2010-12-21 20:25:17 -02:00
|
|
|
end do
|
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
! deallocate the configuration array
|
|
|
|
!
|
|
|
|
deallocate(cfg)
|
|
|
|
|
|
|
|
!! FILL OUT THE REMAINING FIELDS AND ALLOCATE AND ASSOCIATE DATA BLOCKS
|
|
|
|
!!
|
|
|
|
! calculate block sizes
|
|
|
|
!
|
|
|
|
xl = (xmax - xmin) / rdims(1)
|
|
|
|
yl = (ymax - ymin) / rdims(2)
|
|
|
|
zl = (zmax - zmin) / rdims(3)
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! fill out block structure fields
|
|
|
|
!
|
|
|
|
do k = 1, rdims(3)
|
|
|
|
|
|
|
|
! claculate the block position along Z
|
|
|
|
!
|
|
|
|
kl = (k - 1) * res(1)
|
|
|
|
|
|
|
|
! calculate the Z bounds
|
|
|
|
!
|
|
|
|
zmn = zmin + (k - 1) * zl
|
|
|
|
zmx = zmin + k * zl
|
|
|
|
|
|
|
|
do j = 1, rdims(2)
|
|
|
|
|
|
|
|
! claculate the block position along Y
|
|
|
|
!
|
|
|
|
jl = (j - 1) * res(1)
|
|
|
|
|
|
|
|
! calculate the Y bounds
|
2009-09-10 17:25:28 -03:00
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
ymn = ymin + (j - 1) * yl
|
|
|
|
ymx = ymin + j * yl
|
|
|
|
|
|
|
|
do i = 1, rdims(1)
|
2009-09-10 17:25:28 -03:00
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
! claculate the block position along Y
|
2009-09-10 18:15:30 -03:00
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
il = (i - 1) * res(1)
|
2009-09-10 18:15:30 -03:00
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
! calculate the Z bounds
|
2009-09-10 18:15:30 -03:00
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
xmn = xmin + (i - 1) * xl
|
|
|
|
xmx = xmin + i * xl
|
2009-09-10 18:15:30 -03:00
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
! assign a pointer
|
2009-09-10 18:15:30 -03:00
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
pmeta => block_array(i,j,k)%ptr
|
|
|
|
|
|
|
|
! mark it as the leaf
|
|
|
|
!
|
|
|
|
call metablock_setleaf(pmeta)
|
|
|
|
|
|
|
|
! set the level
|
|
|
|
!
|
|
|
|
call metablock_setlevel(pmeta, 1)
|
|
|
|
|
|
|
|
! create a new data block
|
|
|
|
!
|
|
|
|
call append_datablock(pdata)
|
|
|
|
|
|
|
|
! associate meta and data blocks
|
|
|
|
!
|
|
|
|
call associate_blocks(pmeta, pdata)
|
2009-09-26 14:27:47 -03:00
|
|
|
|
2010-10-11 22:46:07 -03:00
|
|
|
! set block coordinates
|
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
call metablock_set_coord(pmeta, il, jl, kl)
|
|
|
|
|
|
|
|
! set the bounds
|
|
|
|
!
|
|
|
|
call metablock_setbounds(pmeta, xmn, xmx, ymn, ymx, zmn, zmx)
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
2011-02-16 11:28:50 -02:00
|
|
|
!! ASSIGN THE BLOCK NEIGHBORS
|
|
|
|
!!
|
2010-12-21 20:25:17 -02:00
|
|
|
! assign boundaries along the X direction
|
|
|
|
!
|
|
|
|
do k = 1, rdims(3)
|
|
|
|
do j = 1, rdims(2)
|
|
|
|
do i = 1, rdims(1) - 1
|
|
|
|
|
|
|
|
! assign a pointer
|
|
|
|
!
|
|
|
|
pmeta => block_array(i ,j,k)%ptr
|
2010-10-11 22:46:07 -03:00
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
! assign neighbor
|
2009-09-26 14:27:47 -03:00
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
pnext => block_array(i+1,j,k)%ptr
|
2009-09-10 18:15:30 -03:00
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
! assign their neighbor pointers
|
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
pmeta%neigh(1,2,p)%ptr => pnext
|
|
|
|
pnext%neigh(1,1,p)%ptr => pmeta
|
|
|
|
end do
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! if periodic boundary conditions set edge block neighbors
|
2009-09-10 18:23:18 -03:00
|
|
|
!
|
|
|
|
if (xlbndry .eq. 'periodic' .and. xubndry .eq. 'periodic') then
|
2010-12-21 20:25:17 -02:00
|
|
|
do k = 1, rdims(3)
|
|
|
|
do j = 1, rdims(2)
|
|
|
|
|
|
|
|
! assign pointers
|
|
|
|
!
|
|
|
|
pmeta => block_array( 1 ,j,k)%ptr
|
|
|
|
pnext => block_array(rdims(1),j,k)%ptr
|
|
|
|
|
|
|
|
! assign their neighbor pointers
|
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
pmeta%neigh(1,1,p)%ptr => pnext
|
|
|
|
pnext%neigh(1,2,p)%ptr => pmeta
|
|
|
|
end do
|
2009-09-10 18:23:18 -03:00
|
|
|
end do
|
|
|
|
end do
|
2009-09-27 03:07:23 -03:00
|
|
|
end if
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! assign boundaries along the Y direction
|
|
|
|
!
|
|
|
|
do k = 1, rdims(3)
|
|
|
|
do j = 1, rdims(2) - 1
|
|
|
|
do i = 1, rdims(1)
|
|
|
|
|
|
|
|
! assign a pointer
|
|
|
|
!
|
|
|
|
pmeta => block_array(i,j ,k)%ptr
|
|
|
|
|
|
|
|
! assign neighbor
|
|
|
|
!
|
|
|
|
pnext => block_array(i,j+1,k)%ptr
|
|
|
|
|
|
|
|
! assign their neighbor pointers
|
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
pmeta%neigh(2,2,p)%ptr => pnext
|
|
|
|
pnext%neigh(2,1,p)%ptr => pmeta
|
|
|
|
end do
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! if periodic boundary conditions set edge block neighbors
|
|
|
|
!
|
2009-09-10 18:23:18 -03:00
|
|
|
if (ylbndry .eq. 'periodic' .and. yubndry .eq. 'periodic') then
|
2010-12-21 20:25:17 -02:00
|
|
|
do k = 1, rdims(3)
|
|
|
|
do i = 1, rdims(1)
|
|
|
|
|
|
|
|
! assign pointers
|
|
|
|
!
|
|
|
|
pmeta => block_array(i, 1 ,k)%ptr
|
|
|
|
pnext => block_array(i,rdims(2),k)%ptr
|
|
|
|
|
|
|
|
! assign their neighbor pointers
|
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
pmeta%neigh(2,1,p)%ptr => pnext
|
|
|
|
pnext%neigh(2,2,p)%ptr => pmeta
|
|
|
|
end do
|
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
|
2010-12-21 20:25:17 -02:00
|
|
|
|
|
|
|
! assign boundaries along the Z direction
|
|
|
|
!
|
|
|
|
do k = 1, rdims(3) - 1
|
|
|
|
do j = 1, rdims(2)
|
|
|
|
do i = 1, rdims(1)
|
|
|
|
|
|
|
|
! assign a pointer
|
|
|
|
!
|
|
|
|
pmeta => block_array(i,j,k )%ptr
|
|
|
|
|
|
|
|
! assign neighbor
|
|
|
|
!
|
|
|
|
pnext => block_array(i,j,k+1)%ptr
|
|
|
|
|
|
|
|
! assign their neighbor pointers
|
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
pmeta%neigh(3,2,p)%ptr => pnext
|
|
|
|
pnext%neigh(3,1,p)%ptr => pmeta
|
|
|
|
end do
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
! if periodic boundary conditions set edge block neighbors
|
|
|
|
!
|
2009-09-10 18:23:18 -03:00
|
|
|
if (zlbndry .eq. 'periodic' .and. zubndry .eq. 'periodic') then
|
2010-12-21 20:25:17 -02:00
|
|
|
do j = 1, rdims(2)
|
|
|
|
do i = 1, rdims(1)
|
|
|
|
|
|
|
|
! assign pointers
|
|
|
|
!
|
|
|
|
pmeta => block_array(i,j, 1 )%ptr
|
|
|
|
pnext => block_array(i,j,rdims(3))%ptr
|
|
|
|
|
|
|
|
! assign their neighbor pointers
|
|
|
|
!
|
|
|
|
do p = 1, nfaces
|
|
|
|
pmeta%neigh(3,1,p)%ptr => pnext
|
|
|
|
pnext%neigh(3,2,p)%ptr => pmeta
|
|
|
|
end do
|
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
|
|
|
|
2010-12-21 20:25:17 -02:00
|
|
|
! deallocate the block pointer array
|
2009-09-10 17:46:36 -03:00
|
|
|
!
|
2010-12-21 20:25:17 -02:00
|
|
|
deallocate(block_array)
|
2009-09-10 17:25:28 -03:00
|
|
|
!
|
2008-12-22 15:34:02 -06:00
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine domain_default
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
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 &
|
2010-12-02 18:17:29 -02:00
|
|
|
, gamma, dens, pres, ratio, rcut
|
2010-12-01 09:25:30 -02:00
|
|
|
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 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
|
2010-12-02 18:17:29 -02:00
|
|
|
real :: dx, dy, dz, r
|
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
|
|
|
!
|
2010-12-02 18:17:29 -02:00
|
|
|
! calculate the cell sizes
|
2008-11-11 16:12:26 -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-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 */
|
2010-12-02 18:17:29 -02:00
|
|
|
dz = 1.0d0
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2010-12-02 18:17:29 -02:00
|
|
|
! generate the coordinates
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2010-12-02 18:17:29 -02:00
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng - 0.5d0) * dx + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng - 0.5d0) * dy + pblock%meta%ymin
|
2008-12-08 15:31:35 -06:00
|
|
|
#if NDIMS == 3
|
2010-12-02 18:17:29 -02:00
|
|
|
z(:) = ((/(k, k = 1, km)/) - ng - 0.5d0) * dz + pblock%meta%zmin
|
2008-12-08 15:31:35 -06:00
|
|
|
#else /* NDIMS == 3 */
|
2010-12-02 18:17:29 -02:00
|
|
|
z(1) = 0.0d0
|
2008-12-08 15:31:35 -06:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-11-11 16:12:26 -06:00
|
|
|
|
2010-12-02 18:17:29 -02:00
|
|
|
! set the uniform variables
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2009-09-22 17:30:53 -03:00
|
|
|
q(idn,:) = dens
|
|
|
|
q(ivx,:) = 0.0d0
|
|
|
|
q(ivy,:) = 0.0d0
|
|
|
|
q(ivz,:) = 0.0d0
|
2010-12-02 18:17:29 -02:00
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,:) = pres
|
|
|
|
#endif /* ADI */
|
2009-10-28 00:12:18 -02:00
|
|
|
#ifdef MHD
|
2010-12-02 18:17:29 -02:00
|
|
|
q(ibx,:) = 1.0d0 / sqrt(2.0d0)
|
|
|
|
q(iby,:) = 1.0d0 / sqrt(2.0d0)
|
2009-10-28 00:12:18 -02:00
|
|
|
q(ibz,:) = 0.0d0
|
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
|
|
|
|
2010-12-02 18:17:29 -02:00
|
|
|
! set the initial star profile (density for ISO or pressure for ADI)
|
2008-11-11 16:12:26 -06:00
|
|
|
!
|
2008-12-13 21:05:51 -06:00
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
|
|
|
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
|
2010-12-02 18:17:29 -02:00
|
|
|
q(idn,i) = dens * ratio
|
2010-03-30 23:23:49 -03:00
|
|
|
else
|
|
|
|
q(idn,i) = dens
|
|
|
|
end if
|
|
|
|
#endif /* ISO */
|
|
|
|
#ifdef ADI
|
2009-09-22 17:30:53 -03:00
|
|
|
if (r .lt. rcut) then
|
2010-12-02 18:17:29 -02:00
|
|
|
q(ipr,i) = pres * ratio
|
2008-12-18 10:20:15 -06:00
|
|
|
else
|
2010-12-02 18:17:29 -02:00
|
|
|
q(ipr,i) = pres
|
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
|
|
|
|
2010-12-02 18:17:29 -02:00
|
|
|
! convert the primitive variables to conserved ones
|
2009-09-22 17:30:53 -03:00
|
|
|
!
|
2010-12-02 18:17:29 -02:00
|
|
|
call prim2cons(im, q(:,:), u(:,:))
|
2010-02-28 18:35:57 -03:00
|
|
|
|
2010-12-02 18:17:29 -02:00
|
|
|
! copy the conserved variables to the current block
|
2010-02-28 18:35:57 -03:00
|
|
|
!
|
|
|
|
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-10 14:02:00 -02:00
|
|
|
#ifdef ISO
|
|
|
|
use config , only : csnd2
|
|
|
|
#endif /* ISO */
|
2010-12-10 18:47:28 -02:00
|
|
|
use constants, only : dpi
|
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 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-10 18:47:28 -02:00
|
|
|
real :: xlen, dx, dy, dz, yexp
|
2010-12-10 14:02:00 -02:00
|
|
|
#ifdef MHD
|
|
|
|
real :: ptot, pmag
|
|
|
|
#endif /* MHD */
|
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
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
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-10 14:02:00 -02:00
|
|
|
#ifdef MHD
|
|
|
|
! calculate the total pressure
|
|
|
|
!
|
|
|
|
ptot = 0.5d0 * bamp * bamp
|
|
|
|
#endif /* MHD */
|
|
|
|
|
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 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-10 18:47:28 -02:00
|
|
|
! calculate the exponent factor
|
|
|
|
!
|
|
|
|
yexp = exp(- 0.5d0 * (y(j) / ycut)**2)
|
|
|
|
|
2010-12-03 15:46:42 -02:00
|
|
|
#ifdef MHD
|
2010-12-10 18:47:28 -02:00
|
|
|
do i = 1, im
|
|
|
|
|
2010-12-02 09:54:17 -02:00
|
|
|
! initialize the magnetic field components
|
2010-12-01 21:08:45 -02:00
|
|
|
!
|
2010-12-02 09:54:17 -02:00
|
|
|
q(ibx,i) = bamp * tanh(y(j) / ydel)
|
2010-12-10 18:47:28 -02:00
|
|
|
|
|
|
|
! calculate magnetic pressure
|
|
|
|
!
|
|
|
|
pmag = 0.5d0 * q(ibx,i) * q(ibx,i)
|
|
|
|
|
|
|
|
! add perturbation
|
|
|
|
!
|
2010-12-11 19:25:59 -02:00
|
|
|
q(ibx,i) = q(ibx,i) &
|
|
|
|
- bper * yexp * y(j) * cos(dpi * x(i) / xlen) / ycut**2
|
|
|
|
q(iby,i) = bper * yexp * dpi * sin(dpi * x(i) / xlen)
|
2010-12-10 14:02:00 -02:00
|
|
|
|
|
|
|
! initialize density or pressure depending on EOS, so the total pressure is
|
|
|
|
! uniform
|
|
|
|
!
|
|
|
|
|
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,i) = pres + (ptot - pmag)
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef ISO
|
|
|
|
q(idn,i) = dens + (ptot - pmag) / csnd2
|
|
|
|
#endif /* ISO */
|
|
|
|
end do
|
2010-12-03 15:46:42 -02:00
|
|
|
#endif /* MHD */
|
2010-12-01 21:08:45 -02:00
|
|
|
|
|
|
|
! 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
|
2010-12-08 22:05:18 -02:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2011-03-18 14:00:27 -03:00
|
|
|
! init_multi_current_sheet: subroutine initializes the set up for the multiple
|
|
|
|
! current sheet problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_multi_current_sheet(pblock)
|
|
|
|
|
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : in, jn, kn, im, jm, km, ng &
|
|
|
|
, xmin, xmax, dens, pres, bamp, vper, ydel
|
|
|
|
#ifdef ISO
|
|
|
|
use config , only : csnd2
|
|
|
|
#endif /* ISO */
|
|
|
|
use constants, only : dpi
|
|
|
|
use mpitools , only : ncpu
|
|
|
|
use random , only : randomn
|
|
|
|
use scheme , only : prim2cons
|
|
|
|
use variables, only : nvr, nqt
|
|
|
|
use variables, only : idn, ivx, ivy, ivz
|
|
|
|
#ifdef ADI
|
|
|
|
use variables, only : ipr
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
use variables, only : ibx, iby, ibz
|
|
|
|
#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
|
|
|
|
real :: xlen, dx, dy, dz, yi, yt
|
|
|
|
#ifdef MHD
|
|
|
|
real :: ptot, pmag
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real, dimension(im) :: x
|
|
|
|
real, dimension(jm) :: y
|
|
|
|
real, dimension(km) :: z
|
|
|
|
real, dimension(nvr,im) :: q, u
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! calculate the length of the box
|
|
|
|
!
|
|
|
|
xlen = xmax - xmin
|
|
|
|
|
|
|
|
#ifdef MHD
|
|
|
|
! calculate the total pressure
|
|
|
|
!
|
|
|
|
ptot = 0.5d0 * bamp * bamp
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! calculate the cell sizes
|
|
|
|
!
|
|
|
|
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 */
|
|
|
|
|
|
|
|
! generate the coordinates
|
|
|
|
!
|
|
|
|
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
|
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,:) = pres
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
q(ibx,:) = 0.0d0
|
|
|
|
q(iby,:) = 0.0d0
|
|
|
|
q(ibz,:) = 0.0d0
|
|
|
|
#ifdef GLM
|
|
|
|
q(iph,:) = 0.0d0
|
|
|
|
#endif /* GLM */
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! set the initial profiles
|
|
|
|
!
|
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
|
|
|
|
|
|
|
! calculate the exponent factor
|
|
|
|
!
|
|
|
|
yi = y(j) - floor(y(j)) - 0.5d0
|
|
|
|
yt = yi - sign(0.25d0, yi)
|
|
|
|
|
|
|
|
#ifdef MHD
|
|
|
|
do i = 1, im
|
|
|
|
|
|
|
|
! initialize random velocity field
|
|
|
|
!
|
|
|
|
q(ivx,i) = vper * randomn(ncpu)
|
|
|
|
q(ivy,i) = vper * randomn(ncpu)
|
|
|
|
#if NDIMS == 3
|
|
|
|
q(ivz,i) = vper * randomn(ncpu)
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
|
|
|
! initialize the magnetic field components
|
|
|
|
!
|
|
|
|
q(ibx,i) = - sign(1.0d0, yi) * bamp * tanh(yt / ydel)
|
|
|
|
|
|
|
|
! calculate magnetic pressure
|
|
|
|
!
|
|
|
|
pmag = 0.5d0 * q(ibx,i) * q(ibx,i)
|
|
|
|
|
|
|
|
! initialize density or pressure depending on EOS, so the total pressure is
|
|
|
|
! uniform
|
|
|
|
!
|
|
|
|
|
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,i) = pres + (ptot - pmag)
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef ISO
|
|
|
|
q(idn,i) = dens + (ptot - pmag) / csnd2
|
|
|
|
#endif /* ISO */
|
|
|
|
end do
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! convert primitive variables to conserved
|
|
|
|
!
|
|
|
|
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)
|
|
|
|
|
|
|
|
end do
|
|
|
|
end do
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
end subroutine init_multi_current_sheet
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
2010-12-08 22:05:18 -02:00
|
|
|
! init_turbulence: subroutine initializes the variables for the turbulence
|
|
|
|
! problem
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_turbulence(pblock)
|
|
|
|
|
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : im, jm, km, dens, pres, bamp
|
|
|
|
use scheme , only : prim2cons
|
|
|
|
use variables, only : nvr, nqt
|
|
|
|
use variables, only : idn, ivx, ivy, ivz
|
|
|
|
#ifdef ADI
|
|
|
|
use variables, only : ipr
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
use variables, only : ibx, iby, ibz
|
|
|
|
#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
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
2010-12-08 22:23:31 -02:00
|
|
|
real, dimension(nvr,im) :: q
|
|
|
|
real, dimension(nqt,im) :: u
|
2010-12-08 22:05:18 -02:00
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! set variables
|
|
|
|
!
|
|
|
|
q(idn,:) = dens
|
|
|
|
q(ivx,:) = 0.0d0
|
|
|
|
q(ivy,:) = 0.0d0
|
|
|
|
q(ivz,:) = 0.0d0
|
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,:) = pres
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
q(ibx,:) = bamp
|
|
|
|
q(iby,:) = 0.0d0
|
|
|
|
q(ibz,:) = 0.0d0
|
|
|
|
#ifdef GLM
|
|
|
|
q(iph,:) = 0.0d0
|
|
|
|
#endif /* GLM */
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! set the initial profiles
|
|
|
|
!
|
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
|
|
|
|
|
|
|
! convert primitive variables to conserved
|
|
|
|
!
|
2010-12-08 22:23:31 -02:00
|
|
|
call prim2cons(im, q(1:nvr,1:im), u(1:nqt,1:im))
|
2010-12-08 22:05:18 -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_turbulence
|
2011-03-24 19:26:57 -03:00
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
! init_orszag_tang: subroutine initializes the setup for Orszag-Tang problems
|
|
|
|
!
|
|
|
|
!===============================================================================
|
|
|
|
!
|
|
|
|
subroutine init_orszag_tang(pblock)
|
|
|
|
|
|
|
|
use constants, only : dpi, qpi
|
|
|
|
use blocks , only : block_data
|
|
|
|
use config , only : im, jm, km, in, jn, kn, ng
|
|
|
|
use config , only : dens, bamp
|
|
|
|
#ifdef ADI
|
|
|
|
use config , only : gamma, pres
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef ISO
|
|
|
|
use config , only : csnd
|
|
|
|
#endif /* ISO */
|
|
|
|
use scheme , only : prim2cons
|
|
|
|
use variables, only : nvr, nqt
|
|
|
|
use variables, only : idn, ivx, ivy, ivz
|
|
|
|
#ifdef ADI
|
|
|
|
use variables, only : ipr
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
use variables, only : ibx, iby, ibz
|
|
|
|
#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
|
|
|
|
real :: dx, dy
|
|
|
|
|
|
|
|
! local arrays
|
|
|
|
!
|
|
|
|
real, dimension(im) :: x
|
|
|
|
real, dimension(jm) :: y
|
|
|
|
real, dimension(nvr,im) :: q
|
|
|
|
real, dimension(nqt,im) :: u
|
|
|
|
!
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
! calculate constants
|
|
|
|
!
|
|
|
|
#ifdef ADI
|
|
|
|
bamp = 1.0d0 / sqrt(qpi)
|
|
|
|
pres = gamma / qpi
|
|
|
|
dens = gamma**2 / qpi
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef ISO
|
|
|
|
bamp = csnd * (5.0d0 / 3.0d0) / qpi
|
|
|
|
#endif /* ISO */
|
|
|
|
|
|
|
|
! calculate the cell sizes
|
|
|
|
!
|
|
|
|
dx = (pblock%meta%xmax - pblock%meta%xmin) / in
|
|
|
|
dy = (pblock%meta%ymax - pblock%meta%ymin) / jn
|
|
|
|
|
|
|
|
! generate the coordinates
|
|
|
|
!
|
|
|
|
x(:) = ((/(i, i = 1, im)/) - ng - 0.5d0) * dx + pblock%meta%xmin
|
|
|
|
y(:) = ((/(j, j = 1, jm)/) - ng - 0.5d0) * dy + pblock%meta%ymin
|
|
|
|
|
|
|
|
! set variables
|
|
|
|
!
|
|
|
|
q(idn,:) = dens
|
|
|
|
#ifdef ADI
|
|
|
|
q(ipr,:) = pres
|
|
|
|
#endif /* ADI */
|
|
|
|
#ifdef MHD
|
|
|
|
#ifdef GLM
|
|
|
|
q(iph,:) = 0.0d0
|
|
|
|
#endif /* GLM */
|
|
|
|
#endif /* MHD */
|
|
|
|
|
|
|
|
! set the initial profiles
|
|
|
|
!
|
|
|
|
do k = 1, km
|
|
|
|
do j = 1, jm
|
|
|
|
do i = 1, im
|
|
|
|
q(ivx,i) = - sin(dpi * y(j))
|
|
|
|
q(ivy,i) = sin(dpi * x(i))
|
|
|
|
q(ivz,i) = 0.0d0
|
|
|
|
#ifdef MHD
|
|
|
|
q(ibx,i) = - bamp * sin(dpi * y(j))
|
|
|
|
q(iby,i) = bamp * sin(qpi * x(i))
|
|
|
|
q(ibz,i) = 0.0d0
|
|
|
|
#endif /* MHD */
|
|
|
|
end do
|
|
|
|
|
|
|
|
! convert primitive variables to conserved
|
|
|
|
!
|
|
|
|
call prim2cons(im, q(1:nvr,1:im), u(1:nqt,1:im))
|
|
|
|
|
|
|
|
! 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_orszag_tang
|
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
|
2011-03-26 19:33:37 -03:00
|
|
|
use config , only : im, jm, km, ib, ie, jb, je, kb, ke &
|
|
|
|
, crefmin, crefmax, epsref
|
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
|
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
integer :: i, j, k, im2, jm2, km2, ip2, jp2, kp2
|
|
|
|
real :: cref, fl, fr, fc, fx, fy, fz
|
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
|
2011-03-26 19:33:37 -03:00
|
|
|
real, dimension(im,jm,km) :: bx, by, bz
|
2010-12-01 15:57:58 -02:00
|
|
|
#endif /* MHD */
|
2011-03-26 19:33:37 -03:00
|
|
|
real, parameter :: cf = 1.0d0 / NDIMS
|
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
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = 0.0d0
|
2010-12-01 15:57:58 -02:00
|
|
|
|
2011-03-26 19:33:37 -03:00
|
|
|
! find the maximum smoothness indicator over all cells
|
2010-12-01 15:57:58 -02:00
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
do k = kb, ke
|
|
|
|
#if NDIMS == 3
|
|
|
|
km2 = k - 2
|
|
|
|
kp2 = k + 2
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
do j = jb, je
|
|
|
|
jm2 = j - 2
|
|
|
|
jp2 = j + 2
|
|
|
|
do i = ib, ie
|
|
|
|
im2 = i - 2
|
|
|
|
ip2 = i + 2
|
2010-02-11 23:30:46 -02:00
|
|
|
|
2010-12-01 15:57:58 -02:00
|
|
|
! density
|
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = dn(ip2,j,k) - dn(i,j,k)
|
|
|
|
fl = dn(im2,j,k) - dn(i,j,k)
|
|
|
|
fc = dn(ip2,j,k) + dn(im2,j,k) + 2.0d0 * dn(i,j,k)
|
|
|
|
fx = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * fc)
|
|
|
|
fr = dn(i,jp2,k) - dn(i,j,k)
|
|
|
|
fl = dn(i,jm2,k) - dn(i,j,k)
|
|
|
|
fc = dn(i,jp2,k) + dn(i,jm2,k) + 2.0d0 * dn(i,j,k)
|
|
|
|
fy = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * fc)
|
2010-12-01 15:57:58 -02:00
|
|
|
#if NDIMS == 2
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = dn(i,j,kp2) - dn(i,j,k)
|
|
|
|
fl = dn(i,j,km2) - dn(i,j,k)
|
|
|
|
fc = dn(i,j,kp2) + dn(i,j,km2) + 2.0d0 * dn(i,j,k)
|
|
|
|
fz = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * fc)
|
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy + fz * fz)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-16 13:40:34 -06:00
|
|
|
|
2010-03-30 23:23:49 -03:00
|
|
|
#ifdef ADI
|
2010-12-01 15:57:58 -02:00
|
|
|
! pressure
|
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = pr(ip2,j,k) - pr(i,j,k)
|
|
|
|
fl = pr(im2,j,k) - pr(i,j,k)
|
|
|
|
fc = pr(ip2,j,k) + pr(im2,j,k) + 2.0d0 * pr(i,j,k)
|
|
|
|
fx = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * fc)
|
|
|
|
fr = pr(i,jp2,k) - pr(i,j,k)
|
|
|
|
fl = pr(i,jm2,k) - pr(i,j,k)
|
|
|
|
fc = pr(i,jp2,k) + pr(i,jm2,k) + 2.0d0 * pr(i,j,k)
|
|
|
|
fy = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * fc)
|
2010-12-01 15:57:58 -02:00
|
|
|
#if NDIMS == 2
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = pr(i,j,kp2) - pr(i,j,k)
|
|
|
|
fl = pr(i,j,km2) - pr(i,j,k)
|
|
|
|
fc = pr(i,j,kp2) + pr(i,j,km2) + 2.0d0 * pr(i,j,k)
|
|
|
|
fz = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * fc)
|
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy + fz * fz)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 3 */
|
2008-12-16 13:40:34 -06:00
|
|
|
|
2010-03-30 23:23:49 -03:00
|
|
|
#endif /* ADI */
|
2010-12-01 15:57:58 -02:00
|
|
|
#ifdef MHD
|
|
|
|
! X magnetic component
|
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = bx(ip2,j,k) - bx(i,j,k)
|
|
|
|
fl = bx(im2,j,k) - bx(i,j,k)
|
|
|
|
fc = abs(bx(ip2,j,k)) + abs(bx(im2,j,k)) + 2.0d0 * abs(bx(i,j,k))
|
|
|
|
fx = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
|
|
|
fr = bx(i,jp2,k) - bx(i,j,k)
|
|
|
|
fl = bx(i,jm2,k) - bx(i,j,k)
|
|
|
|
fc = abs(bx(i,jp2,k)) + abs(bx(i,jm2,k)) + 2.0d0 * abs(bx(i,j,k))
|
|
|
|
fy = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
2010-12-01 15:57:58 -02:00
|
|
|
#if NDIMS == 2
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = bx(i,j,kp2) - bx(i,j,k)
|
|
|
|
fl = bx(i,j,km2) - bx(i,j,k)
|
|
|
|
fc = abs(bx(i,j,kp2)) + abs(bx(i,j,km2)) + 2.0d0 * abs(bx(i,j,k))
|
2011-03-28 11:10:30 -03:00
|
|
|
fz = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy + fz * fz)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 3 */
|
2010-12-01 15:57:58 -02:00
|
|
|
|
|
|
|
! Y magnetic component
|
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = by(ip2,j,k) - by(i,j,k)
|
|
|
|
fl = by(im2,j,k) - by(i,j,k)
|
|
|
|
fc = abs(by(ip2,j,k)) + abs(by(im2,j,k)) + 2.0d0 * abs(by(i,j,k))
|
|
|
|
fx = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
|
|
|
fr = by(i,jp2,k) - by(i,j,k)
|
|
|
|
fl = by(i,jm2,k) - by(i,j,k)
|
|
|
|
fc = abs(by(i,jp2,k)) + abs(by(i,jm2,k)) + 2.0d0 * abs(by(i,j,k))
|
|
|
|
fy = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
2010-12-01 15:57:58 -02:00
|
|
|
#if NDIMS == 2
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = by(i,j,kp2) - by(i,j,k)
|
|
|
|
fl = by(i,j,km2) - by(i,j,k)
|
|
|
|
fc = abs(by(i,j,kp2)) + abs(by(i,j,km2)) + 2.0d0 * abs(by(i,j,k))
|
2011-03-28 11:10:30 -03:00
|
|
|
fz = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy + fz * fz)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 3 */
|
2010-12-01 15:57:58 -02:00
|
|
|
|
|
|
|
! Z magnetic component
|
|
|
|
!
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = bz(ip2,j,k) - bz(i,j,k)
|
|
|
|
fl = bz(im2,j,k) - bz(i,j,k)
|
|
|
|
fc = abs(bz(ip2,j,k)) + abs(bz(im2,j,k)) + 2.0d0 * abs(bz(i,j,k))
|
|
|
|
fx = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
|
|
|
fr = bz(i,jp2,k) - bz(i,j,k)
|
|
|
|
fl = bz(i,jm2,k) - bz(i,j,k)
|
|
|
|
fc = abs(bz(i,jp2,k)) + abs(bz(i,jm2,k)) + 2.0d0 * abs(bz(i,j,k))
|
|
|
|
fy = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
2010-12-01 15:57:58 -02:00
|
|
|
#if NDIMS == 2
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
#if NDIMS == 3
|
2011-03-26 19:33:37 -03:00
|
|
|
fr = bz(i,j,kp2) - bz(i,j,k)
|
|
|
|
fl = bz(i,j,km2) - bz(i,j,k)
|
|
|
|
fc = abs(bz(i,j,kp2)) + abs(bz(i,j,km2)) + 2.0d0 * abs(bz(i,j,k))
|
2011-03-28 11:10:30 -03:00
|
|
|
fz = abs(fr + fl) / (abs(fr) + abs(fl) + epsref * (fc + 1.0e-8))
|
2011-03-26 19:33:37 -03:00
|
|
|
cref = max(cref, sqrt(cf * (fx * fx + fy * fy + fz * fz)))
|
2010-12-02 10:02:52 -02:00
|
|
|
#endif /* NDIMS == 3 */
|
2010-12-01 15:57:58 -02:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
2011-03-26 19:33:37 -03:00
|
|
|
if (cref .ge. crefmax) then
|
2008-11-29 22:19:02 -06:00
|
|
|
check_ref = 1
|
2010-03-08 19:09:49 -03:00
|
|
|
end if
|
2011-03-26 19:33:37 -03:00
|
|
|
if (cref .le. crefmin) then
|
2010-03-08 19:09:49 -03:00
|
|
|
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
|