Merge branch 'master' into gem-reconnection-challenge
This commit is contained in:
commit
f9b390d55e
@ -1,6 +1,6 @@
|
||||
|
||||
# **The AMUN Code**
|
||||
## Copyright (C) 2008-2022 Grzegorz Kowal
|
||||
## Copyright (C) 2008-2023 Grzegorz Kowal
|
||||
|
||||
[](https://ampere-orbis.nsupdate.info/gkowal/amun-code)
|
||||
|
||||
|
@ -20,7 +20,7 @@ __all__ = [ 'AmunXML', 'AmunH5', 'WriteVTK', \
|
||||
'amun_attribute', 'amun_coordinate', 'amun_dataset', 'amun_dataset_vtk', 'amun_integrals' ]
|
||||
|
||||
__author__ = "Grzegorz Kowal"
|
||||
__copyright__ = "Copyright 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>"
|
||||
__copyright__ = "Copyright 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>"
|
||||
__version__ = "0.9.9"
|
||||
__maintainer__ = "Grzegorz Kowal"
|
||||
__email__ = "grzegorz@amuncode.org"
|
||||
|
@ -5,7 +5,7 @@
|
||||
This file is part of the AMUN source code, a program to perform Newtonian or
|
||||
relativistic magnetohydrodynamical simulations on uniform or adaptive grid.
|
||||
|
||||
Copyright (C) 2021-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2021-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
adaptive mesh.
|
||||
|
||||
Copyright (C) 2018-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
Copyright (C) 2018-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
@ -3070,7 +3070,8 @@ module blocks
|
||||
! subroutine CHANGE_BLOCKS_PROCESS:
|
||||
! --------------------------------
|
||||
!
|
||||
! Subroutine switches meta blocks which belong to old process to the new one.
|
||||
! Subroutine changes the process of meta blocks associated with the process
|
||||
! npold to npnew.
|
||||
!
|
||||
! Arguments:
|
||||
!
|
||||
@ -3089,15 +3090,14 @@ module blocks
|
||||
|
||||
!-------------------------------------------------------------------------------
|
||||
!
|
||||
if (npnew == npold) return
|
||||
|
||||
pmeta => list_meta
|
||||
do while(associated(pmeta))
|
||||
|
||||
! if the meta block belongs to process npold, switch it to process npnew
|
||||
!
|
||||
if (pmeta%process == npold) pmeta%process = npnew
|
||||
|
||||
pmeta => pmeta%next
|
||||
end do ! meta blocks
|
||||
end do
|
||||
|
||||
!-------------------------------------------------------------------------------
|
||||
!
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2020-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2020-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2017-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2017-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -5,7 +5,7 @@
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2012-2020 Yann Collet
|
||||
!! Copyright (C) 2020-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2020-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2019-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2019-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
@ -91,7 +91,7 @@ module helpers
|
||||
write(*,"(1x,78('-'))")
|
||||
write(*,"(1x,18('='),17x,a,17x,19('='))") 'A M U N'
|
||||
write(*,"(1x,16('='),4x,a,4x,16('='))") &
|
||||
'Copyright (C) 2008-2022 Grzegorz Kowal'
|
||||
'Copyright (C) 2008-2023 Grzegorz Kowal'
|
||||
write(*,"(1x,18('='),9x,a,9x,19('='))") &
|
||||
'under GNU GPLv3 license'
|
||||
write(*,"(1x,78('-'))")
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
@ -42,7 +42,8 @@ module interpolations
|
||||
real(kind=8), dimension(:,:,:) , intent(in) :: q
|
||||
real(kind=8), dimension(:,:,:,:,:), intent(out) :: qi
|
||||
end subroutine
|
||||
subroutine reconstruct_iface(h, fc, fl, fr)
|
||||
subroutine reconstruct_iface(positive, h, fc, fl, fr)
|
||||
logical , intent(in) :: positive
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -76,7 +77,6 @@ module interpolations
|
||||
! monotonicity preserving reconstruction coefficients
|
||||
!
|
||||
real(kind=8), save :: kappa = 1.0d+00
|
||||
real(kind=8), save :: kbeta = 1.0d+00
|
||||
|
||||
! number of ghost zones (required for compact schemes)
|
||||
!
|
||||
@ -218,7 +218,6 @@ module interpolations
|
||||
call get_parameter("eps" , eps )
|
||||
call get_parameter("limo3_rad" , rad )
|
||||
call get_parameter("kappa" , kappa )
|
||||
call get_parameter("kbeta" , kbeta )
|
||||
call get_parameter("ppm_const" , ppm_const )
|
||||
call get_parameter("central_weight" , cweight )
|
||||
call get_parameter("cfl" , cfl )
|
||||
@ -978,20 +977,20 @@ module interpolations
|
||||
!
|
||||
! Arguments:
|
||||
!
|
||||
! positive - the variable positivity flag;
|
||||
! h - the spatial step;
|
||||
! q - the variable array;
|
||||
! qi - the array of reconstructed interfaces (2 in each direction);
|
||||
! p - the variable positivity flag;
|
||||
! h - the spatial step;
|
||||
! q - the variable array;
|
||||
! qi - the array of reconstructed interfaces (2 in each direction);
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine interfaces_dir(positive, h, q, qi)
|
||||
subroutine interfaces_dir(p, h, q, qi)
|
||||
|
||||
use coordinates, only : nb, ne, nbl, neu
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: positive
|
||||
logical , intent(in) :: p
|
||||
real(kind=8), dimension(:) , intent(in) :: h
|
||||
real(kind=8), dimension(:,:,:) , intent(in) :: q
|
||||
real(kind=8), dimension(:,:,:,:,:), intent(out) :: qi
|
||||
@ -1025,23 +1024,23 @@ module interpolations
|
||||
do k = nbl, neu
|
||||
#endif /* NDIMS == 3 */
|
||||
do j = nbl, neu
|
||||
call reconstruct(h(1), q(:,j,k), qi(:,j,k,1,1), qi(:,j,k,2,1))
|
||||
call reconstruct(p, h(1), q(:,j,k), qi(:,j,k,1,1), qi(:,j,k,2,1))
|
||||
end do ! j = nbl, neu
|
||||
do i = nbl, neu
|
||||
call reconstruct(h(2), q(i,:,k), qi(i,:,k,1,2), qi(i,:,k,2,2))
|
||||
call reconstruct(p, h(2), q(i,:,k), qi(i,:,k,1,2), qi(i,:,k,2,2))
|
||||
end do ! i = nbl, neu
|
||||
#if NDIMS == 3
|
||||
end do ! k = nbl, neu
|
||||
do j = nbl, neu
|
||||
do i = nbl, neu
|
||||
call reconstruct(h(3), q(i,j,:), qi(i,j,:,1,3), qi(i,j,:,2,3))
|
||||
call reconstruct(p, h(3), q(i,j,:), qi(i,j,:,1,3), qi(i,j,:,2,3))
|
||||
end do ! i = nbl, neu
|
||||
end do ! j = nbl, neu
|
||||
#endif /* NDIMS == 3 */
|
||||
|
||||
! make sure the interface states are positive for positive variables
|
||||
!
|
||||
if (positive) then
|
||||
if (p) then
|
||||
|
||||
#if NDIMS == 3
|
||||
do k = nbl, neu
|
||||
@ -1442,6 +1441,7 @@ module interpolations
|
||||
!
|
||||
! Arguments:
|
||||
!
|
||||
! p - the flag indicating if the reconstructed variable is positivite;
|
||||
! h - the spatial step; this is required for some reconstruction methods;
|
||||
! f - the input vector of cell averaged values;
|
||||
! fl - the left side state reconstructed for location (i+1/2);
|
||||
@ -1449,10 +1449,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct(h, f, fl, fr)
|
||||
subroutine reconstruct(p, h, f, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: f
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -1461,7 +1462,7 @@ module interpolations
|
||||
!
|
||||
! reconstruct the states using the selected subroutine
|
||||
!
|
||||
call reconstruct_states(h, f(:), fl(:), fr(:))
|
||||
call reconstruct_states(p, h, f(:), fl(:), fr(:))
|
||||
|
||||
! correct the reconstruction near extrema by clipping them in order to improve
|
||||
! the stability of scheme
|
||||
@ -1485,10 +1486,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_tvd(h, fc, fl, fr)
|
||||
subroutine reconstruct_tvd(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -1553,10 +1555,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_weno3(h, fc, fl, fr)
|
||||
subroutine reconstruct_weno3(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -1675,10 +1678,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_limo3(h, fc, fl, fr)
|
||||
subroutine reconstruct_limo3(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -1818,10 +1822,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_ppm(h, fc, fl, fr)
|
||||
subroutine reconstruct_ppm(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -2002,10 +2007,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_weno5z(h, fc, fl, fr)
|
||||
subroutine reconstruct_weno5z(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -2159,10 +2165,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_weno5yc(h, fc, fl, fr)
|
||||
subroutine reconstruct_weno5yc(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -2317,10 +2324,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_weno5ns(h, fc, fl, fr)
|
||||
subroutine reconstruct_weno5ns(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -2503,12 +2511,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_crweno5z(h, fc, fl, fr)
|
||||
subroutine reconstruct_crweno5z(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : tridiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -2878,12 +2887,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_crweno5yc(h, fc, fl, fr)
|
||||
subroutine reconstruct_crweno5yc(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : tridiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -3256,12 +3266,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_crweno5ns(h, fc, fl, fr)
|
||||
subroutine reconstruct_crweno5ns(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : tridiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -3647,10 +3658,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_mp5(h, fc, fl, fr)
|
||||
subroutine reconstruct_mp5(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -3676,7 +3688,7 @@ module interpolations
|
||||
u(n-1) = sum(ce3(:) * fc(n-2:n))
|
||||
u(n ) = fc(n )
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -3694,7 +3706,7 @@ module interpolations
|
||||
u(n-1) = sum(ce3(:) * fi(n-2:n))
|
||||
u(n ) = fi(n )
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -3724,10 +3736,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_mp7(h, fc, fl, fr)
|
||||
subroutine reconstruct_mp7(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -3755,7 +3768,7 @@ module interpolations
|
||||
u(n-1) = sum(ce3(:) * fc(n-2:n))
|
||||
u(n ) = fc(n )
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -3775,7 +3788,7 @@ module interpolations
|
||||
u(n-1) = sum(ce3(:) * fi(n-2:n))
|
||||
u(n ) = fi(n )
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -3805,10 +3818,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_mp9(h, fc, fl, fr)
|
||||
subroutine reconstruct_mp9(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -3838,7 +3852,7 @@ module interpolations
|
||||
u(n-1) = sum(ce3(:) * fc(n-2:n))
|
||||
u(n ) = fc(n )
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -3860,7 +3874,7 @@ module interpolations
|
||||
u(n-1) = sum(ce3(:) * fi(n-2:n))
|
||||
u(n ) = fi(n )
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -3902,12 +3916,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_crmp5(h, fc, fl, fr)
|
||||
subroutine reconstruct_crmp5(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : tridiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -3958,7 +3973,7 @@ module interpolations
|
||||
|
||||
call tridiag(n, a(1:n), b(1:n), c(1:n), r(1:n), u(1:n))
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -3983,7 +3998,7 @@ module interpolations
|
||||
|
||||
call tridiag(n, a(1:n), b(1:n), c(1:n), r(1:n), u(1:n))
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -4014,12 +4029,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_crmp7(h, fc, fl, fr)
|
||||
subroutine reconstruct_crmp7(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : tridiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -4072,7 +4088,7 @@ module interpolations
|
||||
|
||||
call tridiag(n, a(1:n), b(1:n), c(1:n), r(1:n), u(1:n))
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -4099,7 +4115,7 @@ module interpolations
|
||||
|
||||
call tridiag(n, a(1:n), b(1:n), c(1:n), r(1:n), u(1:n))
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -4130,12 +4146,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_crmp9(h, fc, fl, fr)
|
||||
subroutine reconstruct_crmp9(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : pentadiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -4196,7 +4213,7 @@ module interpolations
|
||||
|
||||
call pentadiag(n, e(:), c(:), d(:), a(:), b(:), r(:), u(:))
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -4225,7 +4242,7 @@ module interpolations
|
||||
|
||||
call pentadiag(n, e(:), c(:), d(:), a(:), b(:), r(:), u(:))
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -4260,12 +4277,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_ocmp5(h, fc, fl, fr)
|
||||
subroutine reconstruct_ocmp5(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : tridiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -4327,7 +4345,7 @@ module interpolations
|
||||
|
||||
call tridiag(n, a(1:n), b(1:n), c(1:n), r(1:n), u(1:n))
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -4352,7 +4370,7 @@ module interpolations
|
||||
|
||||
call tridiag(n, a(1:n), b(1:n), c(1:n), r(1:n), u(1:n))
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -4387,12 +4405,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_ocmp7(h, fc, fl, fr)
|
||||
subroutine reconstruct_ocmp7(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : pentadiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -4466,7 +4485,7 @@ module interpolations
|
||||
|
||||
call pentadiag(n, e(:), c(:), d(:), a(:), b(:), r(:), u(:))
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -4493,7 +4512,7 @@ module interpolations
|
||||
|
||||
call pentadiag(n, e(:), c(:), d(:), a(:), b(:), r(:), u(:))
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -4528,12 +4547,13 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_ocmp9(h, fc, fl, fr)
|
||||
subroutine reconstruct_ocmp9(p, h, fc, fl, fr)
|
||||
|
||||
use algebra, only : pentadiag
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -4611,7 +4631,7 @@ module interpolations
|
||||
|
||||
call pentadiag(n, e(:), c(:), d(:), a(:), b(:), r(:), u(:))
|
||||
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
fl(1:n) = u(1:n)
|
||||
|
||||
@ -4640,7 +4660,7 @@ module interpolations
|
||||
|
||||
call pentadiag(n, e(:), c(:), d(:), a(:), b(:), r(:), u(:))
|
||||
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
fr(1:n-1) = u(n-1:1:-1)
|
||||
|
||||
@ -4773,10 +4793,11 @@ module interpolations
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine reconstruct_gp(h, fc, fl, fr)
|
||||
subroutine reconstruct_gp(p, h, fc, fl, fr)
|
||||
|
||||
implicit none
|
||||
|
||||
logical , intent(in) :: p
|
||||
real(kind=8) , intent(in) :: h
|
||||
real(kind=8), dimension(:), intent(in) :: fc
|
||||
real(kind=8), dimension(:), intent(out) :: fl, fr
|
||||
@ -4814,7 +4835,7 @@ module interpolations
|
||||
|
||||
! apply the monotonicity preserving limiting
|
||||
!
|
||||
call mp_limiting(fc(:), u(:))
|
||||
call mp_limiting(p, n, fc(:), u(:))
|
||||
|
||||
! copy the interpolation to the respective vector
|
||||
!
|
||||
@ -4848,7 +4869,7 @@ module interpolations
|
||||
|
||||
! apply the monotonicity preserving limiting
|
||||
!
|
||||
call mp_limiting(fi(:), u(:))
|
||||
call mp_limiting(p, n, fi(:), u(:))
|
||||
|
||||
! copy the interpolation to the respective vector
|
||||
!
|
||||
@ -5325,93 +5346,118 @@ module interpolations
|
||||
! subroutine MP_LIMITING:
|
||||
! ----------------------
|
||||
!
|
||||
! Subroutine applies the monotonicity preserving (MP) limiter to a vector of
|
||||
! high order reconstructed interface values.
|
||||
! Subroutine applies the monotonicity preserving (MP) limitation to
|
||||
! the interface states reconstructed using a high order upwind
|
||||
! interpolation.
|
||||
!
|
||||
! Arguments:
|
||||
!
|
||||
! qc - the vector of cell-centered values;
|
||||
! qi - the vector of interface values obtained from the high order
|
||||
! interpolation as input and its monotonicity limited values as output;
|
||||
! p - the logical flag indicating if the variable is positive;
|
||||
! n - the length of vector u and q;
|
||||
! u - the vector of centered cell-integrated values;
|
||||
! q - the vector of interface values obtained from the high order
|
||||
! interpolation to which the limitation is applied;
|
||||
!
|
||||
! References:
|
||||
!
|
||||
! [1] Suresh, A. & Huynh, H. T.,
|
||||
! "Accurate Monotonicity-Preserving Schemes with Runge-Kutta
|
||||
! Time Stepping"
|
||||
! Journal on Computational Physics,
|
||||
! 1997, vol. 136, pp. 83-99,
|
||||
! http://dx.doi.org/10.1006/jcph.1997.5745
|
||||
! [2] He, ZhiWei, Li, XinLiang, Fu, DeXun, & Ma, YanWen,
|
||||
! "A 5th order monotonicity-preserving upwind compact difference
|
||||
! scheme",
|
||||
! Science China Physics, Mechanics and Astronomy,
|
||||
! Volume 54, Issue 3, pp. 511-522,
|
||||
! http://dx.doi.org/10.1007/s11433-010-4220-x
|
||||
! Journal on Computational Physics, 1997, 136, 83-99,
|
||||
! https://doi.org/10.1006/jcph.1997.5745
|
||||
! [2] Myeong-Hwan Ahn, Duck-Joo Lee,
|
||||
! "Modified Monotonicity Preserving Constraints for High-Resolution
|
||||
! Optimized Compact Scheme",
|
||||
! Journal of Scientific Computing, 2020, 83:34,
|
||||
! https://doi.org/10.1007/s10915-020-01221-0
|
||||
!
|
||||
!===============================================================================
|
||||
!
|
||||
subroutine mp_limiting(qc, qi)
|
||||
subroutine mp_limiting(p, n, u, q)
|
||||
|
||||
implicit none
|
||||
|
||||
real(kind=8), dimension(:), intent(in) :: qc
|
||||
real(kind=8), dimension(:), intent(inout) :: qi
|
||||
logical , intent(in) :: p
|
||||
integer , intent(in) :: n
|
||||
real(kind=8), dimension(n), intent(in) :: u
|
||||
real(kind=8), dimension(n), intent(inout) :: q
|
||||
|
||||
integer :: n, i, im1, ip1, ip2
|
||||
real(kind=8) :: dq, ds, dc0, dc4, dm1, dp1, dml, dmr
|
||||
integer :: i, im2, im1, ip1, ip2
|
||||
real(kind=8) :: du, dm, dc, dp, dc4, dmm, dmp, di, de, bt
|
||||
real(kind=8) :: qlc, qmd, qmp, qmn, qmx, qul
|
||||
|
||||
real(kind=8), dimension(0:size(qc)+2) :: dm
|
||||
real(kind=8), dimension(n) :: d
|
||||
real(kind=8), dimension(2) :: umn, umx
|
||||
|
||||
!-------------------------------------------------------------------------------
|
||||
!
|
||||
n = size(qc)
|
||||
d(1 ) = 0.0d+00
|
||||
d(2:n) = u(2:n) - u(1:n-1)
|
||||
|
||||
dm(0 ) = 0.0d+00
|
||||
dm(1 ) = 0.0d+00
|
||||
dm(2:n) = qc(2:n) - qc(1:n-1)
|
||||
dm(n+1) = 0.0d+00
|
||||
dm(n+2) = 0.0d+00
|
||||
im2 = 1
|
||||
im1 = 1
|
||||
ip1 = 2
|
||||
ip2 = 3
|
||||
|
||||
do i = 1, n - 1
|
||||
do i = 1, n
|
||||
|
||||
ip1 = i + 1
|
||||
du = kappa * d(i)
|
||||
|
||||
if (dm(i) * dm(ip1) >= 0.0d+00) then
|
||||
dq = kappa * dm(i)
|
||||
else
|
||||
dq = kbeta * dm(i)
|
||||
end if
|
||||
qmp = u(i) + minmod(d(ip1), du)
|
||||
|
||||
qmp = qc(i) + minmod(dm(ip1), dq)
|
||||
ds = (qi(i) - qc(i)) * (qi(i) - qmp)
|
||||
if ((q(i) - u(i)) * (q(i) - qmp) > eps) then
|
||||
|
||||
if (ds > eps) then
|
||||
dm = d(i ) - d(im1)
|
||||
dc = d(ip1) - d(i )
|
||||
dp = d(ip2) - d(ip1)
|
||||
dc4 = 4.0d+00 * dc
|
||||
|
||||
im1 = i - 1
|
||||
ip2 = i + 2
|
||||
dmp = minmod4(dc4 - dp, 4.0d+00 * dp - dc, dc, dp)
|
||||
dmm = minmod4(dc4 - dm, 4.0d+00 * dm - dc, dc, dm)
|
||||
|
||||
dm1 = dm(i ) - dm(im1)
|
||||
dc0 = dm(ip1) - dm(i )
|
||||
dp1 = dm(ip2) - dm(ip1)
|
||||
dc4 = 4.0d+00 * dc0
|
||||
qul = u(i) + du
|
||||
qmd = u(i) + 5.0d-01 * (d(ip1) - dmp )
|
||||
qlc = u(i) + 5.0d-01 * (d(i ) + 8.0d+00 * dmm / 3.0d+00)
|
||||
|
||||
dml = 0.5d+00 * minmod4(dc4 - dm1, 4.0d+00 * dm1 - dc0, dc0, dm1)
|
||||
dmr = 0.5d+00 * minmod4(dc4 - dp1, 4.0d+00 * dp1 - dc0, dc0, dp1)
|
||||
umn(1) = min(u(im1), u(ip1))
|
||||
umn(2) = min(u(im2), u(ip2))
|
||||
umx(1) = max(u(im1), u(ip1))
|
||||
umx(2) = max(u(im2), u(ip2))
|
||||
|
||||
qmd = qc(i) + 0.5d+00 * dm(ip1) - dmr
|
||||
qul = qc(i) + dq
|
||||
qlc = qc(i) + 0.5d+00 * dq + dml
|
||||
if ((u(i) > umx(1) .and. umx(1) > umx(2) .and. &
|
||||
u(im2) <= u(ip1) .and. u(im1) >= u(ip2)) .or. &
|
||||
(u(i) < umn(1) .and. umn(1) < umn(2) .and. &
|
||||
u(im2) >= u(ip1) .and. u(im1) <= u(ip2))) then
|
||||
|
||||
qmx = max(min(qc(i), qc(ip1), qmd), min(qc(i), qul, qlc))
|
||||
qmn = min(max(qc(i), qc(ip1), qmd), max(qc(i), qul, qlc))
|
||||
bt = 2.0d+00 * u(i)
|
||||
di = (u(im1) + u(ip1)) - bt
|
||||
de = (u(im2) + u(ip2)) - bt
|
||||
bt = di / de
|
||||
if (bt > 3.0d-01) qlc = u(im2)
|
||||
|
||||
qi(i) = median(qi(i), qmn, qmx)
|
||||
end if
|
||||
|
||||
qmx = max(min(u(i), u(ip1), qmd), min(u(i), qul, qlc))
|
||||
qmn = min(max(u(i), u(ip1), qmd), max(u(i), qul, qlc))
|
||||
|
||||
if (p .and. qmn <= 0.0d+00) then
|
||||
if (d(i) <= 0.0d+00 .and. d(ip1) >= 0.0d+00) then
|
||||
qmn = u(i) * u(ip1) / (u(i) + u(ip1))
|
||||
else
|
||||
qmn = max(eps, min(u(i), u(ip1)))
|
||||
end if
|
||||
end if
|
||||
|
||||
q(i) = median(q(i), qmn, qmx)
|
||||
|
||||
end if
|
||||
|
||||
end do ! i = 1, n - 1
|
||||
im2 = im1
|
||||
im1 = i
|
||||
ip1 = ip2
|
||||
ip2 = min(ip2 + 1, n)
|
||||
|
||||
end do
|
||||
|
||||
!-------------------------------------------------------------------------------
|
||||
!
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
@ -1458,9 +1458,25 @@ module io
|
||||
|
||||
if (nprocs >= lnprocs) then
|
||||
|
||||
if (nproc < lnprocs) then
|
||||
! spread the restart snapshots reading across new processes so we do not
|
||||
! overload the memory; change the data block process starting from the last
|
||||
! down to the first process, so we do not change the process number of blocks
|
||||
! which have already been updated;
|
||||
!
|
||||
n = nprocs / lnprocs
|
||||
do nl = lnprocs - 1, 0, -1
|
||||
nu = nl * n
|
||||
call change_blocks_process(nl, nu)
|
||||
end do
|
||||
if (mod(nproc, n) == 0) then
|
||||
nl = nproc / n
|
||||
else
|
||||
nl = -1
|
||||
end if
|
||||
|
||||
write(fname,sfmt) trim(dname), "datablocks", nproc, "xml"
|
||||
if (nl >= 0) then
|
||||
|
||||
write(fname,sfmt) trim(dname), "datablocks", nl, "xml"
|
||||
inquire(file=fname, exist=test)
|
||||
if (.not. test) then
|
||||
write(*,*) trim(fname) // " does not exist!"
|
||||
@ -1538,7 +1554,7 @@ module io
|
||||
|
||||
if (status == 0) then
|
||||
|
||||
write(fname,sfmt) trim(dname), "datablock_ids", nproc, "bin"
|
||||
write(fname,sfmt) trim(dname), "datablock_ids", nl, "bin"
|
||||
open(newunit=lun, file=fname, form='unformatted', access='stream')
|
||||
read(lun) ids
|
||||
close(lun)
|
||||
@ -1553,7 +1569,7 @@ module io
|
||||
call link_blocks(block_array(ids(l))%ptr, pdata)
|
||||
|
||||
write(fname,"(a,'datablock_prim_',i6.6,'_',i6.6,'.bin')") &
|
||||
trim(dname), nproc, l
|
||||
trim(dname), nl, l
|
||||
open(newunit=lun, file=fname, form='unformatted', access='stream')
|
||||
read(lun) array(:,:,:,:,1)
|
||||
close(lun)
|
||||
@ -1575,7 +1591,7 @@ module io
|
||||
end if
|
||||
|
||||
write(fname,"(a,'datablock_cons_',i6.6,'_',i6.6,'.bin')") &
|
||||
trim(dname), nproc, l
|
||||
trim(dname), nl, l
|
||||
open(newunit=lun, file=fname, form='unformatted', access='stream')
|
||||
read(lun) array
|
||||
close(lun)
|
||||
@ -1610,7 +1626,7 @@ module io
|
||||
|
||||
if (status == 0) then
|
||||
|
||||
write(fname,sfmt) trim(dname), "random_seeds", nproc, "bin"
|
||||
write(fname,sfmt) trim(dname), "random_seeds", nl, "bin"
|
||||
open(newunit=lun, file=fname, form='unformatted', access='stream')
|
||||
read(lun) seeds
|
||||
close(lun)
|
||||
@ -1625,7 +1641,7 @@ module io
|
||||
call print_message(loc, "Could not allocate space for seeds!")
|
||||
end if
|
||||
|
||||
else ! nproc < lnprocs
|
||||
else ! nl < 0
|
||||
|
||||
write(fname,sfmt) trim(dname), "datablocks", 0, "xml"
|
||||
inquire(file=fname, exist=test)
|
||||
@ -1683,7 +1699,7 @@ module io
|
||||
|
||||
end if ! gentype == "same"
|
||||
|
||||
end if ! nproc < nprocs
|
||||
end if ! nl < 0
|
||||
|
||||
else ! nprocs < lnprocs
|
||||
|
||||
|
103
sources/mesh.F90
103
sources/mesh.F90
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
@ -592,7 +592,7 @@ module mesh
|
||||
use blocks , only : append_datablock, remove_datablock, link_blocks
|
||||
use helpers , only : print_message
|
||||
use mpitools, only : check_status
|
||||
use mpitools, only : npmax, nproc, nodes, lprocs
|
||||
use mpitools, only : nproc, nodes, lprocs
|
||||
use mpitools, only : send_array, receive_array
|
||||
#endif /* MPI */
|
||||
|
||||
@ -601,16 +601,15 @@ module mesh
|
||||
integer, intent(out) :: status
|
||||
|
||||
#ifdef MPI
|
||||
logical :: flag
|
||||
integer(kind=4) :: np, nl, nc, nr
|
||||
integer(kind=4) :: l, m, n, p
|
||||
|
||||
type(block_meta), pointer :: pmeta
|
||||
type(block_data), pointer :: pdata
|
||||
|
||||
integer(kind=4) :: tag1, tag2
|
||||
|
||||
integer(kind=4), dimension(nodes) :: nb
|
||||
integer(kind=4), dimension(lprocs,nodes) :: lb
|
||||
integer(kind=4), dimension(nodes) :: leafs_per_node
|
||||
integer(kind=4), dimension(lprocs,nodes) :: leafs_per_process
|
||||
|
||||
character(len=*), parameter :: loc = 'MESH::redistribute_blocks()'
|
||||
#endif /* MPI */
|
||||
@ -620,50 +619,53 @@ module mesh
|
||||
status = 0
|
||||
|
||||
#ifdef MPI
|
||||
! calculate the new data block distribution between processes
|
||||
! calculate the new data block distribution between nodes and processes on each
|
||||
! node
|
||||
!
|
||||
nl = mod(get_nleafs(), nodes)
|
||||
nb(:) = get_nleafs() / nodes
|
||||
nb(1:nl) = nb(1:nl) + 1
|
||||
do nc = 1, nodes
|
||||
nl = mod(nb(nc), lprocs)
|
||||
lb( : ,nc) = nb(nc) / lprocs
|
||||
lb(1:nl,nc) = lb(1:nl,nc) + 1
|
||||
n = mod(get_nleafs(), nodes)
|
||||
leafs_per_node( : ) = get_nleafs() / nodes
|
||||
leafs_per_node(1:n) = leafs_per_node(1:n) + 1
|
||||
do n = 1, nodes
|
||||
m = mod(leafs_per_node(n), lprocs)
|
||||
leafs_per_process( : ,n) = leafs_per_node(n) / lprocs
|
||||
leafs_per_process(1:m,n) = leafs_per_process(1:m,n) + 1
|
||||
end do
|
||||
|
||||
nc = 1
|
||||
nr = 1
|
||||
np = 0
|
||||
nl = 0
|
||||
! update the %process field of leafs with respect to the new division,
|
||||
! and redistribute data blocks at the same time
|
||||
!
|
||||
p = 0 ! process count
|
||||
l = 0 ! leaf per process count
|
||||
m = 1 ! node process count
|
||||
n = 1 ! node count
|
||||
|
||||
tag2 = 0
|
||||
|
||||
pmeta => list_meta
|
||||
do while (associated(pmeta))
|
||||
|
||||
! exchange data blocks between processes
|
||||
!
|
||||
if (pmeta%process /= np) then
|
||||
if (pmeta%leaf) then
|
||||
if (pmeta%leaf) then
|
||||
l = l + 1
|
||||
if (pmeta%process /= p) then
|
||||
changed = .true.
|
||||
|
||||
tag1 = tag2 + 1
|
||||
tag2 = tag1 + 1
|
||||
|
||||
if (nproc == pmeta%process) then
|
||||
if (nproc == pmeta%process .and. associated(pmeta%data)) then
|
||||
pdata => pmeta%data
|
||||
call send_array(p, tag1, pdata%uu)
|
||||
call send_array(p, tag2, pdata%q)
|
||||
|
||||
call send_array(np, tag1, pmeta%data%uu)
|
||||
call send_array(np, tag2, pmeta%data%q)
|
||||
|
||||
call remove_datablock(pmeta%data, status)
|
||||
call remove_datablock(pdata, status)
|
||||
if (status /= 0) then
|
||||
call print_message(loc, "Could not remove data block!")
|
||||
go to 1000
|
||||
end if
|
||||
|
||||
nullify(pmeta%data)
|
||||
end if
|
||||
|
||||
if (nproc == np) then
|
||||
|
||||
if (nproc == p .and. .not. associated(pmeta%data)) then
|
||||
call append_datablock(pdata, status)
|
||||
if (status /= 0) then
|
||||
call print_message(loc, "Could not append new data block!")
|
||||
@ -673,43 +675,20 @@ module mesh
|
||||
|
||||
call receive_array(pmeta%process, tag1, pmeta%data%uu)
|
||||
call receive_array(pmeta%process, tag2, pmeta%data%q)
|
||||
|
||||
end if
|
||||
|
||||
pmeta%process = p
|
||||
end if
|
||||
|
||||
pmeta%process = np
|
||||
|
||||
end if
|
||||
|
||||
! determine the new block distribution
|
||||
!
|
||||
if (pmeta%leaf) then
|
||||
nl = nl + 1
|
||||
|
||||
if (nl >= lb(nr,nc)) then
|
||||
|
||||
np = min(npmax, np + 1)
|
||||
nl = 0
|
||||
nr = nr + 1
|
||||
if (nr > lprocs) then
|
||||
nr = 1
|
||||
nc = nc + 1
|
||||
if (l >= leafs_per_process(m,n)) then
|
||||
l = 0
|
||||
p = p + 1
|
||||
m = m + 1
|
||||
if (m > lprocs) then
|
||||
m = 1
|
||||
n = n + 1
|
||||
end if
|
||||
flag = nc <= nodes
|
||||
if (flag) flag = lb(nr,nc) == 0
|
||||
do while(flag)
|
||||
np = min(npmax, np + 1)
|
||||
nr = nr + 1
|
||||
if (nr > lprocs) then
|
||||
nr = 1
|
||||
nc = nc + 1
|
||||
end if
|
||||
flag = nc <= nodes
|
||||
if (flag) flag = lb(nr,nc) == 0
|
||||
end do
|
||||
|
||||
end if
|
||||
|
||||
end if
|
||||
|
||||
pmeta => pmeta%next
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
@ -772,10 +772,6 @@ module statistics
|
||||
dh(2) = ady(pmeta%level)
|
||||
dh(3) = adz(pmeta%level)
|
||||
|
||||
! calculate current density (J = ∇xB)
|
||||
!
|
||||
call curl(dh(:), pdata%q(ibx:ibz,:,:,:), jc(1:3,:,:,:))
|
||||
|
||||
! total mass
|
||||
!
|
||||
#if NDIMS == 3
|
||||
@ -820,6 +816,11 @@ module statistics
|
||||
+ pdata%q(iby,nb:ne,nb:ne, : )**2 &
|
||||
+ pdata%q(ibz,nb:ne,nb:ne, : )**2) * dvolh
|
||||
#endif /* NDIMS == 3 */
|
||||
|
||||
! calculate current density (J = ∇xB)
|
||||
!
|
||||
call curl(dh(:), pdata%q(ibx:ibz,:,:,:), jc(1:3,:,:,:))
|
||||
|
||||
end if
|
||||
|
||||
if (.not. periodic(1)) then
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2017-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2017-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2008-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2017-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2017-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
@ -4,7 +4,7 @@
|
||||
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
||||
!! adaptive mesh.
|
||||
!!
|
||||
!! Copyright (C) 2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!! Copyright (C) 2022-2023 Grzegorz Kowal <grzegorz@amuncode.org>
|
||||
!!
|
||||
!! This program is free software: you can redistribute it and/or modify
|
||||
!! it under the terms of the GNU General Public License as published by
|
||||
|
Loading…
x
Reference in New Issue
Block a user