2010-10-13 03:32:10 -03:00
|
|
|
|
!!******************************************************************************
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
|
!! This file is part of the AMUN source code, a program to perform
|
|
|
|
|
!! Newtonian or relativistic magnetohydrodynamical simulations on uniform or
|
|
|
|
|
!! adaptive mesh.
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!!
|
2022-02-02 09:51:41 -03:00
|
|
|
|
!! Copyright (C) 2008-2022 Grzegorz Kowal <grzegorz@amuncode.org>
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
|
!! 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
|
|
|
|
|
!! the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
!! (at your option) any later version.
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!!
|
2011-04-29 11:21:30 -03:00
|
|
|
|
!! This program is distributed in the hope that it will be useful,
|
2008-12-08 19:07:42 -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
|
2012-07-22 12:30:20 -03:00
|
|
|
|
!! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!!
|
2010-10-13 03:32:10 -03:00
|
|
|
|
!!******************************************************************************
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!!
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!! module: SCHEMES
|
|
|
|
|
!!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
!! The module provides and interface to numerical schemes, subroutines to
|
|
|
|
|
!! calculate variable increment and one dimensional Riemann solvers.
|
2012-07-22 12:30:20 -03:00
|
|
|
|
!!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
!! If you implement a new set of equations, you have to add at least one
|
|
|
|
|
!! corresponding update_flux subroutine, and one Riemann solver.
|
2012-08-01 17:25:49 -03:00
|
|
|
|
!!
|
2012-07-22 12:30:20 -03:00
|
|
|
|
!!******************************************************************************
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!
|
2012-08-01 16:38:10 -03:00
|
|
|
|
module schemes
|
2008-12-08 19:07:42 -06:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2019-01-30 14:58:40 -02:00
|
|
|
|
! Rieman solver and state vectors names
|
|
|
|
|
!
|
|
|
|
|
character(len=255) , save :: name_sol = ""
|
|
|
|
|
character(len=255) , save :: name_sts = "primitive"
|
|
|
|
|
|
2021-12-21 22:59:19 -03:00
|
|
|
|
! KEPES solver
|
|
|
|
|
!
|
|
|
|
|
logical , save :: kepes = .false.
|
|
|
|
|
|
2016-08-14 22:52:40 -03:00
|
|
|
|
! 4-vector reconstruction flag
|
|
|
|
|
!
|
|
|
|
|
logical , save :: states_4vec = .false.
|
|
|
|
|
|
2019-10-04 11:02:05 -03:00
|
|
|
|
! high order fluxes
|
|
|
|
|
!
|
|
|
|
|
logical , save :: high_order_flux = .false.
|
|
|
|
|
|
2018-08-29 23:25:11 -03:00
|
|
|
|
! interfaces for procedure pointers
|
|
|
|
|
!
|
|
|
|
|
abstract interface
|
|
|
|
|
subroutine update_flux_iface(dx, q, f)
|
2019-02-05 10:55:04 -02:00
|
|
|
|
real(kind=8), dimension(:) , intent(in) :: dx
|
|
|
|
|
real(kind=8), dimension(:,:,:,:) , intent(in) :: q
|
|
|
|
|
real(kind=8), dimension(:,:,:,:,:), intent(out) :: f
|
2018-08-29 23:25:11 -03:00
|
|
|
|
end subroutine
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_solver_iface(ql, qr, fi)
|
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2020-02-22 10:13:28 +07:00
|
|
|
|
end subroutine
|
2018-08-29 23:25:11 -03:00
|
|
|
|
end interface
|
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! pointer to the Riemann solver
|
|
|
|
|
!
|
2020-02-22 10:13:28 +07:00
|
|
|
|
procedure(riemann_solver_iface), pointer, save :: riemann_solver => null()
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
2012-08-01 16:38:10 -03:00
|
|
|
|
! by default everything is private
|
|
|
|
|
!
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
! declare public subroutines
|
|
|
|
|
!
|
2019-01-30 14:58:40 -02:00
|
|
|
|
public :: initialize_schemes, finalize_schemes, print_schemes
|
2014-05-27 16:29:53 -03:00
|
|
|
|
public :: update_flux
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
|
|
|
|
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
|
!
|
2008-12-08 19:07:42 -06:00
|
|
|
|
contains
|
2011-04-30 12:28:02 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!!
|
|
|
|
|
!!*** PUBLIC SUBROUTINES *****************************************************
|
|
|
|
|
!!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! subroutine INITIALIZE_SCHEMES:
|
|
|
|
|
! -----------------------------
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! Subroutine initiate the module by setting module parameters and subroutine
|
|
|
|
|
! pointers.
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! verbose - a logical flag turning the information printing;
|
2019-02-11 09:51:02 -02:00
|
|
|
|
! status - an integer flag for error return value;
|
2011-04-30 12:28:02 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2019-02-11 09:51:02 -02:00
|
|
|
|
subroutine initialize_schemes(verbose, status)
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
use equations , only : eqsys, eos
|
2022-05-24 18:32:02 -03:00
|
|
|
|
use helpers , only : print_message, uppercase
|
2019-02-11 09:51:02 -02:00
|
|
|
|
use parameters, only : get_parameter
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
logical, intent(in) :: verbose
|
|
|
|
|
integer, intent(out) :: status
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
character(len=64) :: solver = "HLL"
|
|
|
|
|
character(len=64) :: statev = "primitive"
|
2019-10-04 11:02:05 -03:00
|
|
|
|
character(len=64) :: flux = "off"
|
2014-01-02 12:32:19 -02:00
|
|
|
|
|
2022-05-24 18:32:02 -03:00
|
|
|
|
|
|
|
|
|
character(len=256) :: msg
|
|
|
|
|
|
|
|
|
|
character(len=*), parameter :: fmt = "('The selected Riemann solver " // &
|
|
|
|
|
"is not implemented for the ',a,': ',a,'.'" // &
|
|
|
|
|
",a,4x,'Available Riemann solvers are: ', a, '.')"
|
|
|
|
|
character(len=*), parameter :: loc = 'SCHEMES::initialize_schemes()'
|
|
|
|
|
|
2021-11-16 15:22:15 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2019-02-11 09:51:02 -02:00
|
|
|
|
!
|
|
|
|
|
status = 0
|
|
|
|
|
|
2019-01-28 21:31:30 -02:00
|
|
|
|
call get_parameter("riemann_solver" , solver)
|
|
|
|
|
call get_parameter("state_variables", statev)
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! depending on the system of equations initialize the module variables
|
2011-04-30 12:28:02 -03:00
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
select case(trim(eqsys))
|
|
|
|
|
|
|
|
|
|
!--- HYDRODYNAMICS ---
|
2011-04-30 12:28:02 -03:00
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case("hd", "HD", "hydro", "HYDRO", "hydrodynamic", "HYDRODYNAMIC")
|
|
|
|
|
|
|
|
|
|
select case(trim(eos))
|
|
|
|
|
|
|
|
|
|
case("iso", "ISO", "isothermal", "ISOTHERMAL")
|
|
|
|
|
|
|
|
|
|
select case(trim(solver))
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case("hll", "HLL")
|
|
|
|
|
name_sol = "HLL"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hll
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case("roe", "ROE")
|
|
|
|
|
name_sol = "ROE"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hd_iso_roe
|
2019-02-11 09:51:02 -02:00
|
|
|
|
|
2021-12-24 07:45:30 -03:00
|
|
|
|
case("kepes", "KEPES")
|
|
|
|
|
name_sol = "KEPES"
|
|
|
|
|
kepes = .true.
|
|
|
|
|
riemann_solver => riemann_hd_iso_kepes
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case default
|
|
|
|
|
|
|
|
|
|
if (verbose) then
|
2022-05-24 18:32:02 -03:00
|
|
|
|
write(msg,fmt) 'isothermal hydrodynamics', &
|
|
|
|
|
"'" // uppercase(trim(solver)) // "'", &
|
|
|
|
|
new_line('a'), &
|
|
|
|
|
"'HLL', 'ROE', 'KEPES'"
|
|
|
|
|
call print_message(loc, msg)
|
2019-02-11 09:51:02 -02:00
|
|
|
|
end if
|
|
|
|
|
status = 1
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
case("adi", "ADI", "adiabatic", "ADIABATIC")
|
|
|
|
|
|
|
|
|
|
select case(trim(solver))
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case("hll", "HLL")
|
|
|
|
|
name_sol = "HLL"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hll
|
2019-02-11 09:51:02 -02:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case("hllc", "HLLC")
|
|
|
|
|
name_sol = "HLLC"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hd_hllc
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2014-03-06 13:16:57 -03:00
|
|
|
|
case("roe", "ROE")
|
|
|
|
|
name_sol = "ROE"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hd_adi_roe
|
2014-03-06 13:16:57 -03:00
|
|
|
|
|
2021-12-21 22:11:44 -03:00
|
|
|
|
case("kepes", "KEPES")
|
|
|
|
|
name_sol = "KEPES"
|
2021-12-21 22:59:19 -03:00
|
|
|
|
kepes = .true.
|
2021-12-21 22:11:44 -03:00
|
|
|
|
riemann_solver => riemann_hd_adi_kepes
|
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case default
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
if (verbose) then
|
2022-05-24 18:32:02 -03:00
|
|
|
|
write(msg,fmt) 'adiabatic hydrodynamics', &
|
|
|
|
|
"'" // uppercase(trim(solver)) // "'", &
|
|
|
|
|
new_line('a'), &
|
|
|
|
|
"'HLL', 'HLLC', 'ROE', 'KEPES'"
|
|
|
|
|
call print_message(loc, msg)
|
2019-02-11 09:51:02 -02:00
|
|
|
|
end if
|
|
|
|
|
status = 1
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
end select
|
2011-05-19 18:24:09 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
!--- MAGNETOHYDRODYNAMICS ---
|
2011-04-30 12:28:02 -03:00
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case("mhd", "MHD", "magnetohydrodynamic", "MAGNETOHYDRODYNAMIC")
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
select case(trim(eos))
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case("iso", "ISO", "isothermal", "ISOTHERMAL")
|
|
|
|
|
|
|
|
|
|
select case(trim(solver))
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case("hll", "HLL")
|
|
|
|
|
name_sol = "HLL"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hll
|
2019-02-11 09:51:02 -02:00
|
|
|
|
|
2013-12-20 13:53:45 -02:00
|
|
|
|
case ("hlld", "HLLD")
|
|
|
|
|
name_sol = "HLLD"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_mhd_iso_hlld
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2014-03-06 13:55:09 -03:00
|
|
|
|
case("roe", "ROE")
|
|
|
|
|
name_sol = "ROE"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_mhd_iso_roe
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-01 12:36:53 -03:00
|
|
|
|
case("kepes", "KEPES")
|
|
|
|
|
name_sol = "KEPES"
|
|
|
|
|
kepes = .true.
|
|
|
|
|
riemann_solver => riemann_mhd_iso_kepes
|
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case default
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
if (verbose) then
|
2022-05-24 18:32:02 -03:00
|
|
|
|
write(msg,fmt) 'isothermal magnetohydrodynamics', &
|
|
|
|
|
"'" // uppercase(trim(solver)) // "'", &
|
|
|
|
|
new_line('a'), &
|
|
|
|
|
"'HLL', 'HLLD', 'ROE', 'KEPES'"
|
|
|
|
|
call print_message(loc, msg)
|
2019-02-11 09:51:02 -02:00
|
|
|
|
end if
|
|
|
|
|
status = 1
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
case("adi", "ADI", "adiabatic", "ADIABATIC")
|
|
|
|
|
|
|
|
|
|
select case(trim(solver))
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case ("hll", "HLL")
|
|
|
|
|
name_sol = "HLL"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hll
|
2019-02-11 09:51:02 -02:00
|
|
|
|
|
2013-12-12 16:25:30 -02:00
|
|
|
|
case ("hllc", "HLLC")
|
|
|
|
|
name_sol = "HLLC"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_mhd_hllc
|
2013-12-12 16:25:30 -02:00
|
|
|
|
|
2013-12-12 16:38:25 -02:00
|
|
|
|
case ("hlld", "HLLD")
|
|
|
|
|
name_sol = "HLLD"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_mhd_adi_hlld
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2014-03-06 14:19:31 -03:00
|
|
|
|
case("roe", "ROE")
|
|
|
|
|
name_sol = "ROE"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_mhd_adi_roe
|
2014-03-06 14:19:31 -03:00
|
|
|
|
|
2021-12-23 23:30:46 -03:00
|
|
|
|
case("kepes", "KEPES")
|
|
|
|
|
name_sol = "KEPES"
|
|
|
|
|
kepes = .true.
|
|
|
|
|
riemann_solver => riemann_mhd_adi_kepes
|
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
case default
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
if (verbose) then
|
2022-05-24 18:32:02 -03:00
|
|
|
|
write(msg,fmt) 'adiabatic magnetohydrodynamics', &
|
|
|
|
|
"'" // uppercase(trim(solver)) // "'", &
|
|
|
|
|
new_line('a'), &
|
|
|
|
|
"'HLL', 'HLLC', 'HLLD', 'ROE', 'KEPES'"
|
|
|
|
|
call print_message(loc, msg)
|
2019-02-11 09:51:02 -02:00
|
|
|
|
end if
|
|
|
|
|
status = 1
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
end select
|
2011-04-30 12:28:02 -03:00
|
|
|
|
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!--- SPECIAL RELATIVITY HYDRODYNAMICS ---
|
|
|
|
|
!
|
|
|
|
|
case("srhd", "SRHD")
|
|
|
|
|
|
|
|
|
|
select case(trim(eos))
|
|
|
|
|
|
|
|
|
|
case("adi", "ADI", "adiabatic", "ADIABATIC")
|
|
|
|
|
|
2015-02-06 17:41:17 -02:00
|
|
|
|
select case(trim(statev))
|
|
|
|
|
|
|
|
|
|
case("4vec", "4-vector", "4VEC", "4-VECTOR")
|
|
|
|
|
name_sts = "4-vector"
|
2016-08-14 22:52:40 -03:00
|
|
|
|
states_4vec = .true.
|
2015-02-06 17:41:17 -02:00
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
name_sts = "primitive"
|
|
|
|
|
|
|
|
|
|
end select
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
|
|
|
|
select case(trim(solver))
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case ("hll", "HLL")
|
|
|
|
|
name_sol = "HLL"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hll
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case("hllc", "HLLC", "hllcm", "HLLCM", "hllc-m", "HLLC-M")
|
|
|
|
|
name_sol = "HLLC (Mignone & Bodo 2005)"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_srhd_hllc
|
2019-02-11 09:51:02 -02:00
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
|
|
|
|
|
if (verbose) then
|
2022-05-24 18:32:02 -03:00
|
|
|
|
write(msg,fmt) 'adiabatic special relativity hydrodynamics', &
|
|
|
|
|
"'" // uppercase(trim(solver)) // "'", &
|
|
|
|
|
new_line('a'), &
|
|
|
|
|
"'HLL', 'HLLC'"
|
|
|
|
|
call print_message(loc, msg)
|
2019-02-11 09:51:02 -02:00
|
|
|
|
end if
|
|
|
|
|
status = 1
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
2015-02-16 20:06:43 -02:00
|
|
|
|
!--- SPECIAL RELATIVITY MAGNETOHYDRODYNAMICS ---
|
|
|
|
|
!
|
|
|
|
|
case("srmhd", "SRMHD")
|
|
|
|
|
|
|
|
|
|
select case(trim(eos))
|
|
|
|
|
|
|
|
|
|
case("adi", "ADI", "adiabatic", "ADIABATIC")
|
|
|
|
|
|
|
|
|
|
select case(trim(statev))
|
|
|
|
|
|
|
|
|
|
case("4vec", "4-vector", "4VEC", "4-VECTOR")
|
|
|
|
|
name_sts = "4-vector"
|
2016-08-14 22:52:40 -03:00
|
|
|
|
states_4vec = .true.
|
2015-02-16 20:06:43 -02:00
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
name_sts = "primitive"
|
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
select case(trim(solver))
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case ("hll", "HLL")
|
|
|
|
|
name_sol = "HLL"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_hll
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
case("hllc", "HLLC", "hllcm", "HLLCM", "hllc-m", "HLLC-M")
|
|
|
|
|
name_sol = "HLLC (Mignone & Bodo 2006)"
|
2020-02-22 10:13:28 +07:00
|
|
|
|
riemann_solver => riemann_srmhd_hllc
|
2019-02-11 09:51:02 -02:00
|
|
|
|
|
|
|
|
|
case default
|
|
|
|
|
|
|
|
|
|
if (verbose) then
|
2022-05-24 18:32:02 -03:00
|
|
|
|
write(msg,fmt) 'adiabatic special relativity magnetohydrodynamics',&
|
|
|
|
|
"'" // uppercase(trim(solver)) // "'", &
|
|
|
|
|
new_line('a'), &
|
|
|
|
|
"'HLL', 'HLLC'"
|
|
|
|
|
call print_message(loc, msg)
|
2019-02-11 09:51:02 -02:00
|
|
|
|
end if
|
|
|
|
|
status = 1
|
2015-02-16 20:06:43 -02:00
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
|
|
|
|
end select
|
|
|
|
|
|
2011-05-19 18:24:09 -03:00
|
|
|
|
end select
|
|
|
|
|
|
2019-10-04 11:02:05 -03:00
|
|
|
|
! flag for higher order flux correction
|
|
|
|
|
!
|
|
|
|
|
call get_parameter("high_order_flux", flux)
|
|
|
|
|
|
|
|
|
|
select case(trim(flux))
|
|
|
|
|
case ("on", "ON", "t", "T", "y", "Y", "true", "TRUE", "yes", "YES")
|
|
|
|
|
high_order_flux = .true.
|
|
|
|
|
case default
|
|
|
|
|
high_order_flux = .false.
|
|
|
|
|
end select
|
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine initialize_schemes
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! subroutine FINALIZE_SCHEMES:
|
|
|
|
|
! ---------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine releases memory used by the module.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2019-02-11 09:51:02 -02:00
|
|
|
|
! status - an integer flag for error return value;
|
2013-12-11 10:16:06 -02:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2019-02-11 09:51:02 -02:00
|
|
|
|
subroutine finalize_schemes(status)
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2019-02-11 09:51:02 -02:00
|
|
|
|
integer, intent(out) :: status
|
2014-01-02 12:32:19 -02:00
|
|
|
|
|
2021-11-16 15:22:15 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2019-02-11 09:51:02 -02:00
|
|
|
|
!
|
|
|
|
|
status = 0
|
|
|
|
|
|
2020-02-22 10:27:27 +07:00
|
|
|
|
nullify(riemann_solver)
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
2011-04-30 12:28:02 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
end subroutine finalize_schemes
|
2012-08-01 12:56:52 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2019-01-30 14:58:40 -02:00
|
|
|
|
!
|
|
|
|
|
! subroutine PRINT_SCHEMES:
|
|
|
|
|
! ------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine prints module parameters and settings.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! verbose - a logical flag turning the information printing;
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
subroutine print_schemes(verbose)
|
|
|
|
|
|
2019-01-30 22:32:53 -02:00
|
|
|
|
use helpers, only : print_section, print_parameter
|
|
|
|
|
|
2019-01-30 14:58:40 -02:00
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
logical, intent(in) :: verbose
|
2021-11-16 15:22:15 -03:00
|
|
|
|
|
2019-01-30 14:58:40 -02:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
if (verbose) then
|
2019-01-30 22:32:53 -02:00
|
|
|
|
call print_section(verbose, "Schemes")
|
|
|
|
|
call print_parameter(verbose, "Riemann solver" , name_sol)
|
|
|
|
|
call print_parameter(verbose, "state variables", name_sts)
|
2019-10-04 11:02:05 -03:00
|
|
|
|
if (high_order_flux) then
|
|
|
|
|
call print_parameter(verbose, "high order flux correction", "on" )
|
|
|
|
|
else
|
|
|
|
|
call print_parameter(verbose, "high order flux correction", "off")
|
|
|
|
|
end if
|
2019-01-30 14:58:40 -02:00
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine print_schemes
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2016-08-01 23:36:15 -03:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
! subroutine UPDATE_FLUX:
|
|
|
|
|
! ----------------------
|
2016-08-09 16:00:41 -03:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! Subroutine solves the Riemann problem along each direction and calculates
|
|
|
|
|
! the numerical fluxes, which are used later to calculate the conserved
|
2020-02-21 22:00:41 +07:00
|
|
|
|
! variable increments.
|
2016-08-09 16:00:41 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2021-11-12 12:39:33 -03:00
|
|
|
|
! dx - the spatial step;
|
|
|
|
|
! q - the array of primitive variables;
|
|
|
|
|
! s - the state arrays for primitive variables;
|
|
|
|
|
! f - the array of numerical fluxes;
|
2016-08-09 16:00:41 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2021-11-12 12:39:33 -03:00
|
|
|
|
subroutine update_flux(dx, q, s, f)
|
2016-08-09 16:00:41 -03:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
use coordinates, only : nn => bcells, nbl, neu
|
2020-02-21 22:00:41 +07:00
|
|
|
|
use equations , only : relativistic
|
|
|
|
|
use equations , only : nf, ivars, ivx, ivz
|
2016-08-09 16:00:41 -03:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
real(kind=8), dimension(:) , intent(in) :: dx
|
|
|
|
|
real(kind=8), dimension(:,:,:,:) , intent(in) :: q
|
|
|
|
|
real(kind=8), dimension(:,:,:,:,:,:), intent(inout) :: s
|
|
|
|
|
real(kind=8), dimension(:,:,:,:,:) , intent(out) :: f
|
2016-08-09 16:00:41 -03:00
|
|
|
|
|
2022-01-08 10:37:53 -03:00
|
|
|
|
integer :: n, i, j, k, l, p
|
2020-02-21 22:00:41 +07:00
|
|
|
|
real(kind=8) :: vm
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn,2) :: qi
|
|
|
|
|
real(kind=8), dimension(nf,nn) :: fi
|
|
|
|
|
|
2016-08-09 16:00:41 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-08 10:37:53 -03:00
|
|
|
|
#if NDIMS == 2
|
|
|
|
|
k = 1
|
|
|
|
|
#endif /* NDIMS == 2 */
|
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
! in the relativistic case, apply the reconstruction on variables
|
|
|
|
|
! using the four-velocities if requested
|
2016-08-09 16:00:41 -03:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
if (relativistic .and. states_4vec) then
|
2016-08-09 16:00:41 -03:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
f(:,:,:,:,1) = q(:,:,:,:)
|
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#if NDIMS == 3
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do k = 1, nn
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#endif /* NDIMS == 3 */
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do j = 1, nn
|
|
|
|
|
do i = 1, nn
|
2020-02-21 11:43:02 +07:00
|
|
|
|
|
2020-02-21 22:00:41 +07:00
|
|
|
|
vm = sqrt(1.0d+00 - sum(q(ivx:ivz,i,j,k)**2))
|
2020-02-21 11:43:02 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
f(ivx:ivz,i,j,k,1) = f(ivx:ivz,i,j,k,1) / vm
|
2020-02-21 11:43:02 +07:00
|
|
|
|
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do ! i = 1, nn
|
|
|
|
|
end do ! j = 1, nn
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#if NDIMS == 3
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do ! k = 1, nn
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#endif /* NDIMS == 3 */
|
2020-02-21 11:43:02 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
call reconstruct_interfaces(dx(:), f(:,:,:,:,1), s(:,:,:,:,:,:))
|
2020-02-21 11:43:02 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
! convert the states' four-velocities back to velocities
|
2020-02-21 11:43:02 +07:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
#if NDIMS == 3
|
|
|
|
|
do k = 1, nn
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#endif /* NDIMS == 3 */
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do j = 1, nn
|
|
|
|
|
do i = 1, nn
|
2020-02-21 11:43:02 +07:00
|
|
|
|
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do l = 1, 2
|
|
|
|
|
do p = 1, NDIMS
|
2020-02-21 11:57:53 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
vm = sqrt(1.0d+00 + sum(s(ivx:ivz,i,j,k,l,p)**2))
|
2020-02-21 11:57:53 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
s(ivx:ivz,i,j,k,l,p) = s(ivx:ivz,i,j,k,l,p) / vm
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do ! p = 1, ndims
|
|
|
|
|
end do ! l = 1, 2
|
|
|
|
|
end do ! i = 1, nn
|
|
|
|
|
end do ! j = 1, nn
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#if NDIMS == 3
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do ! k = 1, nn
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#endif /* NDIMS == 3 */
|
2020-02-21 11:57:53 +07:00
|
|
|
|
|
2020-02-21 22:00:41 +07:00
|
|
|
|
else
|
2020-02-21 11:57:53 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
call reconstruct_interfaces(dx(:), q(:,:,:,:), s(:,:,:,:,:,:))
|
2020-02-21 22:00:41 +07:00
|
|
|
|
|
|
|
|
|
end if
|
2020-02-21 11:57:53 +07:00
|
|
|
|
|
2021-11-12 12:39:33 -03:00
|
|
|
|
f(:,:,:,:,:) = 0.0d+00
|
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! calculate the flux along the X-direction
|
2020-02-21 11:57:53 +07:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
#if NDIMS == 3
|
|
|
|
|
do k = nbl, neu
|
|
|
|
|
#endif /* NDIMS == 3 */
|
|
|
|
|
do j = nbl, neu
|
2020-02-21 11:57:53 +07:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! copy states to directional lines with proper vector component ordering
|
2020-02-21 11:57:53 +07:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do n = 1, nf
|
2021-11-12 12:39:33 -03:00
|
|
|
|
qi(n,:,1:2) = s(ivars(1,n),:,j,k,1:2,1)
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do
|
2014-03-06 12:15:44 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! call one dimensional Riemann solver in order to obtain numerical fluxes
|
2009-10-28 00:12:18 -02:00
|
|
|
|
!
|
2020-02-21 11:18:23 +07:00
|
|
|
|
call numerical_flux(qi(:,:,:), fi(:,:))
|
2010-12-11 14:38:34 -02:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! update the array of fluxes
|
2010-12-11 14:38:34 -02:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do n = 1, nf
|
2021-07-10 18:26:52 -03:00
|
|
|
|
f(ivars(1,n),:,j,k,1) = fi(n,:)
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do
|
2008-12-08 20:03:01 -06:00
|
|
|
|
|
2019-02-05 14:19:49 -02:00
|
|
|
|
end do ! j = nbl, neu
|
2010-12-11 14:38:34 -02:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! calculate the flux along the Y direction
|
2010-12-11 14:38:34 -02:00
|
|
|
|
!
|
2019-02-05 14:19:49 -02:00
|
|
|
|
do i = nbl, neu
|
2010-12-11 14:38:34 -02:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! copy directional variable vectors to pass to the one dimensional solver
|
2009-10-28 00:12:18 -02:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do n = 1, nf
|
2021-11-12 12:39:33 -03:00
|
|
|
|
qi(n,:,1:2) = s(ivars(2,n),i,:,k,1:2,2)
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do
|
2014-03-06 12:15:44 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! call one dimensional Riemann solver in order to obtain numerical fluxes
|
2008-12-08 20:16:37 -06:00
|
|
|
|
!
|
2020-02-21 11:18:23 +07:00
|
|
|
|
call numerical_flux(qi(:,:,:), fi(:,:))
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
! update the array of fluxes
|
2008-12-08 20:16:37 -06:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do n = 1, nf
|
2021-07-10 18:26:52 -03:00
|
|
|
|
f(ivars(2,n),i,:,k,2) = fi(n,:)
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
2019-02-05 14:19:49 -02:00
|
|
|
|
end do ! i = nbl, neu
|
|
|
|
|
#if NDIMS == 3
|
|
|
|
|
end do ! k = nbl, neu
|
|
|
|
|
#endif /* NDIMS == 3 */
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
2016-07-26 22:47:55 -03:00
|
|
|
|
#if NDIMS == 3
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! calculate the flux along the Z direction
|
2008-12-08 20:16:37 -06:00
|
|
|
|
!
|
2019-02-05 14:19:49 -02:00
|
|
|
|
do j = nbl, neu
|
|
|
|
|
do i = nbl, neu
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
! copy directional variable vectors to pass to the one dimensional solver
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do n = 1, nf
|
2021-11-12 12:39:33 -03:00
|
|
|
|
qi(n,:,1:2) = s(ivars(3,n),i,j,:,1:2,3)
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do
|
2014-03-06 12:15:44 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
! call one dimensional Riemann solver in order to obtain numerical fluxes
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 11:18:23 +07:00
|
|
|
|
call numerical_flux(qi(:,:,:), fi(:,:))
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
! update the array of fluxes
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
do n = 1, nf
|
2021-07-10 18:26:52 -03:00
|
|
|
|
f(ivars(3,n),i,j,:,3) = fi(n,:)
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end do
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
2019-02-05 14:19:49 -02:00
|
|
|
|
end do ! i = nbl, neu
|
|
|
|
|
end do ! j = nbl, neu
|
2016-07-26 22:47:55 -03:00
|
|
|
|
#endif /* NDIMS == 3 */
|
2013-12-11 10:16:06 -02:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 22:00:41 +07:00
|
|
|
|
end subroutine update_flux
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
!===============================================================================
|
2021-11-12 12:39:33 -03:00
|
|
|
|
!!
|
|
|
|
|
!!*** PRIVATE SUBROUTINES ****************************************************
|
|
|
|
|
!!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2008-12-08 20:16:37 -06:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! subroutine RECONSTRUCT_INTERFACES:
|
|
|
|
|
! ---------------------------------
|
|
|
|
|
!
|
2020-02-21 22:23:25 +07:00
|
|
|
|
! Subroutine reconstructs the Riemann states along all directions.
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! dx - the spatial step;
|
|
|
|
|
! q - the array of primitive variables;
|
|
|
|
|
! qi - the array of reconstructed states (2 in each direction);
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
subroutine reconstruct_interfaces(dx, q, qi)
|
|
|
|
|
|
|
|
|
|
! include external procedures
|
|
|
|
|
!
|
2020-02-21 22:23:25 +07:00
|
|
|
|
use equations , only : nf
|
|
|
|
|
use equations , only : positive
|
|
|
|
|
use interpolations, only : interfaces
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
|
!
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
! subroutine arguments
|
|
|
|
|
!
|
|
|
|
|
real(kind=8), dimension(:) , intent(in) :: dx
|
|
|
|
|
real(kind=8), dimension(:,:,:,:) , intent(in) :: q
|
|
|
|
|
real(kind=8), dimension(:,:,:,:,:,:), intent(out) :: qi
|
|
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
|
!
|
2020-02-21 22:23:25 +07:00
|
|
|
|
integer :: p
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2020-02-21 22:23:25 +07:00
|
|
|
|
! interpolate interfaces for all flux variables
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
do p = 1, nf
|
2020-02-21 22:23:25 +07:00
|
|
|
|
call interfaces(positive(p), dx(1:NDIMS), q (p,:,:,:), &
|
|
|
|
|
qi(p,:,:,:,1:2,1:NDIMS))
|
|
|
|
|
end do
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine reconstruct_interfaces
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2020-02-22 10:27:27 +07:00
|
|
|
|
! subroutine NUMERICAL_FLUX:
|
|
|
|
|
! -------------------------
|
2014-03-06 12:59:51 -03:00
|
|
|
|
!
|
2020-02-22 10:27:27 +07:00
|
|
|
|
! Subroutine prepares Riemann states and calls the selected Riemann solver
|
|
|
|
|
! in order to get the numerical flux. If requested, the resulting flux
|
|
|
|
|
! is corrected by higher order correction terms.
|
2014-03-06 12:59:51 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2019-02-05 22:08:30 -02:00
|
|
|
|
! q - the array of primitive variables at the Riemann states;
|
|
|
|
|
! f - the output array of fluxes;
|
2014-03-06 12:59:51 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2020-02-22 10:27:27 +07:00
|
|
|
|
subroutine numerical_flux(q, f)
|
2014-03-06 12:59:51 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, ibx, ibp
|
|
|
|
|
use equations , only : magnetized, cmax
|
2014-03-06 12:59:51 -03:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2019-02-05 22:08:30 -02:00
|
|
|
|
real(kind=8), dimension(:,:,:), intent(inout) :: q
|
|
|
|
|
real(kind=8), dimension(:,:) , intent(out) :: f
|
2014-03-06 12:59:51 -03:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: bx, bp
|
2014-03-06 12:59:51 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ql, qr
|
2021-11-16 15:22:15 -03:00
|
|
|
|
|
2014-03-06 12:59:51 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2021-12-21 22:59:19 -03:00
|
|
|
|
if (kepes) then
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call riemann_solver(q(:,:,1), q(:,:,2), f(:,:))
|
2021-12-21 22:59:19 -03:00
|
|
|
|
else
|
|
|
|
|
|
2021-11-16 15:22:15 -03:00
|
|
|
|
! copy the state vectors
|
2019-02-05 22:08:30 -02:00
|
|
|
|
!
|
2021-12-21 22:59:19 -03:00
|
|
|
|
ql(:,:) = q(:,:,1)
|
|
|
|
|
qr(:,:) = q(:,:,2)
|
2019-02-05 22:08:30 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! obtain the state values for Bx and Psi for the GLM-MHD equations
|
|
|
|
|
!
|
2021-12-21 22:59:19 -03:00
|
|
|
|
if (magnetized) then
|
|
|
|
|
do i = 1, size(q, 2)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2021-12-21 22:59:19 -03:00
|
|
|
|
bx = 5.0d-01 * ((qr(ibx,i) + ql(ibx,i)) &
|
2020-02-21 20:39:50 +07:00
|
|
|
|
- (qr(ibp,i) - ql(ibp,i)) / cmax)
|
2021-12-21 22:59:19 -03:00
|
|
|
|
bp = 5.0d-01 * ((qr(ibp,i) + ql(ibp,i)) &
|
2020-02-21 20:39:50 +07:00
|
|
|
|
- (qr(ibx,i) - ql(ibx,i)) * cmax)
|
|
|
|
|
|
2021-12-21 22:59:19 -03:00
|
|
|
|
ql(ibx,i) = bx
|
|
|
|
|
qr(ibx,i) = bx
|
|
|
|
|
ql(ibp,i) = bp
|
|
|
|
|
qr(ibp,i) = bp
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2021-12-21 22:59:19 -03:00
|
|
|
|
end do
|
|
|
|
|
end if
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! get the numerical fluxes
|
2014-03-06 12:59:51 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call riemann_solver(ql(:,:), qr(:,:), f(:,:))
|
2020-02-22 10:05:42 +07:00
|
|
|
|
|
|
|
|
|
! higher order flux corrections
|
|
|
|
|
!
|
2021-12-21 22:59:19 -03:00
|
|
|
|
call higher_order_flux_correction(f)
|
|
|
|
|
|
|
|
|
|
end if
|
2020-02-22 10:05:42 +07:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2020-02-22 10:27:27 +07:00
|
|
|
|
end subroutine numerical_flux
|
2020-02-22 10:05:42 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! GENERIC RIEMANN SOLVERS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
2020-02-22 10:05:42 +07:00
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! subroutine RIEMANN_HLL:
|
|
|
|
|
! ----------------------
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! Subroutine solves one dimensional general Riemann problem using
|
|
|
|
|
! the Harten-Lax-van Leer (HLL) method.
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! Arguments:
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! References:
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2022-01-20 12:51:34 -03:00
|
|
|
|
! [1] Harten, A., Lax, P. D., Van Leer, B.
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! "On Upstream Differencing and Godunov-Type Schemes for Hyperbolic
|
|
|
|
|
! Conservation Laws",
|
2022-01-20 12:51:34 -03:00
|
|
|
|
! SIAM Review, 1983, Volume 25, Number 1, pp. 35-61,
|
|
|
|
|
! https://doi.org/10.1137/1025002
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2013-12-11 10:16:06 -02:00
|
|
|
|
!===============================================================================
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_hll(ql, qr, fi)
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
|
|
|
|
|
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: sl, sr
|
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
|
|
|
|
|
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
|
|
|
|
|
|
|
|
|
do i = 1, nn
|
|
|
|
|
|
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
|
|
|
|
|
|
|
|
|
if (sl >= 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
fi(:,i) = fl(:,i)
|
|
|
|
|
|
|
|
|
|
else if (sr <= 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
fi(:,i) = fr(:,i)
|
|
|
|
|
|
|
|
|
|
else ! sl < 0 < sr
|
|
|
|
|
|
2022-01-20 12:51:34 -03:00
|
|
|
|
wl = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr = sr * ur(:,i) - fr(:,i)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
2022-01-20 12:51:34 -03:00
|
|
|
|
fi(:,i) = (sl * wr - sr * wl) / (sr - sl)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
end if ! sl < 0 < sr
|
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine riemann_hll
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! ISOTHERMAL HYDRODYNAMIC RIEMANN SOLVERS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! subroutine RIEMANN_HD_ISO_ROE:
|
|
|
|
|
! -----------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine solves one dimensional Riemann problem using
|
|
|
|
|
! the Roe's method.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Roe, P. L.
|
|
|
|
|
! "Approximate Riemann Solvers, Parameter Vectors, and Difference
|
|
|
|
|
! Schemes",
|
|
|
|
|
! Journal of Computational Physics, 1981, 43, pp. 357-372
|
|
|
|
|
! [2] Toro, E. F.,
|
|
|
|
|
! "Riemann Solvers and Numerical Methods for Fluid dynamics",
|
|
|
|
|
! Springer-Verlag Berlin Heidelberg, 2009
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_hd_iso_roe(ql, qr, fi)
|
|
|
|
|
|
|
|
|
|
use coordinates, only : nn => bcells
|
2022-01-20 16:57:06 -03:00
|
|
|
|
use equations , only : nf, csnd
|
|
|
|
|
use equations , only : idn, ivx, ivy, ivz
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
2013-12-11 10:16:06 -02:00
|
|
|
|
implicit none
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
|
|
|
|
|
2022-01-20 16:57:06 -03:00
|
|
|
|
integer :: i
|
2022-01-21 18:59:20 -03:00
|
|
|
|
real(kind=8) :: sdl, sdr, sds, cs, ch
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
2022-01-20 16:57:06 -03:00
|
|
|
|
real(kind=8), dimension(nf ) :: qs, lm, al, df
|
|
|
|
|
|
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
real(kind=8) , save :: chi
|
|
|
|
|
real(kind=8), dimension(4,4), save :: rvec, lvec
|
|
|
|
|
!$omp threadprivate(first, chi, rvec, lvec)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2022-01-20 16:57:06 -03:00
|
|
|
|
if (first) then
|
|
|
|
|
chi = 5.0d-01 / csnd
|
|
|
|
|
|
|
|
|
|
rvec(:,1) = [ 1.0d+00, 0.0d+00, 0.0d+00, 1.0d+00 ]
|
|
|
|
|
rvec(:,2) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rvec(:,3) = [ 0.0d+00, 1.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rvec(:,4) = [ 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00 ]
|
|
|
|
|
|
|
|
|
|
lvec(:,1) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
lvec(:,2) = [ chi , 0.0d+00, 0.0d+00, - chi ]
|
|
|
|
|
lvec(:,3) = [ 0.0d+00, 1.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
lvec(:,4) = [ 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00 ]
|
|
|
|
|
|
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-20 16:57:06 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl)
|
|
|
|
|
call fluxspeed(qr, ur, fr)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
do i = 1, nn
|
|
|
|
|
|
|
|
|
|
sdl = sqrt(ql(idn,i))
|
|
|
|
|
sdr = sqrt(qr(idn,i))
|
|
|
|
|
sds = sdl + sdr
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-20 16:57:06 -03:00
|
|
|
|
qs(idn) = sdl * sdr
|
|
|
|
|
qs(ivx:ivz) = (sdl * ql(ivx:ivz,i) + sdr * qr(ivx:ivz,i)) / sds
|
|
|
|
|
|
2022-01-21 18:59:20 -03:00
|
|
|
|
cs = sign(csnd, qs(ivx))
|
|
|
|
|
ch = sign(chi , qs(ivx))
|
|
|
|
|
|
|
|
|
|
lm(1) = qs(ivx) + cs
|
2022-01-20 16:57:06 -03:00
|
|
|
|
lm(2) = qs(ivx)
|
|
|
|
|
lm(3) = qs(ivx)
|
2022-01-21 18:59:20 -03:00
|
|
|
|
lm(4) = qs(ivx) - cs
|
2022-01-20 16:57:06 -03:00
|
|
|
|
|
|
|
|
|
rvec(1,2) = lm(1)
|
|
|
|
|
rvec(4,2) = lm(4)
|
|
|
|
|
rvec(1,3) = qs(ivy)
|
|
|
|
|
rvec(4,3) = qs(ivy)
|
|
|
|
|
rvec(1,4) = qs(ivz)
|
|
|
|
|
rvec(4,4) = qs(ivz)
|
|
|
|
|
|
2022-01-21 18:59:20 -03:00
|
|
|
|
lvec(1,1) = - ch * lm(4)
|
2022-01-20 16:57:06 -03:00
|
|
|
|
lvec(2,1) = - qs(ivy)
|
|
|
|
|
lvec(3,1) = - qs(ivz)
|
2022-01-21 18:59:20 -03:00
|
|
|
|
lvec(4,1) = ch * lm(1)
|
|
|
|
|
lvec(1,2) = ch
|
|
|
|
|
lvec(4,2) = - ch
|
2022-01-20 16:57:06 -03:00
|
|
|
|
|
|
|
|
|
al = abs(lm) * matmul(lvec, ur(:,i) - ul(:,i))
|
2022-01-21 18:59:20 -03:00
|
|
|
|
df = matmul(al, rvec)
|
2022-01-20 16:57:06 -03:00
|
|
|
|
fi(:,i) = 5.0d-01 * ((fl(:,i) + fr(:,i)) - df)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
end do
|
2016-08-14 20:46:27 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2011-03-21 14:29:40 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_hd_iso_roe
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! subroutine RIEMANN_HD_ISO_KEPES:
|
|
|
|
|
! -------------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine solves one dimensional isothermal hydrodynamic Riemann problem
|
|
|
|
|
! using the entropy stable KEPES method.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Winters, A. R., Czernik, C., Schily, M. B., Gassner, G. J.,
|
|
|
|
|
! "Entropy stable numerical approximations for the isothermal and
|
|
|
|
|
! polytropic Euler equations",
|
|
|
|
|
! BIT Numerical Mathematics (2020) 60:791–824,
|
|
|
|
|
! https://doi.org/10.1007/s10543-019-00789-w
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
subroutine riemann_hd_iso_kepes(ql, qr, fi)
|
|
|
|
|
|
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, csnd, csnd2
|
|
|
|
|
use equations , only : idn, ivx, ivy, ivz, imx, imy, imz
|
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
|
|
|
|
|
2022-01-20 17:48:33 -03:00
|
|
|
|
integer :: i
|
2022-01-21 19:06:28 -03:00
|
|
|
|
real(kind=8) :: v2l, v2r, cs
|
2022-01-20 17:48:33 -03:00
|
|
|
|
real(kind=8) :: dnl, dna, vxa, vya, vza
|
|
|
|
|
|
2022-01-21 19:06:28 -03:00
|
|
|
|
real(kind=8), dimension(nf) :: v, lm, tm
|
2022-01-20 17:48:33 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
real(kind=8), dimension(4,4), save :: rm
|
|
|
|
|
!$omp threadprivate(first, rm)
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
2011-03-21 14:29:40 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (first) then
|
2022-01-20 17:48:33 -03:00
|
|
|
|
rm(:,1) = [ 1.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rm(:,2) = [ 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00 ]
|
|
|
|
|
rm(:,3) = [ 0.0d+00, 0.0d+00, 0.0d+00, 1.0d+00 ]
|
|
|
|
|
rm(:,4) = [ 1.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
2014-03-06 12:15:44 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
2011-03-21 14:29:40 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2011-03-21 14:29:40 -03:00
|
|
|
|
|
2022-01-20 17:48:33 -03:00
|
|
|
|
v2l = sum(ql(ivx:ivz,i) * ql(ivx:ivz,i))
|
|
|
|
|
v2r = sum(qr(ivx:ivz,i) * qr(ivx:ivz,i))
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dnl = lmean(ql(idn,i), qr(idn,i))
|
|
|
|
|
dna = amean(ql(idn,i), qr(idn,i))
|
|
|
|
|
vxa = amean(ql(ivx,i), qr(ivx,i))
|
|
|
|
|
vya = amean(ql(ivy,i), qr(ivy,i))
|
|
|
|
|
vza = amean(ql(ivz,i), qr(ivz,i))
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-20 17:48:33 -03:00
|
|
|
|
v(idn) = 5.0d-01 * (v2l - v2r)
|
|
|
|
|
if (qr(idn,i) > ql(idn,i)) then
|
2022-01-21 19:40:55 -03:00
|
|
|
|
v(idn) = v(idn) + csnd2 * log(qr(idn,i) / ql(idn,i))
|
2022-01-20 17:48:33 -03:00
|
|
|
|
else if (ql(idn,i) > qr(idn,i)) then
|
2022-01-21 19:40:55 -03:00
|
|
|
|
v(idn) = v(idn) - csnd2 * log(ql(idn,i) / qr(idn,i))
|
2022-01-20 17:48:33 -03:00
|
|
|
|
end if
|
2022-01-19 11:53:56 -03:00
|
|
|
|
v(ivx) = qr(ivx,i) - ql(ivx,i)
|
|
|
|
|
v(ivy) = qr(ivy,i) - ql(ivy,i)
|
|
|
|
|
v(ivz) = qr(ivz,i) - ql(ivz,i)
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-21 19:06:28 -03:00
|
|
|
|
cs = sign(csnd, vxa)
|
|
|
|
|
|
|
|
|
|
lm(:) = [ vxa + cs, vxa, vxa, vxa - cs ]
|
2014-03-06 12:15:44 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
tm(1) = 5.0d-01 * dnl / csnd2
|
|
|
|
|
tm(2) = dnl
|
|
|
|
|
tm(3) = dnl
|
|
|
|
|
tm(4) = tm(1)
|
|
|
|
|
|
2022-01-20 17:48:33 -03:00
|
|
|
|
rm(2:4,1) = [ lm(1), vya, vza ]
|
|
|
|
|
rm(2:4,4) = [ lm(4), vya, vza ]
|
2011-03-21 14:29:40 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(idn,i) = dnl * vxa
|
|
|
|
|
fi(imx,i) = fi(idn,i) * vxa + csnd2 * dna
|
|
|
|
|
fi(imy,i) = fi(idn,i) * vya
|
|
|
|
|
fi(imz,i) = fi(idn,i) * vza
|
2012-08-01 16:38:10 -03:00
|
|
|
|
|
2022-01-21 19:06:28 -03:00
|
|
|
|
fi(:,i) = fi(:,i) - 5.0d-01 * matmul(rm, (abs(lm) * tm) * matmul(v, rm))
|
2022-01-20 17:48:33 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end do
|
2011-03-21 14:29:40 -03:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2012-08-01 16:38:10 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_hd_iso_kepes
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! ADIABATIC HYDRODYNAMIC RIEMANN SOLVERS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
2011-03-21 14:29:40 -03:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!===============================================================================
|
2014-03-05 19:04:23 -03:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! subroutine RIEMANN_HD_HLLC:
|
|
|
|
|
! --------------------------
|
2014-01-02 12:32:19 -02:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using the HLLC
|
|
|
|
|
! method by Gurski or Li. The HLLC and HLLC-C differ by definitions of
|
|
|
|
|
! the tangential components of the velocity and magnetic field.
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-20 18:02:05 -03:00
|
|
|
|
! [1] Toro, E. F.,
|
|
|
|
|
! "The HLLC Riemann solver",
|
|
|
|
|
! Shock Waves, 2019, 29, 8, 1065-1082,
|
|
|
|
|
! https://doi.org/10.1007/s00193-019-00912-4
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_hd_hllc(ql, qr, fi)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
2022-01-20 18:02:05 -03:00
|
|
|
|
use equations , only : nf
|
|
|
|
|
use equations , only : idn, ivy, ivz, imx, imy, imz, ien
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-08-06 18:56:57 -03:00
|
|
|
|
integer :: i
|
2020-02-21 20:39:50 +07:00
|
|
|
|
real(kind=8) :: dn, pr
|
2020-08-06 18:56:57 -03:00
|
|
|
|
real(kind=8) :: sl, sr, sm, slmm, srmm
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr, ui
|
|
|
|
|
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
|
|
|
|
|
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
|
|
|
|
|
|
|
|
|
do i = 1, nn
|
2014-01-02 12:32:19 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
2019-03-30 22:50:08 -03:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
if (sl >= 0.0d+00) then
|
2019-02-05 22:08:30 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
else if (sr <= 0.0d+00) then
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
else ! sl < 0 < sr
|
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
wl = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr = sr * ur(:,i) - fr(:,i)
|
2016-08-14 19:48:46 -03:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
dn = wr(idn) - wl(idn)
|
|
|
|
|
sm = (wr(imx) - wl(imx)) / dn
|
2016-08-14 19:48:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
pr = (wl(idn) * wr(imx) - wr(idn) * wl(imx)) / dn
|
2016-08-14 19:48:46 -03:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
if (sm > 0.0d+00) then
|
2016-08-14 19:48:46 -03:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
slmm = sl - sm
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
ui(idn) = wl(idn) / slmm
|
|
|
|
|
ui(imx) = ui(idn) * sm
|
|
|
|
|
ui(imy) = ui(idn) * ql(ivy,i)
|
|
|
|
|
ui(imz) = ui(idn) * ql(ivz,i)
|
|
|
|
|
ui(ien) = (wl(ien) + sm * pr) / slmm
|
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
fi(:,i) = sl * ui - wl
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
else if (sm < 0.0d+00) then
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
srmm = sr - sm
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
ui(idn) = wr(idn) / srmm
|
|
|
|
|
ui(imx) = ui(idn) * sm
|
|
|
|
|
ui(imy) = ui(idn) * qr(ivy,i)
|
|
|
|
|
ui(imz) = ui(idn) * qr(ivz,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pr) / srmm
|
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
fi(:,i) = sr * ui - wr
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
else
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
fi(:,i) = (sl * wr - sr * wl) / (sr - sl)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
end if
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-20 18:02:05 -03:00
|
|
|
|
end if
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine riemann_hd_hllc
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_HD_ADI_ROE:
|
|
|
|
|
! -----------------------------
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using
|
|
|
|
|
! the Roe's method.
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Roe, P. L.
|
|
|
|
|
! "Approximate Riemann Solvers, Parameter Vectors, and Difference
|
|
|
|
|
! Schemes",
|
|
|
|
|
! Journal of Computational Physics, 1981, 43, pp. 357-372
|
2022-01-21 18:47:17 -03:00
|
|
|
|
! https://doi.org/10.1016/0021-9991(81)90128-5
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [2] Toro, E. F.,
|
|
|
|
|
! "Riemann Solvers and Numerical Methods for Fluid dynamics",
|
|
|
|
|
! Springer-Verlag Berlin Heidelberg, 2009
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_hd_adi_roe(ql, qr, fi)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
2022-01-21 18:47:17 -03:00
|
|
|
|
use equations , only : nf, adiabatic_index
|
|
|
|
|
use equations , only : idn, ivx, ivy, ivz, ipr, ien
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 18:47:17 -03:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: sdl, sdr, sds, vv, vh, c2, cs, vc, fa, fb, fc, f1, f2, f3
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
2022-01-21 18:47:17 -03:00
|
|
|
|
real(kind=8), dimension(nf ) :: qs, lm, al, df
|
|
|
|
|
|
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
real(kind=8) , save :: adi_m1, adi_m1x
|
|
|
|
|
real(kind=8), dimension(5,5), save :: rvec, lvec
|
|
|
|
|
!$omp threadprivate(first, adi_m1, adi_m1x, rvec, lvec)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!
|
2022-01-21 18:47:17 -03:00
|
|
|
|
if (first) then
|
|
|
|
|
|
|
|
|
|
adi_m1 = adiabatic_index - 1.0d+00
|
|
|
|
|
adi_m1x = adiabatic_index / adi_m1
|
|
|
|
|
|
|
|
|
|
rvec(:,1) = [ 1.0d+00, 1.0d+00, 0.0d+00, 0.0d+00, 1.0d+00 ]
|
|
|
|
|
rvec(:,2) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rvec(:,3) = [ 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rvec(:,4) = [ 0.0d+00, 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00 ]
|
|
|
|
|
rvec(:,5) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
|
|
|
|
|
lvec(:,1) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
lvec(:,2) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
lvec(:,3) = [ 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
lvec(:,4) = [ 0.0d+00, 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00 ]
|
|
|
|
|
lvec(:,5) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
|
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 18:47:17 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl)
|
|
|
|
|
call fluxspeed(qr, ur, fr)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sdl = sqrt(ql(idn,i))
|
|
|
|
|
sdr = sqrt(qr(idn,i))
|
|
|
|
|
sds = sdl + sdr
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 18:47:17 -03:00
|
|
|
|
qs(idn) = sdl * sdr
|
|
|
|
|
qs(ivx:ivz) = (sdl * ql(ivx:ivz,i) + sdr * qr(ivx:ivz,i)) / sds
|
|
|
|
|
qs(ien) = ((ul(ien,i) + ql(ipr,i)) / sdl &
|
|
|
|
|
+ (ur(ien,i) + qr(ipr,i)) / sdr) / sds ! enthalpy
|
|
|
|
|
|
|
|
|
|
vv = sum(qs(ivx:ivz) * qs(ivx:ivz))
|
|
|
|
|
vh = 5.0d-01 * vv
|
|
|
|
|
c2 = adi_m1 * (qs(ien) - vh)
|
|
|
|
|
cs = sign(sqrt(c2), qs(ivx))
|
|
|
|
|
fa = adi_m1 / c2
|
|
|
|
|
fb = 5.0d-01 * fa
|
|
|
|
|
fc = 5.0d-01 / cs
|
|
|
|
|
vc = cs * qs(ivx)
|
|
|
|
|
f1 = fb * vh
|
|
|
|
|
f2 = fc * qs(ivx)
|
|
|
|
|
f3 = - fb * qs(ivx)
|
|
|
|
|
|
|
|
|
|
lm(1) = qs(ivx) + cs
|
|
|
|
|
lm(2) = qs(ivx)
|
|
|
|
|
lm(3) = qs(ivx)
|
|
|
|
|
lm(4) = qs(ivx)
|
|
|
|
|
lm(5) = qs(ivx) - cs
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 18:47:17 -03:00
|
|
|
|
rvec(1,2) = lm(1)
|
|
|
|
|
rvec(1,3) = qs(ivy)
|
|
|
|
|
rvec(1,4) = qs(ivz)
|
|
|
|
|
rvec(1,5) = qs(ien) + vc
|
|
|
|
|
rvec(2,2) = qs(ivx)
|
|
|
|
|
rvec(2,3) = qs(ivy)
|
|
|
|
|
rvec(2,4) = qs(ivz)
|
|
|
|
|
rvec(2,5) = vh
|
|
|
|
|
rvec(3,5) = qs(ivy)
|
|
|
|
|
rvec(4,5) = qs(ivz)
|
|
|
|
|
rvec(5,2) = lm(5)
|
|
|
|
|
rvec(5,3) = qs(ivy)
|
|
|
|
|
rvec(5,4) = qs(ivz)
|
|
|
|
|
rvec(5,5) = qs(ien) - vc
|
|
|
|
|
|
|
|
|
|
lvec(1,1) = f1 - f2
|
|
|
|
|
lvec(1,2) = f3 + fc
|
|
|
|
|
lvec(1,3) = - fb * qs(ivy)
|
|
|
|
|
lvec(1,4) = - fb * qs(ivz)
|
|
|
|
|
lvec(1,5) = fb
|
|
|
|
|
lvec(2,1) = - fa * vh + 1.0d+00
|
|
|
|
|
lvec(2,2) = fa * qs(ivx)
|
|
|
|
|
lvec(2,3) = fa * qs(ivy)
|
|
|
|
|
lvec(2,4) = fa * qs(ivz)
|
|
|
|
|
lvec(2,5) = - fa
|
|
|
|
|
lvec(3,1) = - qs(ivy)
|
|
|
|
|
lvec(4,1) = - qs(ivz)
|
|
|
|
|
lvec(5,1) = f1 + f2
|
|
|
|
|
lvec(5,2) = f3 - fc
|
|
|
|
|
lvec(5,3) = lvec(1,3)
|
|
|
|
|
lvec(5,4) = lvec(1,4)
|
|
|
|
|
lvec(5,5) = fb
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 18:47:17 -03:00
|
|
|
|
al = abs(lm) * matmul(lvec, ur(:,i) - ul(:,i))
|
|
|
|
|
df = matmul(al, rvec)
|
|
|
|
|
fi(:,i) = 5.0d-01 * ((fl(:,i) + fr(:,i)) - df)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
end do
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_hd_adi_roe
|
2013-12-20 13:53:45 -02:00
|
|
|
|
!
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_HD_ADI_KEPES:
|
|
|
|
|
! -------------------------------
|
2020-02-22 06:57:02 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional adiabatic hydrodynamic Riemann problem
|
|
|
|
|
! using the entropy stable KEPES method.
|
2020-02-22 06:57:02 +07:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2020-02-22 06:57:02 +07:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Winters, A. R., Derigs, D., Gassner, G. J., Walch, S.
|
|
|
|
|
! "A uniquely defined entropy stable matrix dissipation operator
|
|
|
|
|
! for high Mach number ideal MHD and compressible Euler
|
|
|
|
|
! simulations",
|
|
|
|
|
! Journal of Computational Physics, 2017, 332, pp. 274-289
|
2022-01-21 19:35:58 -03:00
|
|
|
|
! https://doi.org/10.1016/j.jcp.2016.12.006
|
2020-02-22 06:57:02 +07:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_hd_adi_kepes(ql, qr, fi)
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, adiabatic_index
|
|
|
|
|
use equations , only : idn, ivx, ivy, ivz, ipr, imx, imy, imz, ien
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: bl, br, v2l, v2r, cs, vc
|
|
|
|
|
real(kind=8) :: btl, dnl, prl, bta, dna, vxa, vya, vza, vva, pra, ent
|
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(nf) :: v, lm, tm
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
real(kind=8) , save :: adi_m1, adi_m1x
|
|
|
|
|
real(kind=8), dimension(5,5), save :: rm
|
|
|
|
|
!$omp threadprivate(first, adi_m1, adi_m1x, rm)
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-02-22 06:57:02 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (first) then
|
|
|
|
|
adi_m1 = adiabatic_index - 1.0d+00
|
|
|
|
|
adi_m1x = adi_m1 / adiabatic_index
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,:) = [ 1.0d+00, 1.0d+00, 0.0d+00, 0.0d+00, 1.0d+00 ]
|
|
|
|
|
rm(2,:) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rm(3,:) = [ 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00, 0.0d+00 ]
|
|
|
|
|
rm(4,:) = [ 0.0d+00, 0.0d+00, 0.0d+00, 1.0d+00, 0.0d+00 ]
|
|
|
|
|
rm(5,:) = [ 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00, 0.0d+00 ]
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
bl = ql(idn,i) / ql(ipr,i)
|
|
|
|
|
br = qr(idn,i) / qr(ipr,i)
|
|
|
|
|
v2l = sum(ql(ivx:ivz,i) * ql(ivx:ivz,i))
|
|
|
|
|
v2r = sum(qr(ivx:ivz,i) * qr(ivx:ivz,i))
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
btl = lmean(bl, br)
|
|
|
|
|
bta = amean(bl, br)
|
|
|
|
|
dnl = lmean(ql(idn,i), qr(idn,i))
|
|
|
|
|
dna = amean(ql(idn,i), qr(idn,i))
|
|
|
|
|
vxa = amean(ql(ivx,i), qr(ivx,i))
|
|
|
|
|
vya = amean(ql(ivy,i), qr(ivy,i))
|
|
|
|
|
vza = amean(ql(ivz,i), qr(ivz,i))
|
|
|
|
|
pra = dna / bta
|
|
|
|
|
prl = dnl / btl
|
|
|
|
|
vva = 5.0d-01 * sum(ql(ivx:ivz,i) * qr(ivx:ivz,i))
|
|
|
|
|
ent = 1.0d+00 / adi_m1x / btl + vva
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
v(idn) = 5.0d-01 * (bl * v2l - br * v2r)
|
|
|
|
|
if (qr(idn,i) > ql(idn,i)) then
|
|
|
|
|
v(idn) = v(idn) + log(qr(idn,i) / ql(idn,i))
|
|
|
|
|
else if (ql(idn,i) > qr(idn,i)) then
|
|
|
|
|
v(idn) = v(idn) - log(ql(idn,i) / qr(idn,i))
|
|
|
|
|
end if
|
|
|
|
|
if (br > bl) then
|
|
|
|
|
v(idn) = v(idn) + log(br / bl) / adi_m1
|
|
|
|
|
else if (bl > br) then
|
|
|
|
|
v(idn) = v(idn) - log(bl / br) / adi_m1
|
|
|
|
|
end if
|
2022-01-19 11:53:56 -03:00
|
|
|
|
v(ivx) = br * qr(ivx,i) - bl * ql(ivx,i)
|
|
|
|
|
v(ivy) = br * qr(ivy,i) - bl * ql(ivy,i)
|
|
|
|
|
v(ivz) = br * qr(ivz,i) - bl * ql(ivz,i)
|
|
|
|
|
v(ipr) = bl - br
|
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
cs = sign(sqrt(adiabatic_index * pra / dnl), vxa)
|
|
|
|
|
vc = vxa * cs
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
lm(1) = vxa + cs
|
2022-01-19 11:53:56 -03:00
|
|
|
|
lm(2) = vxa
|
|
|
|
|
lm(3) = vxa
|
|
|
|
|
lm(4) = vxa
|
2022-01-21 19:35:58 -03:00
|
|
|
|
lm(5) = vxa - cs
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
tm(1) = 5.0d-01 * dnl / adiabatic_index
|
|
|
|
|
tm(2) = dnl * adi_m1x
|
|
|
|
|
tm(3) = pra
|
|
|
|
|
tm(4) = pra
|
|
|
|
|
tm(5) = tm(1)
|
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
rm(2,1) = lm(1)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,1) = vya
|
|
|
|
|
rm(4,1) = vza
|
|
|
|
|
rm(2,2) = vxa
|
|
|
|
|
rm(3,2) = vya
|
|
|
|
|
rm(4,2) = vza
|
2022-01-21 19:35:58 -03:00
|
|
|
|
rm(2,5) = lm(5)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,5) = vya
|
|
|
|
|
rm(4,5) = vza
|
2022-01-21 19:35:58 -03:00
|
|
|
|
rm(5,:) = [ ent + vc, vva, vya, vza, ent - vc ]
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
fi(idn,i) = dnl * vxa
|
|
|
|
|
fi(imx,i) = fi(idn,i) * vxa + pra
|
|
|
|
|
fi(imy,i) = fi(idn,i) * vya
|
|
|
|
|
fi(imz,i) = fi(idn,i) * vza
|
|
|
|
|
fi(ien,i) = (prl / adi_m1 + pra + dnl * vva) * vxa
|
|
|
|
|
|
2022-01-21 19:35:58 -03:00
|
|
|
|
fi(:,i) = fi(:,i) - 5.0d-01 * matmul(rm, (abs(lm) * tm) * matmul(v, rm))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine riemann_hd_adi_kepes
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! RELATIVISTIC ADIABATIC HYDRODYNAMIC RIEMANN SOLVERS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! subroutine RIEMANN_SRHD_HLLC:
|
|
|
|
|
! ----------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine solves one dimensional Riemann problem using
|
|
|
|
|
! the Harten-Lax-van Leer method with contact discontinuity resolution (HLLC)
|
|
|
|
|
! by Mignone & Bodo.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Mignone, A. & Bodo, G.
|
|
|
|
|
! "An HLLC Riemann solver for relativistic flows - I. Hydrodynamics",
|
|
|
|
|
! Monthly Notices of the Royal Astronomical Society,
|
|
|
|
|
! 2005, Volume 364, Pages 126-136
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
subroutine riemann_srhd_hllc(ql, qr, fi)
|
|
|
|
|
|
|
|
|
|
use algebra , only : quadratic
|
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, idn, imx, imy, imz, ien
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
|
|
|
|
|
|
|
|
|
integer :: i, nr
|
|
|
|
|
real(kind=8) :: sl, sr, srml, sm
|
|
|
|
|
real(kind=8) :: pr, dv
|
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr, uh, us, fh
|
|
|
|
|
real(kind=8), dimension(3) :: a
|
|
|
|
|
real(kind=8), dimension(2) :: x
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
|
|
|
|
|
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
|
|
|
|
|
|
|
|
|
do i = 1, nn
|
|
|
|
|
|
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
|
|
|
|
|
|
|
|
|
if (sl >= 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
fi(:,i) = fl(:,i)
|
|
|
|
|
|
|
|
|
|
else if (sr <= 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
fi(:,i) = fr(:,i)
|
|
|
|
|
|
|
|
|
|
else ! sl < 0 < sr
|
|
|
|
|
|
|
|
|
|
srml = sr - sl
|
|
|
|
|
|
2020-02-22 06:57:02 +07:00
|
|
|
|
wl(:) = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr(:) = sr * ur(:,i) - fr(:,i)
|
|
|
|
|
|
|
|
|
|
uh(:) = ( wr(:) - wl(:)) / srml
|
|
|
|
|
fh(:) = (sl * wr(:) - sr * wl(:)) / srml
|
|
|
|
|
|
|
|
|
|
wl(ien) = wl(ien) + wl(idn)
|
|
|
|
|
wr(ien) = wr(ien) + wr(idn)
|
|
|
|
|
|
|
|
|
|
! prepare the quadratic coefficients (eq. 18 in [1])
|
|
|
|
|
!
|
|
|
|
|
a(1) = uh(imx)
|
|
|
|
|
a(2) = - (fh(imx) + uh(ien) + uh(idn))
|
|
|
|
|
a(3) = fh(ien) + fh(idn)
|
|
|
|
|
|
|
|
|
|
! solve the quadratic equation
|
|
|
|
|
!
|
|
|
|
|
nr = quadratic(a(1:3), x(1:2))
|
|
|
|
|
|
|
|
|
|
! if Δ < 0, just use the HLL flux
|
|
|
|
|
!
|
|
|
|
|
if (nr < 1) then
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fh(:)
|
2020-02-22 06:57:02 +07:00
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
! get the contact dicontinuity speed
|
|
|
|
|
!
|
|
|
|
|
sm = x(1)
|
|
|
|
|
|
|
|
|
|
! if the contact discontinuity speed exceeds the sonic speeds, use the HLL flux
|
|
|
|
|
!
|
|
|
|
|
if ((sm <= sl) .or. (sm >= sr)) then
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fh(:)
|
2020-02-22 06:57:02 +07:00
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
! calculate total pressure (eq. 17 in [1])
|
|
|
|
|
!
|
|
|
|
|
pr = fh(imx) - (fh(ien) + fh(idn)) * sm
|
|
|
|
|
|
|
|
|
|
! if the pressure is negative, use the HLL flux
|
|
|
|
|
!
|
|
|
|
|
if (pr <= 0.0d+00) then
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fh(:)
|
2020-02-22 06:57:02 +07:00
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
! depending in the sign of the contact dicontinuity speed, calculate the proper
|
|
|
|
|
! state and corresponding flux
|
|
|
|
|
!
|
|
|
|
|
if (sm > 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
! calculate the conserved variable vector (eqs. 16 in [1])
|
|
|
|
|
!
|
|
|
|
|
dv = sl - sm
|
|
|
|
|
us(idn) = wl(idn) / dv
|
|
|
|
|
us(imy) = wl(imy) / dv
|
|
|
|
|
us(imz) = wl(imz) / dv
|
|
|
|
|
us(ien) = (wl(ien) + pr * sm) / dv
|
|
|
|
|
us(imx) = (us(ien) + pr) * sm
|
|
|
|
|
us(ien) = us(ien) - us(idn)
|
|
|
|
|
|
|
|
|
|
! calculate the flux (eq. 14 in [1])
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i) + sl * (us(:) - ul(:,i))
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
|
|
|
|
else if (sm < 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
! calculate the conserved variable vector (eqs. 16 in [1])
|
|
|
|
|
!
|
|
|
|
|
dv = sr - sm
|
|
|
|
|
us(idn) = wr(idn) / dv
|
|
|
|
|
us(imy) = wr(imy) / dv
|
|
|
|
|
us(imz) = wr(imz) / dv
|
|
|
|
|
us(ien) = (wr(ien) + pr * sm) / dv
|
|
|
|
|
us(imx) = (us(ien) + pr) * sm
|
|
|
|
|
us(ien) = us(ien) - us(idn)
|
|
|
|
|
|
|
|
|
|
! calculate the flux (eq. 14 in [1])
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i) + sr * (us(:) - ur(:,i))
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
! intermediate flux is constant across the contact discontinuity and all fluxes
|
|
|
|
|
! except the parallel momentum one are zero
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(idn,i) = 0.0d+00
|
|
|
|
|
fi(imx,i) = pr
|
|
|
|
|
fi(imy,i) = 0.0d+00
|
|
|
|
|
fi(imz,i) = 0.0d+00
|
|
|
|
|
fi(ien,i) = 0.0d+00
|
2020-02-22 06:57:02 +07:00
|
|
|
|
|
|
|
|
|
end if ! sm == 0
|
|
|
|
|
|
|
|
|
|
end if ! p* < 0
|
|
|
|
|
|
|
|
|
|
end if ! sl < sm < sr
|
|
|
|
|
|
|
|
|
|
end if ! nr < 1
|
|
|
|
|
|
|
|
|
|
end if ! sl < 0 < sr
|
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine riemann_srhd_hllc
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! ISOTHERMAL MAGNETOHYDRODYNAMIC RIEMANN SOLVERS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
2020-02-22 06:57:02 +07:00
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_ISO_MHD_HLLD:
|
|
|
|
|
! -------------------------------
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using the modified
|
|
|
|
|
! isothermal HLLD method by Mignone. The difference is in allowing a density
|
|
|
|
|
! jumps across the Alfvén waves, due to the inner intermediate states being
|
|
|
|
|
! an average of the states between two Alfvén waves, which also include
|
|
|
|
|
! two slow magnetosonic waves. Moreover, due to the different left and right
|
|
|
|
|
! intermediate state densities the left and right Alfvén speeds might be
|
|
|
|
|
! different too.
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2020-02-22 06:08:09 +07:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Mignone, A.,
|
|
|
|
|
! "A simple and accurate Riemann solver for isothermal MHD",
|
|
|
|
|
! Journal of Computational Physics, 2007, 225, pp. 1427-1441,
|
|
|
|
|
! https://doi.org/10.1016/j.jcp.2007.01.033
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_iso_hlld(ql, qr, fi)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, idn, imx, imy, imz, ibx, iby, ibz, ibp
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
implicit none
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: sl, sr, sm, sml, smr, srml, slmm, srmm
|
2022-01-21 21:29:38 -03:00
|
|
|
|
real(kind=8) :: bx, b2, dvl, dvr, dnl, dnr
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr, wcl, wcr, uil, uir
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
|
|
|
|
|
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
|
|
|
|
|
|
|
|
|
do i = 1, nn
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-22 06:08:09 +07:00
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-22 06:08:09 +07:00
|
|
|
|
if (sl >= 0.0d+00) then
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2020-02-22 06:08:09 +07:00
|
|
|
|
else if (sr <= 0.0d+00) then
|
2017-04-10 07:56:49 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i)
|
2017-04-10 07:56:49 -03:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
else
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
bx = ql(ibx,i)
|
|
|
|
|
b2 = ql(ibx,i) * qr(ibx,i)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wl(:) = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr(:) = sr * ur(:,i) - fr(:,i)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sm = (wr(imx) - wl(imx)) / (wr(idn) - wl(idn))
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
srml = sr - sl
|
|
|
|
|
slmm = sl - sm
|
|
|
|
|
srmm = sr - sm
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uil(idn) = wl(idn) / slmm
|
|
|
|
|
uir(idn) = wr(idn) / srmm
|
|
|
|
|
uil(imx) = uil(idn) * sm
|
|
|
|
|
uir(imx) = uir(idn) * sm
|
|
|
|
|
uil(ibx) = bx
|
|
|
|
|
uir(ibx) = bx
|
|
|
|
|
uil(ibp) = ql(ibp,i)
|
|
|
|
|
uir(ibp) = qr(ibp,i)
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sml = sm - abs(bx) / sqrt(uil(idn))
|
|
|
|
|
smr = sm + abs(bx) / sqrt(uir(idn))
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dvl = slmm * wl(idn) - b2
|
|
|
|
|
dvr = srmm * wr(idn) - b2
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
dnr = uir(idn) / dvr
|
|
|
|
|
dnl = uil(idn) / dvl
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! check degeneracy Sl* -> Sl or Sr* -> Sr
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > sl .and. smr < sr .and. min(dvl, dvr) > 0.0d+00) then
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > 0.0d+00) then ! sl* > 0
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
uil(imy) = dnl * (slmm * wl(imy) - bx * wl(iby))
|
|
|
|
|
uil(imz) = dnl * (slmm * wl(imz) - bx * wl(ibz))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uil(iby) = (wl(idn) * wl(iby) - bx * wl(imy)) / dvl
|
|
|
|
|
uil(ibz) = (wl(idn) * wl(ibz) - bx * wl(imz)) / dvl
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sl * uil(:) - wl(:)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (smr < 0.0d+00) then ! sr* < 0
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
uir(imy) = dnr * (srmm * wr(imy) - bx * wr(iby))
|
|
|
|
|
uir(imz) = dnr * (srmm * wr(imz) - bx * wr(ibz))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uir(iby) = (wr(idn) * wr(iby) - bx * wr(imy)) / dvr
|
|
|
|
|
uir(ibz) = (wr(idn) * wr(ibz) - bx * wr(imz)) / dvr
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * uir(:) - wr(:)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl* <= 0 <= sr*
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (smr > sml) then
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
uil(imy) = dnl * (slmm * wl(imy) - bx * wl(iby))
|
|
|
|
|
uil(imz) = dnl * (slmm * wl(imz) - bx * wl(ibz))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uil(iby) = (wl(idn) * wl(iby) - bx * wl(imy)) / dvl
|
|
|
|
|
uil(ibz) = (wl(idn) * wl(ibz) - bx * wl(imz)) / dvl
|
2019-03-30 22:50:08 -03:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
uir(imy) = dnr * (srmm * wr(imy) - bx * wr(iby))
|
|
|
|
|
uir(imz) = dnr * (srmm * wr(imz) - bx * wr(ibz))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uir(iby) = (wr(idn) * wr(iby) - bx * wr(imy)) / dvr
|
|
|
|
|
uir(ibz) = (wr(idn) * wr(ibz) - bx * wr(imz)) / dvr
|
2013-12-20 13:53:45 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcl(:) = (sml - sl) * uil(:) + wl(:)
|
|
|
|
|
wcr(:) = (smr - sr) * uir(:) + wr(:)
|
2014-01-02 12:32:19 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dvl = smr - sml
|
|
|
|
|
fi(:,i) = (sml * wcr(:) - smr * wcl(:)) / dvl
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Bx = 0 -> Sₘ = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl* <= 0 <= sr*
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sml > sl .and. dvl > 0.0d+00) then ! sr* > sr
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
uil(imy) = dnl * (slmm * wl(imy) - bx * wl(iby))
|
|
|
|
|
uil(imz) = dnl * (slmm * wl(imz) - bx * wl(ibz))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uil(iby) = (wl(idn) * wl(iby) - bx * wl(imy)) / dvl
|
|
|
|
|
uil(ibz) = (wl(idn) * wl(ibz) - bx * wl(imz)) / dvl
|
2014-01-02 12:32:19 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > 0.0d+00) then ! sl* > 0
|
2019-03-30 22:50:08 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sl * uil(:) - wl(:)
|
2019-02-05 22:08:30 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sr > sml) then
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcl(:) = (sml - sl) * uil(:) + wl(:)
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dvl = sr - sml
|
|
|
|
|
fi(:,i) = (sml * wr(:) - sr * wcl(:)) / dvl
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Bx = 0 -> Sₘ = 0
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl* < 0
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (smr < sr .and. dvr > 0.0d+00) then ! sl* < sl
|
2013-12-20 14:01:33 -02:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
uir(imy) = dnr * (srmm * wr(imy) - bx * wr(iby))
|
|
|
|
|
uir(imz) = dnr * (srmm * wr(imz) - bx * wr(ibz))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uir(iby) = (wr(idn) * wr(iby) - bx * wr(imy)) / dvr
|
|
|
|
|
uir(ibz) = (wr(idn) * wr(ibz) - bx * wr(imz)) / dvr
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (smr < 0.0d+00) then ! sr* < 0
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * uir(:) - wr(:)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (smr > sl) then
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcr(:) = (smr - sr) * uir(:) + wr(:)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dvr = smr - sl
|
|
|
|
|
fi(:,i) = (sl * wcr(:) - smr * wl(:)) / dvr
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Bx = 0 -> Sₘ = 0
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sr* > 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl* < sl & sr* > sr
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
2022-01-21 21:29:38 -03:00
|
|
|
|
end if
|
2020-02-22 06:08:09 +07:00
|
|
|
|
|
|
|
|
|
end do
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_mhd_iso_hlld
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_MHD_ISO_ROE:
|
|
|
|
|
! ------------------------------
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using
|
|
|
|
|
! the Roe's method.
|
2014-03-06 13:55:09 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2020-02-22 06:45:14 +07:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Stone, J. M. & Gardiner, T. A.,
|
|
|
|
|
! "ATHENA: A New Code for Astrophysical MHD",
|
|
|
|
|
! The Astrophysical Journal Suplement Series, 2008, 178, pp. 137-177
|
|
|
|
|
! [2] Toro, E. F.,
|
|
|
|
|
! "Riemann Solvers and Numerical Methods for Fluid dynamics",
|
|
|
|
|
! Springer-Verlag Berlin Heidelberg, 2009
|
2014-03-06 13:55:09 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_iso_roe(ql, qr, fi)
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
2022-01-26 13:10:55 -03:00
|
|
|
|
use equations , only : nf, csnd2
|
|
|
|
|
use equations , only : idn, imx, imy, imz, ivx, ivy, ivz, &
|
|
|
|
|
ibx, iby, ibz, ibp
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-26 13:10:55 -03:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: sdl, sdr, sds, xx, yy, bty, btz, br, br2
|
|
|
|
|
real(kind=8) :: cc, ca, cs, cf, cc2, ca2, cs2, cf2, alf, als
|
|
|
|
|
real(kind=8) :: vqstr, sqrtd, qs, qf, norm, css, cff
|
|
|
|
|
real(kind=8) :: as_prime, af_prime, as, af, aspb, afpb
|
2022-01-28 12:58:31 -03:00
|
|
|
|
real(kind=8) :: f1, f2, f3, f4
|
2022-01-02 12:56:24 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
2022-01-26 13:10:55 -03:00
|
|
|
|
real(kind=8), dimension(nf ) :: qi
|
|
|
|
|
real(kind=8), dimension(6 ) :: lm, al, df
|
|
|
|
|
|
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
integer , dimension(6) , save :: ivs
|
|
|
|
|
real(kind=8), dimension(6,6), save :: rvec, lvec
|
|
|
|
|
!$omp threadprivate(first, ivs, rvec, lvec)
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-26 13:10:55 -03:00
|
|
|
|
if (first) then
|
|
|
|
|
|
|
|
|
|
rvec(:,:) = 0.0d+00
|
|
|
|
|
lvec(:,:) = 0.0d+00
|
|
|
|
|
|
|
|
|
|
ivs = [ idn, imx, imy, imz, iby, ibz ]
|
|
|
|
|
|
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-26 13:10:55 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl)
|
|
|
|
|
call fluxspeed(qr, ur, fr)
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sdl = sqrt(ql(idn,i))
|
|
|
|
|
sdr = sqrt(qr(idn,i))
|
|
|
|
|
sds = sdl + sdr
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
qi(idn) = sdl * sdr
|
2022-01-26 13:10:55 -03:00
|
|
|
|
qi(ivx:ivz) = (sdl * ql(ivx:ivz,i) + sdr * qr(ivx:ivz,i)) / sds
|
|
|
|
|
qi(iby:ibz) = (sdr * ql(iby:ibz,i) + sdl * qr(iby:ibz,i)) / sds
|
2022-01-19 11:53:56 -03:00
|
|
|
|
qi(ibx) = ql(ibx,i)
|
|
|
|
|
qi(ibp) = ql(ibp,i)
|
2014-03-06 13:55:09 -03:00
|
|
|
|
|
2022-01-26 13:10:55 -03:00
|
|
|
|
f1 = ql(iby,i) - qr(iby,i)
|
|
|
|
|
f2 = ql(ibz,i) - qr(ibz,i)
|
|
|
|
|
xx = 5.0d-01 * (f1 * f1 + f2 * f2) / (sds * sds)
|
|
|
|
|
yy = 5.0d-01 * (ql(idn,i) + qr(idn,i)) / qi(idn)
|
2020-02-22 06:45:14 +07:00
|
|
|
|
|
2022-01-26 13:10:55 -03:00
|
|
|
|
br2 = qi(iby) * qi(iby) + qi(ibz) * qi(ibz)
|
|
|
|
|
br = sqrt(br2)
|
|
|
|
|
if (br2 > 0.0d+00) then
|
|
|
|
|
bty = qi(iby) / br
|
|
|
|
|
btz = qi(ibz) / br
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else
|
2022-01-26 13:10:55 -03:00
|
|
|
|
bty = 0.0d+00
|
|
|
|
|
btz = 0.0d+00
|
|
|
|
|
end if
|
2020-02-22 06:45:14 +07:00
|
|
|
|
|
2022-01-26 13:10:55 -03:00
|
|
|
|
cc2 = csnd2 + xx
|
2022-01-28 12:58:31 -03:00
|
|
|
|
ca2 = qi(ibx) * qi(ibx) / qi(idn)
|
|
|
|
|
f1 = br2 / qi(idn)
|
|
|
|
|
f2 = ca2 + f1
|
|
|
|
|
f3 = f2 - cc2
|
|
|
|
|
f4 = sqrt(f3 * f3 + 4.0d+00 * cc2 * f1)
|
|
|
|
|
cf2 = 5.0d-01 * (f2 + cc2 + f4)
|
|
|
|
|
cs2 = cc2 * ca2 / cf2
|
2020-02-22 06:18:02 +07:00
|
|
|
|
|
2022-01-29 18:24:33 -03:00
|
|
|
|
if (cs2 < cc2 .and. cc2 < cf2) then
|
|
|
|
|
f1 = (cc2 - cs2) / (cf2 - cs2)
|
|
|
|
|
alf = sqrt(f1)
|
|
|
|
|
als = sqrt(1.0d+00 - f1)
|
|
|
|
|
else if (cc2 >= cf2) then
|
2022-01-26 13:10:55 -03:00
|
|
|
|
alf = 1.0d+00
|
2022-01-29 18:24:33 -03:00
|
|
|
|
als = 0.0d+00
|
|
|
|
|
else
|
|
|
|
|
alf = 0.0d+00
|
2022-01-26 13:10:55 -03:00
|
|
|
|
als = 1.0d+00
|
|
|
|
|
end if
|
2020-02-22 06:18:02 +07:00
|
|
|
|
|
2022-01-26 13:10:55 -03:00
|
|
|
|
cc = sqrt(cc2)
|
|
|
|
|
ca = sqrt(ca2)
|
|
|
|
|
cf = sign(sqrt(cf2), qi(ivx))
|
|
|
|
|
cs = sign(sqrt(cs2), qi(ivx))
|
|
|
|
|
|
|
|
|
|
lm(1) = qi(ivx) + cf
|
|
|
|
|
lm(2) = qi(ivx) + ca
|
|
|
|
|
lm(3) = qi(ivx) + cs
|
|
|
|
|
lm(4) = qi(ivx) - cs
|
|
|
|
|
lm(5) = qi(ivx) - ca
|
|
|
|
|
lm(6) = qi(ivx) - cf
|
|
|
|
|
|
|
|
|
|
sqrtd = sqrt(qi(idn))
|
|
|
|
|
f1 = sqrt(yy)
|
|
|
|
|
qf = cf * sign(alf, qi(ibx)) / f1
|
|
|
|
|
qs = cs * sign(als, qi(ibx)) / f1
|
|
|
|
|
f1 = cc / (f1 * sqrtd)
|
|
|
|
|
af_prime = alf * f1
|
|
|
|
|
as_prime = als * f1
|
|
|
|
|
|
|
|
|
|
rvec(1,1) = alf
|
|
|
|
|
rvec(1,2) = alf * lm(1)
|
|
|
|
|
rvec(1,3) = alf * qi(ivy) - qs * bty
|
|
|
|
|
rvec(1,4) = alf * qi(ivz) - qs * btz
|
|
|
|
|
rvec(1,5) = as_prime * bty
|
|
|
|
|
rvec(1,6) = as_prime * btz
|
|
|
|
|
|
|
|
|
|
rvec(6,1) = alf
|
|
|
|
|
rvec(6,2) = alf * lm(6)
|
|
|
|
|
rvec(6,3) = alf * qi(ivy) + qs * bty
|
|
|
|
|
rvec(6,4) = alf * qi(ivz) + qs * btz
|
|
|
|
|
rvec(6,5) = rvec(1,5)
|
|
|
|
|
rvec(6,6) = rvec(1,6)
|
|
|
|
|
|
|
|
|
|
rvec(3,1) = als
|
|
|
|
|
rvec(3,2) = als * lm(3)
|
|
|
|
|
rvec(3,3) = als * qi(ivy) + qf * bty
|
|
|
|
|
rvec(3,4) = als * qi(ivz) + qf * btz
|
|
|
|
|
rvec(3,5) = - af_prime * bty
|
|
|
|
|
rvec(3,6) = - af_prime * btz
|
|
|
|
|
|
|
|
|
|
rvec(4,1) = als
|
|
|
|
|
rvec(4,2) = als * lm(4)
|
|
|
|
|
rvec(4,3) = als * qi(ivy) - qf * bty
|
|
|
|
|
rvec(4,4) = als * qi(ivz) - qf * btz
|
|
|
|
|
rvec(4,5) = rvec(3,5)
|
|
|
|
|
rvec(4,6) = rvec(3,6)
|
|
|
|
|
|
|
|
|
|
f1 = sign(1.0d+00 / sqrtd, qi(ibx))
|
|
|
|
|
rvec(2,3) = btz
|
|
|
|
|
rvec(2,4) = - bty
|
|
|
|
|
rvec(2,5) = - btz * f1
|
|
|
|
|
rvec(2,6) = bty * f1
|
|
|
|
|
|
|
|
|
|
rvec(5,3) = - rvec(2,3)
|
|
|
|
|
rvec(5,4) = - rvec(2,4)
|
|
|
|
|
rvec(5,5) = rvec(2,5)
|
|
|
|
|
rvec(5,6) = rvec(2,6)
|
|
|
|
|
|
|
|
|
|
norm = 2.0d+00 * cc2
|
|
|
|
|
cff = alf * cf / norm
|
|
|
|
|
css = als * cs / norm
|
|
|
|
|
norm = norm / yy
|
|
|
|
|
qf = qf / norm
|
|
|
|
|
qs = qs / norm
|
|
|
|
|
f1 = qi(idn) / norm
|
|
|
|
|
af = af_prime * f1
|
|
|
|
|
as = as_prime * f1
|
|
|
|
|
f1 = br / norm
|
|
|
|
|
afpb = af_prime * f1
|
|
|
|
|
aspb = as_prime * f1
|
|
|
|
|
vqstr = (qi(ivy) * bty + qi(ivz) * btz)
|
|
|
|
|
|
|
|
|
|
f1 = qs * vqstr
|
|
|
|
|
lvec(1,1) = - cff * lm(6) + f1 - aspb
|
|
|
|
|
lvec(1,2) = cff
|
|
|
|
|
lvec(1,3) = - qs * bty
|
|
|
|
|
lvec(1,4) = - qs * btz
|
|
|
|
|
lvec(1,5) = as * bty
|
|
|
|
|
lvec(1,6) = as * btz
|
|
|
|
|
|
|
|
|
|
lvec(6,1) = cff * lm(1) - f1 - aspb
|
|
|
|
|
lvec(6,2) = - lvec(1,2)
|
|
|
|
|
lvec(6,3) = - lvec(1,3)
|
|
|
|
|
lvec(6,4) = - lvec(1,4)
|
|
|
|
|
lvec(6,5) = lvec(1,5)
|
|
|
|
|
lvec(6,6) = lvec(1,6)
|
|
|
|
|
|
|
|
|
|
f1 = qf * vqstr
|
|
|
|
|
lvec(3,1) = - css * lm(4) - f1 + afpb
|
|
|
|
|
lvec(3,2) = css
|
|
|
|
|
lvec(3,3) = qf * bty
|
|
|
|
|
lvec(3,4) = qf * btz
|
|
|
|
|
lvec(3,5) = - af * bty
|
|
|
|
|
lvec(3,6) = - af * btz
|
|
|
|
|
|
|
|
|
|
lvec(4,1) = css * lm(3) + f1 + afpb
|
|
|
|
|
lvec(4,2) = - lvec(3,2)
|
|
|
|
|
lvec(4,3) = - lvec(3,3)
|
|
|
|
|
lvec(4,4) = - lvec(3,4)
|
|
|
|
|
lvec(4,5) = lvec(3,5)
|
|
|
|
|
lvec(4,6) = lvec(3,6)
|
|
|
|
|
|
|
|
|
|
f1 = sign(5.0d-01 * sqrtd, qi(ibx))
|
|
|
|
|
lvec(2,1) = - 5.0d-01 * (qi(ivy) * btz - qi(ivz) * bty)
|
|
|
|
|
lvec(2,3) = 5.0d-01 * btz
|
|
|
|
|
lvec(2,4) = - 5.0d-01 * bty
|
|
|
|
|
lvec(2,5) = - f1 * btz
|
|
|
|
|
lvec(2,6) = f1 * bty
|
|
|
|
|
|
|
|
|
|
lvec(5,1) = - lvec(2,1)
|
|
|
|
|
lvec(5,3) = - lvec(2,3)
|
|
|
|
|
lvec(5,4) = - lvec(2,4)
|
|
|
|
|
lvec(5,5) = lvec(2,5)
|
|
|
|
|
lvec(5,6) = lvec(2,6)
|
|
|
|
|
|
|
|
|
|
al = abs(lm) * matmul(lvec, ur(ivs,i) - ul(ivs,i))
|
|
|
|
|
df = matmul(al, rvec)
|
|
|
|
|
fi(ivs,i) = 5.0d-01 * ((fl(ivs,i) + fr(ivs,i)) - df(:))
|
|
|
|
|
fi(ibx,i) = fl(ibx,i)
|
|
|
|
|
fi(ibp,i) = fl(ibp,i)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2020-02-22 07:06:22 +07:00
|
|
|
|
end do
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-02-22 06:18:02 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_mhd_iso_roe
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_MHD_ISO_KEPES:
|
|
|
|
|
! --------------------------------
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional isothermal magnetohydrodynamic
|
|
|
|
|
! Riemann problem using the entropy stable KEPES method. The method is
|
|
|
|
|
! a modification of the method described in [1] for the isothermal equation
|
|
|
|
|
! of state.
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Derigs, D., Winters, A. R., Gassner, G. J., Walch, S., Bohm, M.,
|
|
|
|
|
! "Ideal GLM-MHD: About the entropy consistent nine-wave magnetic
|
|
|
|
|
! field divergence diminishing ideal magnetohydrodynamics equations",
|
|
|
|
|
! Journal of Computational Physics, 2018, 364, pp. 420-467,
|
|
|
|
|
! https://doi.org/10.1016/j.jcp.2018.03.002
|
2022-01-21 23:31:54 -03:00
|
|
|
|
! [2] Winters, A. R., Czernik, C., Schily, M. B., Gassner, G. J.,
|
|
|
|
|
! "Entropy stable numerical approximations for the isothermal and
|
|
|
|
|
! polytropic Euler equations",
|
|
|
|
|
! BIT Numerical Mathematics (2020) 60:791–824,
|
|
|
|
|
! https://doi.org/10.1007/s10543-019-00789-w
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_iso_kepes(ql, qr, fi)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, csnd, csnd2, ch => cglm
|
|
|
|
|
use equations , only : idn, imx, imy, imz, ivx, ivy, ivz, &
|
|
|
|
|
ibx, iby, ibz, ibp
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2020-02-21 20:39:50 +07:00
|
|
|
|
implicit none
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2014-08-04 15:53:36 -03:00
|
|
|
|
|
2022-01-21 23:31:54 -03:00
|
|
|
|
integer :: i
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8) :: dna, pta, vxa, vya, vza, bxa, bya, bza, bpa
|
2022-01-21 23:31:54 -03:00
|
|
|
|
real(kind=8) :: dnl, v2l, v2r, b2l, b2r, bp2, das, daf, csq
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8) :: ca, cs, cf, ca2, cs2, cf2, x2, x3
|
2022-01-28 11:59:55 -03:00
|
|
|
|
real(kind=8) :: alf, als, f1, f2, f3, f4
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-21 23:31:54 -03:00
|
|
|
|
real(kind=8), dimension(nf) :: v, lm, tm
|
|
|
|
|
|
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
real(kind=8), dimension(8,8), save :: rm
|
|
|
|
|
!$omp threadprivate(first, rm)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-02-22 06:45:14 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (first) then
|
|
|
|
|
rm(:,:) = 0.0d+00
|
|
|
|
|
rm(5,4) = 1.0d+00
|
|
|
|
|
rm(8,4) = 1.0d+00
|
|
|
|
|
rm(5,5) = 1.0d+00
|
|
|
|
|
rm(8,5) = - 1.0d+00
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2020-02-22 06:45:14 +07:00
|
|
|
|
|
2022-01-21 23:31:54 -03:00
|
|
|
|
v2l = sum(ql(ivx:ivz,i) * ql(ivx:ivz,i))
|
|
|
|
|
v2r = sum(qr(ivx:ivz,i) * qr(ivx:ivz,i))
|
|
|
|
|
b2l = sum(ql(ibx:ibz,i) * ql(ibx:ibz,i))
|
|
|
|
|
b2r = sum(qr(ibx:ibz,i) * qr(ibx:ibz,i))
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-21 23:31:54 -03:00
|
|
|
|
dnl = lmean(ql(idn,i), qr(idn,i))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dna = amean(ql(idn,i), qr(idn,i))
|
|
|
|
|
vxa = amean(ql(ivx,i), qr(ivx,i))
|
|
|
|
|
vya = amean(ql(ivy,i), qr(ivy,i))
|
|
|
|
|
vza = amean(ql(ivz,i), qr(ivz,i))
|
|
|
|
|
bxa = amean(ql(ibx,i), qr(ibx,i))
|
|
|
|
|
bya = amean(ql(iby,i), qr(iby,i))
|
|
|
|
|
bza = amean(ql(ibz,i), qr(ibz,i))
|
|
|
|
|
bpa = amean(ql(ibp,i), qr(ibp,i))
|
2022-01-21 23:31:54 -03:00
|
|
|
|
pta = 5.0d-01 * amean(b2l, b2r) + csnd2 * dna
|
|
|
|
|
|
|
|
|
|
v(idn) = 5.0d-01 * (v2l - v2r)
|
|
|
|
|
if (qr(idn,i) > ql(idn,i)) then
|
|
|
|
|
v(idn) = v(idn) + csnd2 * log(qr(idn,i) / ql(idn,i))
|
|
|
|
|
else if (ql(idn,i) > qr(idn,i)) then
|
|
|
|
|
v(idn) = v(idn) - csnd2 * log(ql(idn,i) / qr(idn,i))
|
|
|
|
|
end if
|
|
|
|
|
v(ivx) = qr(ivx,i) - ql(ivx,i)
|
|
|
|
|
v(ivy) = qr(ivy,i) - ql(ivy,i)
|
|
|
|
|
v(ivz) = qr(ivz,i) - ql(ivz,i)
|
|
|
|
|
v(ibx) = qr(ibx,i) - ql(ibx,i)
|
|
|
|
|
v(iby) = qr(iby,i) - ql(iby,i)
|
|
|
|
|
v(ibz) = qr(ibz,i) - ql(ibz,i)
|
|
|
|
|
v(ibp) = qr(ibp,i) - ql(ibp,i)
|
|
|
|
|
|
|
|
|
|
bp2 = bya * bya + bza * bza
|
|
|
|
|
if (bp2 > 0.0d+00) then
|
|
|
|
|
f1 = sqrt(bp2)
|
|
|
|
|
x2 = bya / f1
|
|
|
|
|
x3 = bza / f1
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else
|
|
|
|
|
x2 = 0.0d+00
|
|
|
|
|
x3 = 0.0d+00
|
|
|
|
|
end if
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-28 11:59:55 -03:00
|
|
|
|
ca2 = bxa * bxa / dnl
|
|
|
|
|
f1 = bp2 / dnl
|
|
|
|
|
f2 = ca2 + f1
|
|
|
|
|
f3 = f2 - csnd2
|
|
|
|
|
f4 = sqrt(f3 * f3 + 4.0d+00 * csnd2 * f1)
|
|
|
|
|
cf2 = 5.0d-01 * (f2 + csnd2 + f4)
|
|
|
|
|
cs2 = csnd2 * ca2 / cf2
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-29 18:24:33 -03:00
|
|
|
|
if (cs2 < csnd2 .and. csnd2 < cf2) then
|
|
|
|
|
f1 = (csnd2 - cs2) / (cf2 - cs2)
|
|
|
|
|
alf = sqrt(f1)
|
|
|
|
|
als = sqrt(1.0d+00 - f1)
|
|
|
|
|
else if (csnd2 >= cf2) then
|
2022-01-21 23:31:54 -03:00
|
|
|
|
alf = 1.0d+00
|
2022-01-29 18:24:33 -03:00
|
|
|
|
als = 0.0d+00
|
|
|
|
|
else
|
|
|
|
|
alf = 0.0d+00
|
2022-01-21 23:31:54 -03:00
|
|
|
|
als = 1.0d+00
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
cf = sign(sqrt(cf2), vxa)
|
|
|
|
|
ca = sqrt(ca2)
|
|
|
|
|
cs = sign(sqrt(cs2), vxa)
|
|
|
|
|
|
|
|
|
|
lm(1) = vxa + cf
|
|
|
|
|
lm(2) = vxa + ca
|
|
|
|
|
lm(3) = vxa + cs
|
|
|
|
|
lm(4) = vxa + ch
|
|
|
|
|
lm(5) = vxa - ch
|
|
|
|
|
lm(6) = vxa - cs
|
|
|
|
|
lm(7) = vxa - ca
|
|
|
|
|
lm(8) = vxa - cf
|
|
|
|
|
|
|
|
|
|
tm(1) = 5.0d-01 / (dnl * csnd2)
|
|
|
|
|
tm(2) = 5.0d-01 / dnl**2
|
|
|
|
|
tm(3) = tm(1)
|
|
|
|
|
tm(4) = 5.0d-01
|
|
|
|
|
tm(5) = tm(4)
|
|
|
|
|
tm(6) = tm(1)
|
|
|
|
|
tm(7) = tm(2)
|
|
|
|
|
tm(8) = tm(1)
|
|
|
|
|
|
|
|
|
|
das = dnl * als
|
|
|
|
|
daf = dnl * alf
|
|
|
|
|
csq = csnd * sqrt(dnl)
|
|
|
|
|
|
|
|
|
|
f1 = daf
|
|
|
|
|
f2 = sign(das, bxa) * cs
|
|
|
|
|
f3 = als * csq
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,1) = f1
|
|
|
|
|
rm(2,1) = f1 * (vxa + cf)
|
|
|
|
|
rm(3,1) = f1 * vya - f2 * x2
|
|
|
|
|
rm(4,1) = f1 * vza - f2 * x3
|
|
|
|
|
rm(6,1) = f3 * x2
|
|
|
|
|
rm(7,1) = f3 * x3
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,8) = f1
|
|
|
|
|
rm(2,8) = f1 * (vxa - cf)
|
|
|
|
|
rm(3,8) = f1 * vya + f2 * x2
|
|
|
|
|
rm(4,8) = f1 * vza + f2 * x3
|
|
|
|
|
rm(6,8) = rm(6,1)
|
|
|
|
|
rm(7,8) = rm(7,1)
|
2017-04-07 08:34:44 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
f1 = dnl * sqrt(dna)
|
|
|
|
|
rm(3,2) = f1 * x3
|
|
|
|
|
rm(4,2) = - f1 * x2
|
|
|
|
|
rm(6,2) = - dnl * x3
|
|
|
|
|
rm(7,2) = dnl * x2
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,7) = - rm(3,2)
|
|
|
|
|
rm(4,7) = - rm(4,2)
|
|
|
|
|
rm(6,7) = rm(6,2)
|
|
|
|
|
rm(7,7) = rm(7,2)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-21 23:31:54 -03:00
|
|
|
|
f1 = das
|
|
|
|
|
f2 = sign(daf, bxa) * cf
|
|
|
|
|
f3 = - alf * csq
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,3) = f1
|
|
|
|
|
rm(2,3) = f1 * (vxa + cs)
|
|
|
|
|
rm(3,3) = f1 * vya + f2 * x2
|
|
|
|
|
rm(4,3) = f1 * vza + f2 * x3
|
|
|
|
|
rm(6,3) = f3 * x2
|
|
|
|
|
rm(7,3) = f3 * x3
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,6) = f1
|
|
|
|
|
rm(2,6) = f1 * (vxa - cs)
|
|
|
|
|
rm(3,6) = f1 * vya - f2 * x2
|
|
|
|
|
rm(4,6) = f1 * vza - f2 * x3
|
|
|
|
|
rm(6,6) = rm(6,3)
|
|
|
|
|
rm(7,6) = rm(7,3)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(idn,i) = dnl * vxa
|
|
|
|
|
fi(imx,i) = fi(idn,i) * vxa - bxa * bxa + pta
|
|
|
|
|
fi(imy,i) = fi(idn,i) * vya - bxa * bya
|
|
|
|
|
fi(imz,i) = fi(idn,i) * vza - bxa * bza
|
|
|
|
|
fi(ibx,i) = ch * bpa
|
|
|
|
|
fi(iby,i) = vxa * bya - bxa * vya
|
|
|
|
|
fi(ibz,i) = vxa * bza - bxa * vza
|
|
|
|
|
fi(ibp,i) = ch * bxa
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-21 23:31:54 -03:00
|
|
|
|
fi(:,i) = fi(:,i) - 5.0d-01 * matmul(rm, (abs(lm) * tm) * matmul(v, rm))
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end do
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-08-20 17:39:03 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_mhd_iso_kepes
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!*******************************************************************************
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ADIABATIC MAGNETOHYDRODYNAMIC RIEMANN SOLVERS
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!*******************************************************************************
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!===============================================================================
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_MHD_HLLC:
|
|
|
|
|
! ---------------------------
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using the HLLC method,
|
|
|
|
|
! by Toro. In the HLLC method the tangential components of the velocity are
|
|
|
|
|
! discontinuous actoss the contact dicontinuity.
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Arguments:
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Toro, E. F., Spruce, M., & Speares, W.
|
|
|
|
|
! "Restoration of the contact surface in the HLL-Riemann solver",
|
|
|
|
|
! Shock Waves, 1994, Volume 4, Issue 1, pp. 25-34
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_hllc(ql, qr, fi)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, idn, ivy, ivz, imx, imy, imz, ien, &
|
|
|
|
|
ibx, iby, ibz, ibp
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
implicit none
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: dn, pt, vy, vz, bx, by, bz, vb, b2
|
|
|
|
|
real(kind=8) :: sl, sr, sm, srml, slmm, srmm
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr, ui
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sl >= 0.0d+00) then
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i)
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sr <= 0.0d+00) then
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i)
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl < 0 < sr
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
bx = ql(ibx,i)
|
|
|
|
|
b2 = ql(ibx,i) * qr(ibx,i)
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
srml = sr - sl
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wl(:) = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr(:) = sr * ur(:,i) - fr(:,i)
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dn = wr(idn) - wl(idn)
|
|
|
|
|
sm = (wr(imx) - wl(imx)) / dn
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
pt = (wl(idn) * wr(imx) - wr(idn) * wl(imx)) / dn + b2
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (b2 > 0.0d+00) then
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = (wr(imy) - wl(imy)) / dn
|
|
|
|
|
vz = (wr(imz) - wl(imz)) / dn
|
|
|
|
|
by = (wr(iby) - wl(iby)) / srml
|
|
|
|
|
bz = (wr(ibz) - wl(ibz)) / srml
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sm > 0.0d+00) then ! sm > 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
slmm = sl - sm
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = wl(idn) / slmm
|
|
|
|
|
ui(imx) = ui(idn) * sm
|
|
|
|
|
ui(imy) = ui(idn) * vy
|
|
|
|
|
ui(imz) = ui(idn) * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ql(ibp,i)
|
2020-08-20 17:39:03 -03:00
|
|
|
|
ui(ien) = (wl(ien) + sm * pt - bx * vb) / slmm
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sl * ui(:) - wl(:)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sm < 0.0d+00) then ! sm < 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
srmm = sr - sm
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = wr(idn) / srmm
|
|
|
|
|
ui(imx) = ui(idn) * sm
|
|
|
|
|
ui(imy) = ui(idn) * vy
|
|
|
|
|
ui(imz) = ui(idn) * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = qr(ibp,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pt - bx * vb) / srmm
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * ui(:) - wr(:)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sm = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! when Sₘ = 0 all variables are continuous, therefore the flux reduces
|
|
|
|
|
! to the HLL one
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sm = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Bₓ = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sm > 0.0d+00) then ! sm > 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
slmm = sl - sm
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = wl(idn) / slmm
|
|
|
|
|
ui(imx) = ui(idn) * sm
|
|
|
|
|
ui(imy) = ui(idn) * ql(ivy,i)
|
|
|
|
|
ui(imz) = ui(idn) * ql(ivz,i)
|
|
|
|
|
ui(ibx) = 0.0d+00
|
|
|
|
|
ui(iby) = wl(iby) / slmm
|
|
|
|
|
ui(ibz) = wl(ibz) / slmm
|
|
|
|
|
ui(ibp) = ql(ibp,i)
|
|
|
|
|
ui(ien) = (wl(ien) + sm * pt) / slmm
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sl * ui(:) - wl(:)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sm < 0.0d+00) then ! sm < 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
srmm = sr - sm
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = wr(idn) / srmm
|
|
|
|
|
ui(imx) = ui(idn) * sm
|
|
|
|
|
ui(imy) = ui(idn) * qr(ivy,i)
|
|
|
|
|
ui(imz) = ui(idn) * qr(ivz,i)
|
|
|
|
|
ui(ibx) = 0.0d+00
|
|
|
|
|
ui(iby) = wr(iby) / srmm
|
|
|
|
|
ui(ibz) = wr(ibz) / srmm
|
|
|
|
|
ui(ibp) = qr(ibp,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pt) / srmm
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * ui(:) - wr(:)
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sm = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! when Sₘ = 0 all variables are continuous, therefore the flux reduces
|
|
|
|
|
! to the HLL one
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sm = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! Bₓ = 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl < 0 < sr
|
2020-08-20 17:39:03 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end do
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-08-20 17:39:03 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_mhd_hllc
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!===============================================================================
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_ADI_MHD_HLLD:
|
|
|
|
|
! -------------------------------
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using the adiabatic HLLD
|
|
|
|
|
! method described by Miyoshi & Kusano.
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Miyoshi, T. & Kusano, K.,
|
|
|
|
|
! "A multi-state HLL approximate Riemann solver for ideal
|
|
|
|
|
! magnetohydrodynamics",
|
|
|
|
|
! Journal of Computational Physics, 2005, 208, pp. 315-344
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_adi_hlld(ql, qr, fi)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, idn, imx, imy, imz, ien, ibx, iby, ibz, ibp
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
implicit none
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
integer :: i
|
|
|
|
|
real(kind=8) :: sl, sr, sm, srml, slmm, srmm
|
|
|
|
|
real(kind=8) :: dn, bx, b2, pt, vy, vz, by, bz, vb
|
|
|
|
|
real(kind=8) :: dnl, dnr, cal, car, sml, smr
|
|
|
|
|
real(kind=8) :: dv, dvl, dvr
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr, wcl, wcr, ui
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sl >= 0.0d+00) then ! sl ≥ 0
|
2020-02-22 07:06:22 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sr <= 0.0d+00) then ! sr ≤ 0
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl < 0 < sr
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
bx = ql(ibx,i)
|
|
|
|
|
b2 = ql(ibx,i) * qr(ibx,i)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
srml = sr - sl
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wl(:) = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr(:) = sr * ur(:,i) - fr(:,i)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dn = wr(idn) - wl(idn)
|
|
|
|
|
sm = (wr(imx) - wl(imx)) / dn
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
slmm = sl - sm
|
|
|
|
|
srmm = sr - sm
|
2021-11-24 13:22:27 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dnl = wl(idn) / slmm
|
|
|
|
|
dnr = wr(idn) / srmm
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
pt = (wl(idn) * wr(imx) - wr(idn) * wl(imx)) / dn + b2
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
cal = abs(bx) / sqrt(dnl)
|
|
|
|
|
car = abs(bx) / sqrt(dnr)
|
|
|
|
|
sml = sm - cal
|
|
|
|
|
smr = sm + car
|
2017-04-07 08:34:44 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate division factors (also used to determine degeneracies)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dvl = slmm * wl(idn) - b2
|
|
|
|
|
dvr = srmm * wr(idn) - b2
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! check degeneracy Sl* -> Sl or Sr* -> Sr
|
2020-02-22 06:45:14 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > sl .and. smr < sr .and. min(dvl, dvr) > 0.0d+00) then ! no degeneracy
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! choose the correct state depending on the speed signs
|
2013-12-12 16:38:25 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > 0.0d+00) then ! sl* > 0
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! primitive variables for the outer left intermediate state
|
|
|
|
|
!
|
|
|
|
|
vy = ( slmm * wl(imy) - bx * wl(iby)) / dvl
|
|
|
|
|
vz = ( slmm * wl(imz) - bx * wl(ibz)) / dvl
|
|
|
|
|
by = (wl(idn) * wl(iby) - bx * wl(imy)) / dvl
|
|
|
|
|
bz = (wl(idn) * wl(ibz) - bx * wl(imz)) / dvl
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the outer left intermediate state
|
|
|
|
|
!
|
|
|
|
|
ui(idn) = dnl
|
|
|
|
|
ui(imx) = dnl * sm
|
|
|
|
|
ui(imy) = dnl * vy
|
|
|
|
|
ui(imz) = dnl * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ul(ibp,i)
|
|
|
|
|
ui(ien) = (wl(ien) + sm * pt - bx * vb) / slmm
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the outer left intermediate flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = sl * ui(:) - wl(:)
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (smr < 0.0d+00) then ! sr* < 0
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! primitive variables for the outer right intermediate state
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = ( srmm * wr(imy) - bx * wr(iby)) / dvr
|
|
|
|
|
vz = ( srmm * wr(imz) - bx * wr(ibz)) / dvr
|
|
|
|
|
by = (wr(idn) * wr(iby) - bx * wr(imy)) / dvr
|
|
|
|
|
bz = (wr(idn) * wr(ibz) - bx * wr(imz)) / dvr
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the outer right intermediate state
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnr
|
|
|
|
|
ui(imx) = dnr * sm
|
|
|
|
|
ui(imy) = dnr * vy
|
|
|
|
|
ui(imz) = dnr * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ur(ibp,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pt - bx * vb) / srmm
|
2013-12-12 16:38:25 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the outer right intermediate flux
|
2017-04-10 08:03:50 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * ui(:) - wr(:)
|
2017-04-10 08:03:50 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl* < 0 < sr*
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! separate cases with non-zero and zero Bx
|
2013-12-12 16:38:25 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (b2 > 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
! primitive variables for the outer left intermediate state
|
2020-02-22 09:47:13 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = ( slmm * wl(imy) - bx * wl(iby)) / dvl
|
|
|
|
|
vz = ( slmm * wl(imz) - bx * wl(ibz)) / dvl
|
|
|
|
|
by = (wl(idn) * wl(iby) - bx * wl(imy)) / dvl
|
|
|
|
|
bz = (wl(idn) * wl(ibz) - bx * wl(imz)) / dvl
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
|
|
|
|
|
|
|
|
|
! conservative variables for the outer left intermediate state
|
2020-02-22 09:47:13 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnl
|
|
|
|
|
ui(imx) = dnl * sm
|
|
|
|
|
ui(imy) = dnl * vy
|
|
|
|
|
ui(imz) = dnl * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ul(ibp,i)
|
|
|
|
|
ui(ien) = (wl(ien) + sm * pt - bx * vb) / slmm
|
|
|
|
|
|
|
|
|
|
! vector of the left-going Alfvén wave
|
2014-03-06 14:19:31 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcl(:) = (sml - sl) * ui(:) + wl(:)
|
|
|
|
|
|
|
|
|
|
! primitive variables for the outer right intermediate state
|
2014-03-06 14:19:31 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = ( srmm * wr(imy) - bx * wr(iby)) / dvr
|
|
|
|
|
vz = ( srmm * wr(imz) - bx * wr(ibz)) / dvr
|
|
|
|
|
by = (wr(idn) * wr(iby) - bx * wr(imy)) / dvr
|
|
|
|
|
bz = (wr(idn) * wr(ibz) - bx * wr(imz)) / dvr
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
|
|
|
|
|
|
|
|
|
! conservative variables for the outer right intermediate state
|
2014-03-06 14:19:31 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnr
|
|
|
|
|
ui(imx) = dnr * sm
|
|
|
|
|
ui(imy) = dnr * vy
|
|
|
|
|
ui(imz) = dnr * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ur(ibp,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pt - bx * vb) / srmm
|
|
|
|
|
|
|
|
|
|
! vector of the right-going Alfvén wave
|
2020-02-22 06:45:14 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcr(:) = (smr - sr) * ui(:) + wr(:)
|
|
|
|
|
|
|
|
|
|
! prepare constant primitive variables of the intermediate states
|
2020-02-22 06:45:14 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dv = abs(bx) * (sqrt(dnr) + sqrt(dnl))
|
|
|
|
|
vy = (wcr(imy) - wcl(imy)) / dv
|
|
|
|
|
vz = (wcr(imz) - wcl(imz)) / dv
|
|
|
|
|
dv = car + cal
|
|
|
|
|
by = (wcr(iby) - wcl(iby)) / dv
|
|
|
|
|
bz = (wcr(ibz) - wcl(ibz)) / dv
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
|
|
|
|
|
|
|
|
|
! choose the correct state depending on the sign of contact discontinuity
|
|
|
|
|
! advection speed
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sm > 0.0d+00) then ! sm > 0
|
|
|
|
|
|
|
|
|
|
! conservative variables for the inmost left intermediate state
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnl
|
|
|
|
|
ui(imx) = dnl * sm
|
|
|
|
|
ui(imy) = dnl * vy
|
|
|
|
|
ui(imz) = dnl * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ul(ibp,i)
|
|
|
|
|
ui(ien) = - (wcl(ien) + sm * pt - bx * vb) / cal
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the inmost left intermediate flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = sml * ui(:) - wcl(:)
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sm < 0.0d+00) then ! sm < 0
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the inmost right intermediate state
|
|
|
|
|
!
|
|
|
|
|
ui(idn) = dnr
|
|
|
|
|
ui(imx) = dnr * sm
|
|
|
|
|
ui(imy) = dnr * vy
|
|
|
|
|
ui(imz) = dnr * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ur(ibp,i)
|
|
|
|
|
ui(ien) = (wcr(ien) + sm * pt - bx * vb) / car
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the inmost right intermediate flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = smr * ui(:) - wcr(:)
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sm = 0
|
2021-11-24 13:22:27 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! in the case when Sₘ = 0 and Bₓ² > 0, all variables are continuous, therefore
|
|
|
|
|
! the flux can be averaged from the Alfvén waves using a simple HLL formula;
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sml * wcr(:) - smr * wcl(:)) / dv
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sm = 0
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Bx = 0
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sm > 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
! primitive variables for the outer left intermediate state
|
2020-02-21 20:39:50 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = slmm * wl(imy) / dvl
|
|
|
|
|
vz = slmm * wl(imz) / dvl
|
|
|
|
|
by = wl(idn) * wl(iby) / dvl
|
|
|
|
|
bz = wl(idn) * wl(ibz) / dvl
|
|
|
|
|
vb = vy * by + vz * bz
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the outer left intermediate state
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnl
|
|
|
|
|
ui(imx) = dnl * sm
|
|
|
|
|
ui(imy) = dnl * vy
|
|
|
|
|
ui(imz) = dnl * vz
|
|
|
|
|
ui(ibx) = 0.0d+00
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ul(ibp,i)
|
|
|
|
|
ui(ien) = (wl(ien) + sm * pt) / slmm
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the outer left intermediate flux
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sl * ui(:) - wl(:)
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sm < 0.0d+00) then
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! primitive variables for the outer right intermediate state
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = ( srmm * wr(imy)) / dvr
|
|
|
|
|
vz = ( srmm * wr(imz)) / dvr
|
|
|
|
|
by = (wr(idn) * wr(iby)) / dvr
|
|
|
|
|
bz = (wr(idn) * wr(ibz)) / dvr
|
|
|
|
|
vb = vy * by + vz * bz
|
2015-02-06 09:09:22 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the outer right intermediate state
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnr
|
|
|
|
|
ui(imx) = dnr * sm
|
|
|
|
|
ui(imy) = dnr * vy
|
|
|
|
|
ui(imz) = dnr * vz
|
|
|
|
|
ui(ibx) = 0.0d+00
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ur(ibp,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pt) / srmm
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the outer right intermediate flux
|
2015-02-06 09:09:22 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * ui(:) - wr(:)
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Sm = 0
|
2020-02-21 20:39:50 +07:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! since Bx = 0 and Sm = 0, then revert to the HLL flux
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! Bx = 0
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl* < 0 < sr*
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! some degeneracies
|
2021-11-24 13:22:27 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! separate degeneracies
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > sl .and. dvl > 0.0d+00) then ! sr* > sr
|
|
|
|
|
|
|
|
|
|
! primitive variables for the outer left intermediate state
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = ( slmm * wl(imy) - bx * wl(iby)) / dvl
|
|
|
|
|
vz = ( slmm * wl(imz) - bx * wl(ibz)) / dvl
|
|
|
|
|
by = (wl(idn) * wl(iby) - bx * wl(imy)) / dvl
|
|
|
|
|
bz = (wl(idn) * wl(ibz) - bx * wl(imz)) / dvl
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the outer left intermediate state
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnl
|
|
|
|
|
ui(imx) = dnl * sm
|
|
|
|
|
ui(imy) = dnl * vy
|
|
|
|
|
ui(imz) = dnl * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ul(ibp,i)
|
|
|
|
|
ui(ien) = (wl(ien) + sm * pt - bx * vb) / slmm
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! choose the correct state depending on the speed signs
|
2015-02-16 12:52:49 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sml > 0.0d+00) then ! sl* > 0
|
2015-02-16 12:52:49 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the outer left intermediate flux
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sl * ui(:) - wl(:)
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl* <= 0
|
|
|
|
|
|
|
|
|
|
! separate cases with non-zero and zero Bx
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (b2 > 0.0d+00) then
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! vector of the left-going Alfvén wave
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcl(:) = (sml - sl) * ui(:) + wl(:)
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! primitive variables for the inner left intermediate state
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dv = srmm * dnr + cal * dnl
|
|
|
|
|
vy = (wr(imy) - wcl(imy)) / dv
|
|
|
|
|
vz = (wr(imz) - wcl(imz)) / dv
|
|
|
|
|
dv = sr - sml
|
|
|
|
|
by = (wr(iby) - wcl(iby)) / dv
|
|
|
|
|
bz = (wr(ibz) - wcl(ibz)) / dv
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! conservative variables for the inner left intermediate state
|
|
|
|
|
!
|
|
|
|
|
ui(idn) = dnl
|
|
|
|
|
ui(imx) = dnl * sm
|
|
|
|
|
ui(imy) = dnl * vy
|
|
|
|
|
ui(imz) = dnl * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ul(ibp,i)
|
|
|
|
|
ui(ien) = - (wcl(ien) + sm * pt - bx * vb) / cal
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! choose the correct state depending on the sign of contact discontinuity
|
|
|
|
|
! advection speed
|
|
|
|
|
!
|
|
|
|
|
if (sm >= 0.0d+00) then ! sm >= 0
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! the inner left intermediate flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = sml * ui(:) - wcl(:)
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sm < 0
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! vector of the left-going Alfvén wave
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcr(:) = (sm - sml) * ui(:) + wcl(:)
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the average flux over the right inner intermediate state
|
2015-02-14 23:08:32 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = (sm * wr(:) - sr * wcr(:)) / srmm
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sm < 0
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! bx = 0
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! no Alfvén wave, so revert to the HLL flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl* < 0
|
2015-02-14 23:08:32 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (smr < sr .and. dvr > 0.0d+00) then ! sl* < sl
|
2019-03-30 22:50:08 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! primitive variables for the outer right intermediate state
|
2019-03-30 22:50:08 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vy = ( srmm * wr(imy) - bx * wr(iby)) / dvr
|
|
|
|
|
vz = ( srmm * wr(imz) - bx * wr(ibz)) / dvr
|
|
|
|
|
by = (wr(idn) * wr(iby) - bx * wr(imy)) / dvr
|
|
|
|
|
bz = (wr(idn) * wr(ibz) - bx * wr(imz)) / dvr
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
|
|
|
|
|
|
|
|
|
! conservative variables for the outer right intermediate state
|
2020-02-22 09:59:24 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnr
|
|
|
|
|
ui(imx) = dnr * sm
|
|
|
|
|
ui(imy) = dnr * vy
|
|
|
|
|
ui(imz) = dnr * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ur(ibp,i)
|
|
|
|
|
ui(ien) = (wr(ien) + sm * pt - bx * vb) / srmm
|
|
|
|
|
|
|
|
|
|
! choose the correct state depending on the speed signs
|
2020-02-22 09:59:24 +07:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (smr < 0.0d+00) then ! sr* < 0
|
|
|
|
|
|
|
|
|
|
! the outer right intermediate flux
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = sr * ui(:) - wr(:)
|
|
|
|
|
|
|
|
|
|
else ! sr* > 0
|
|
|
|
|
|
|
|
|
|
! separate cases with non-zero and zero Bx
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (b2 > 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
! vector of the right-going Alfvén wave
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wcr(:) = (smr - sr) * ui(:) + wr(:)
|
|
|
|
|
|
|
|
|
|
! primitive variables for the inner right intermediate state
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dv = slmm * dnl - car * dnr
|
|
|
|
|
vy = (wl(imy) - wcr(imy)) / dv
|
|
|
|
|
vz = (wl(imz) - wcr(imz)) / dv
|
|
|
|
|
dv = sl - smr
|
|
|
|
|
by = (wl(iby) - wcr(iby)) / dv
|
|
|
|
|
bz = (wl(ibz) - wcr(ibz)) / dv
|
|
|
|
|
vb = sm * bx + vy * by + vz * bz
|
|
|
|
|
|
|
|
|
|
! conservative variables for the inner left intermediate state
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ui(idn) = dnr
|
|
|
|
|
ui(imx) = dnr * sm
|
|
|
|
|
ui(imy) = dnr * vy
|
|
|
|
|
ui(imz) = dnr * vz
|
|
|
|
|
ui(ibx) = bx
|
|
|
|
|
ui(iby) = by
|
|
|
|
|
ui(ibz) = bz
|
|
|
|
|
ui(ibp) = ur(ibp,i)
|
|
|
|
|
ui(ien) = (wcr(ien) + sm * pt - bx * vb) / car
|
|
|
|
|
|
|
|
|
|
! choose the correct state depending on the sign of contact discontinuity
|
|
|
|
|
! advection speed
|
|
|
|
|
!
|
|
|
|
|
if (sm <= 0.0d+00) then ! sm <= 0
|
|
|
|
|
|
|
|
|
|
! the inner right intermediate flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = smr * ui(:) - wcr(:)
|
|
|
|
|
|
|
|
|
|
else ! sm > 0
|
|
|
|
|
|
|
|
|
|
! vector of the right-going Alfvén wave
|
|
|
|
|
!
|
|
|
|
|
wcl(:) = (sm - smr) * ui(:) + wcr(:)
|
|
|
|
|
|
|
|
|
|
! calculate the average flux over the left inner intermediate state
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = (sm * wl(:) - sl * wcl(:)) / slmm
|
|
|
|
|
|
|
|
|
|
end if ! sm > 0
|
|
|
|
|
|
|
|
|
|
else ! bx = 0
|
|
|
|
|
|
|
|
|
|
! no Alfvén wave, so revert to the HLL flux
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
end if ! sr* > 0
|
|
|
|
|
|
|
|
|
|
else ! sl* < sl & sr* > sr
|
|
|
|
|
|
|
|
|
|
! so far we revert to HLL flux in the case of degeneracies
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = (sl * wr(:) - sr * wl(:)) / srml
|
|
|
|
|
|
|
|
|
|
end if ! sl* < sl & sr* > sr
|
|
|
|
|
|
|
|
|
|
end if ! deneneracies
|
|
|
|
|
|
|
|
|
|
end if ! sl < 0 < sr
|
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end subroutine riemann_mhd_adi_hlld
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! subroutine RIEMANN_MHD_ADI_ROE:
|
|
|
|
|
! ------------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine solves one dimensional Riemann problem using
|
|
|
|
|
! the Roe's method.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Stone, J. M. & Gardiner, T. A.,
|
2020-02-22 07:06:22 +07:00
|
|
|
|
! "ATHENA: A New Code for Astrophysical MHD",
|
|
|
|
|
! The Astrophysical Journal Suplement Series, 2008, 178, pp. 137-177
|
|
|
|
|
! [2] Toro, E. F.,
|
|
|
|
|
! "Riemann Solvers and Numerical Methods for Fluid dynamics",
|
|
|
|
|
! Springer-Verlag Berlin Heidelberg, 2009
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!===============================================================================
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_adi_roe(ql, qr, fi)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
2022-01-28 10:36:05 -03:00
|
|
|
|
use equations , only : nf, adiabatic_index
|
|
|
|
|
use equations , only : idn, ivx, ivy, ivz, imx, imy, imz, ipr, ien, &
|
2022-01-19 11:53:56 -03:00
|
|
|
|
ibx, iby, ibz, ibp
|
2022-01-28 10:36:05 -03:00
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2020-02-22 07:06:22 +07:00
|
|
|
|
implicit none
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
integer :: i
|
2020-02-22 07:06:22 +07:00
|
|
|
|
real(kind=8) :: sdl, sdr, sds
|
2022-01-28 10:36:05 -03:00
|
|
|
|
real(kind=8) :: xx, yy, pml, pmr
|
|
|
|
|
|
|
|
|
|
real(kind=8) :: cc2, ca2, cf2, cs2, cc, ca, cf, cs
|
|
|
|
|
real(kind=8) :: v2, v2h, br2, br, hp, ayy, sqty
|
|
|
|
|
real(kind=8) :: bty, btz, qf, qs, sqrtd, vqstr, vbet, norm
|
|
|
|
|
real(kind=8) :: alf, als, af_prime, as_prime, afpbb, aspbb, afpb, aspb
|
|
|
|
|
real(kind=8) :: f1, f2, f3, f4, f5
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
2022-01-28 10:36:05 -03:00
|
|
|
|
real(kind=8), dimension(nf ) :: qi
|
|
|
|
|
real(kind=8), dimension(7 ) :: lm, al, df
|
|
|
|
|
|
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
integer , dimension(7) , save :: ivs
|
|
|
|
|
real(kind=8) , save :: adi_m1, adi_m2, adi_m2d1
|
|
|
|
|
real(kind=8), dimension(7,7), save :: rvec, lvec
|
|
|
|
|
!$omp threadprivate(first, ivs, adi_m1, adi_m2, adi_m2d1, rvec, lvec)
|
2021-11-24 13:22:27 -03:00
|
|
|
|
|
2020-02-22 07:06:22 +07:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2022-01-28 10:36:05 -03:00
|
|
|
|
if (first) then
|
|
|
|
|
adi_m1 = adiabatic_index - 1.0d+00
|
|
|
|
|
adi_m2 = adiabatic_index - 2.0d+00
|
|
|
|
|
adi_m2d1 = adi_m2 / adi_m1
|
|
|
|
|
|
|
|
|
|
rvec(:,:) = 0.0d+00
|
|
|
|
|
lvec(:,:) = 0.0d+00
|
|
|
|
|
rvec(4,1) = 1.0d+00
|
|
|
|
|
|
|
|
|
|
ivs = [ idn, imx, imy, imz, ipr, iby, ibz ]
|
|
|
|
|
|
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl)
|
|
|
|
|
call fluxspeed(qr, ur, fr)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
do i = 1, nn
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
pml = 5.0d-01 * sum(ql(ibx:ibz,i) * ql(ibx:ibz,i))
|
|
|
|
|
pmr = 5.0d-01 * sum(qr(ibx:ibz,i) * qr(ibx:ibz,i))
|
2020-11-17 17:52:22 -03:00
|
|
|
|
sdl = sqrt(ql(idn,i))
|
|
|
|
|
sdr = sqrt(qr(idn,i))
|
|
|
|
|
sds = sdl + sdr
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2020-11-17 17:49:05 -03:00
|
|
|
|
qi(idn) = sdl * sdr
|
2022-01-28 10:36:05 -03:00
|
|
|
|
qi(ivx:ivz) = (sdl * ql(ivx:ivz,i) + sdr * qr(ivx:ivz,i)) / sds
|
|
|
|
|
qi(ipr) = ((ul(ien,i) + ql(ipr,i) + pml) / sdl &
|
2020-11-17 17:49:05 -03:00
|
|
|
|
+ (ur(ien,i) + qr(ipr,i) + pmr) / sdr) / sds
|
2022-01-28 10:36:05 -03:00
|
|
|
|
qi(iby:ibz) = (sdr * ql(iby:ibz,i) + sdl * qr(iby:ibz,i)) / sds
|
2020-11-17 17:49:05 -03:00
|
|
|
|
qi(ibx) = ql(ibx,i)
|
|
|
|
|
qi(ibp) = ql(ibp,i)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
f1 = qr(iby,i) - ql(iby,i)
|
|
|
|
|
f2 = qr(ibz,i) - ql(ibz,i)
|
|
|
|
|
xx = 5.0d-01 * (f1 * f1 + f2 * f2) / (sds * sds)
|
|
|
|
|
yy = 5.0d-01 * (ql(idn,i) + qr(idn,i)) / qi(idn)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
br2 = qi(iby) * qi(iby) + qi(ibz) * qi(ibz)
|
|
|
|
|
if (br2 > 0.0d+00) then
|
|
|
|
|
br = sqrt(br2)
|
|
|
|
|
bty = qi(iby) / br
|
|
|
|
|
btz = qi(ibz) / br
|
|
|
|
|
else
|
|
|
|
|
br = 0.0d+00
|
|
|
|
|
bty = 0.0d+00
|
|
|
|
|
btz = 0.0d+00
|
|
|
|
|
end if
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
v2 = sum(qi(ivx:ivz) * qi(ivx:ivz))
|
|
|
|
|
v2h = 5.0d-01 * v2
|
|
|
|
|
ayy = adi_m1 - adi_m2 * yy
|
|
|
|
|
sqty = sqrt(ayy)
|
|
|
|
|
ca2 = qi(ibx) * qi(ibx)
|
|
|
|
|
hp = qi(ien) - (ca2 + br2) / qi(idn)
|
|
|
|
|
ca2 = ca2 / qi(idn)
|
|
|
|
|
f1 = adi_m1 * (hp - v2h)
|
|
|
|
|
f2 = adi_m2 * xx
|
|
|
|
|
if (f1 > f2) then
|
|
|
|
|
cc2 = f1 - f2
|
|
|
|
|
cc = sqrt(cc2)
|
|
|
|
|
f1 = ayy * br2 / qi(idn)
|
|
|
|
|
f2 = ca2 + f1
|
|
|
|
|
f3 = f2 + cc2
|
|
|
|
|
f4 = f2 - cc2
|
|
|
|
|
f5 = sqrt(f4 * f4 + 4.0d+00 * cc2 * f1)
|
|
|
|
|
cf2 = 5.0d-01 * (f3 + f5)
|
|
|
|
|
cs2 = cc2 * ca2 / cf2
|
|
|
|
|
else
|
|
|
|
|
cf2 = ca2 + ayy * br2 / qi(idn)
|
|
|
|
|
cc2 = 0.0d+00
|
|
|
|
|
cc = 0.0d+00
|
|
|
|
|
cs2 = 0.0d+00
|
|
|
|
|
end if
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-29 18:24:33 -03:00
|
|
|
|
if (cs2 < cc2 .and. cc2 < cf2) then
|
|
|
|
|
f1 = (cc2 - cs2) / (cf2 - cs2)
|
|
|
|
|
alf = sqrt(f1)
|
|
|
|
|
als = sqrt(1.0d+00 - f1)
|
|
|
|
|
else if (cc2 >= cf2) then
|
2022-01-28 10:36:05 -03:00
|
|
|
|
alf = 1.0d+00
|
2022-01-29 18:24:33 -03:00
|
|
|
|
als = 0.0d+00
|
|
|
|
|
else
|
|
|
|
|
alf = 0.0d+00
|
2022-01-28 10:36:05 -03:00
|
|
|
|
als = 1.0d+00
|
|
|
|
|
end if
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
cf = sign(sqrt(cf2), qi(ivx))
|
|
|
|
|
ca = sign(sqrt(ca2), qi(ivx))
|
|
|
|
|
cs = sign(sqrt(cs2), qi(ivx))
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
lm(1) = qi(ivx) + cf
|
|
|
|
|
lm(2) = qi(ivx) + ca
|
|
|
|
|
lm(3) = qi(ivx) + cs
|
|
|
|
|
lm(4) = qi(ivx)
|
|
|
|
|
lm(5) = qi(ivx) - cs
|
|
|
|
|
lm(6) = qi(ivx) - ca
|
|
|
|
|
lm(7) = qi(ivx) - cf
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
vbet = (qi(ivy) * bty + qi(ivz) * btz) / sqty
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
sqrtd = sqrt(qi(idn))
|
|
|
|
|
qf = cf * sign(alf, qi(ibx))
|
|
|
|
|
qs = cs * sign(als, qi(ibx))
|
|
|
|
|
f1 = cc / sqrtd
|
|
|
|
|
af_prime = f1 * alf
|
|
|
|
|
as_prime = f1 * als
|
|
|
|
|
f1 = br / sqty
|
|
|
|
|
afpbb = af_prime * f1
|
|
|
|
|
aspbb = as_prime * f1
|
|
|
|
|
|
|
|
|
|
f1 = qs / sqty
|
|
|
|
|
f2 = qs * vbet
|
|
|
|
|
f3 = as_prime / sqty
|
|
|
|
|
rvec(1,1) = alf
|
|
|
|
|
rvec(1,2) = alf * lm(1)
|
|
|
|
|
rvec(1,3) = alf * qi(ivy) - f1 * bty
|
|
|
|
|
rvec(1,4) = alf * qi(ivz) - f1 * btz
|
|
|
|
|
rvec(1,5) = alf * (hp + qi(ivx) * cf) - f2 + aspbb
|
|
|
|
|
rvec(1,6) = f3 * bty
|
|
|
|
|
rvec(1,7) = f3 * btz
|
|
|
|
|
|
|
|
|
|
rvec(7,1) = alf
|
|
|
|
|
rvec(7,2) = alf * lm(7)
|
|
|
|
|
rvec(7,3) = alf * qi(ivy) + f1 * bty
|
|
|
|
|
rvec(7,4) = alf * qi(ivz) + f1 * btz
|
|
|
|
|
rvec(7,5) = alf * (hp - qi(ivx) * cf) + f2 + aspbb
|
|
|
|
|
rvec(7,6) = rvec(1,6)
|
|
|
|
|
rvec(7,7) = rvec(1,7)
|
|
|
|
|
|
|
|
|
|
f1 = qf / sqty
|
|
|
|
|
f2 = qf * vbet
|
|
|
|
|
f3 = - af_prime / sqty
|
|
|
|
|
rvec(3,1) = als
|
|
|
|
|
rvec(3,2) = als * lm(3)
|
|
|
|
|
rvec(3,3) = als * qi(ivy) + f1 * bty
|
|
|
|
|
rvec(3,4) = als * qi(ivz) + f1 * btz
|
|
|
|
|
rvec(3,5) = als * (hp + qi(ivx) * cs) + f2 - afpbb
|
|
|
|
|
rvec(3,6) = f3 * bty
|
|
|
|
|
rvec(3,7) = f3 * btz
|
|
|
|
|
|
|
|
|
|
rvec(5,1) = als
|
|
|
|
|
rvec(5,2) = als * lm(5)
|
|
|
|
|
rvec(5,3) = als * qi(ivy) - f1 * bty
|
|
|
|
|
rvec(5,4) = als * qi(ivz) - f1 * btz
|
|
|
|
|
rvec(5,5) = als * (hp - qi(ivx) * cs) - f2 - afpbb
|
|
|
|
|
rvec(5,6) = rvec(3,6)
|
|
|
|
|
rvec(5,7) = rvec(3,7)
|
|
|
|
|
|
|
|
|
|
f1 = sign(1.0d+00, qi(ivx))
|
|
|
|
|
f2 = sign(1.0d+00 / sqrtd, qi(ibx))
|
|
|
|
|
rvec(2,3) = f1 * btz
|
|
|
|
|
rvec(2,4) = - f1 * bty
|
|
|
|
|
rvec(2,5) = f1 * (qi(ivy) * btz - qi(ivz) * bty)
|
|
|
|
|
rvec(2,6) = - f2 * btz
|
|
|
|
|
rvec(2,7) = f2 * bty
|
|
|
|
|
|
|
|
|
|
rvec(6,3) = - rvec(2,3)
|
|
|
|
|
rvec(6,4) = - rvec(2,4)
|
|
|
|
|
rvec(6,5) = - rvec(2,5)
|
|
|
|
|
rvec(6,6) = rvec(2,6)
|
|
|
|
|
rvec(6,7) = rvec(2,7)
|
|
|
|
|
|
|
|
|
|
rvec(4,2) = qi(ivx)
|
|
|
|
|
rvec(4,3) = qi(ivy)
|
|
|
|
|
rvec(4,4) = qi(ivz)
|
|
|
|
|
rvec(4,5) = v2h + adi_m2d1 * xx
|
|
|
|
|
|
|
|
|
|
norm = 2.0d+00 * cc2
|
|
|
|
|
f1 = sqty * br / norm
|
|
|
|
|
afpb = af_prime * f1
|
|
|
|
|
aspb = as_prime * f1
|
|
|
|
|
sqty = sqty / norm
|
|
|
|
|
vqstr = (qi(ivy) * bty + qi(ivz) * btz) * sqty
|
|
|
|
|
|
|
|
|
|
f1 = adi_m1 * alf / norm
|
|
|
|
|
f2 = qs * sqty
|
|
|
|
|
f3 = as_prime * qi(idn) * sqty
|
|
|
|
|
f4 = alf * cf / norm
|
|
|
|
|
f5 = qs * vqstr
|
|
|
|
|
lvec(1,1) = f1 * (v2 - hp) - f4 * lm(7) + f5 - aspb
|
|
|
|
|
lvec(1,5) = f1
|
|
|
|
|
lvec(1,2) = - f1 * qi(ivx) + f4
|
|
|
|
|
lvec(1,3) = - f1 * qi(ivy) - f2 * bty
|
|
|
|
|
lvec(1,4) = - f1 * qi(ivz) - f2 * btz
|
|
|
|
|
lvec(1,6) = f3 * bty - f1 * qi(iby)
|
|
|
|
|
lvec(1,7) = f3 * btz - f1 * qi(ibz)
|
|
|
|
|
|
|
|
|
|
lvec(7,1) = f1 * (v2 - hp) + f4 * lm(1) - f5 - aspb
|
|
|
|
|
lvec(7,5) = f1
|
|
|
|
|
lvec(7,2) = - f1 * qi(ivx) - f4
|
|
|
|
|
lvec(7,3) = - f1 * qi(ivy) + f2 * bty
|
|
|
|
|
lvec(7,4) = - f1 * qi(ivz) + f2 * btz
|
|
|
|
|
lvec(7,6) = lvec(1,6)
|
|
|
|
|
lvec(7,7) = lvec(1,7)
|
|
|
|
|
|
|
|
|
|
f1 = adi_m1 * als / norm
|
|
|
|
|
f2 = qf * sqty
|
|
|
|
|
f3 = af_prime * qi(idn) * sqty
|
|
|
|
|
f4 = als * cs / norm
|
|
|
|
|
f5 = qf * vqstr
|
|
|
|
|
lvec(3,1) = f1 * (v2 - hp) - f4 * lm(5) - f5 + afpb
|
|
|
|
|
lvec(3,5) = f1
|
|
|
|
|
lvec(3,2) = - f1 * qi(ivx) + f4
|
|
|
|
|
lvec(3,3) = - f1 * qi(ivy) + f2 * bty
|
|
|
|
|
lvec(3,4) = - f1 * qi(ivz) + f2 * btz
|
|
|
|
|
lvec(3,6) = - f3 * bty - f1 * qi(iby)
|
|
|
|
|
lvec(3,6) = - f3 * btz - f1 * qi(ibz)
|
|
|
|
|
|
|
|
|
|
lvec(5,1) = f1 * (v2 - hp) + f4 * lm(3) + f5 + afpb
|
|
|
|
|
lvec(5,5) = f1
|
|
|
|
|
lvec(5,2) = - f1 * qi(ivx) - f4
|
|
|
|
|
lvec(5,3) = - f1 * qi(ivy) - f2 * bty
|
|
|
|
|
lvec(5,4) = - f1 * qi(ivz) - f2 * btz
|
|
|
|
|
lvec(5,6) = lvec(3,6)
|
|
|
|
|
lvec(5,7) = lvec(3,7)
|
|
|
|
|
|
|
|
|
|
f1 = sign(5.0d-01, qi(ivx)) * bty
|
|
|
|
|
f2 = sign(5.0d-01, qi(ivx)) * btz
|
|
|
|
|
f3 = sign(1.0d+00, qi(ivx)) * sign(sqrtd, qi(ibx))
|
|
|
|
|
lvec(2,1) = qi(ivz) * f1 - qi(ivy) * f2
|
|
|
|
|
lvec(2,3) = f2
|
|
|
|
|
lvec(2,4) = - f1
|
|
|
|
|
lvec(2,6) = - f2 * f3
|
|
|
|
|
lvec(2,7) = f1 * f3
|
|
|
|
|
|
|
|
|
|
lvec(6,1) = - lvec(2,1)
|
|
|
|
|
lvec(6,3) = - lvec(2,3)
|
|
|
|
|
lvec(6,4) = - lvec(2,4)
|
|
|
|
|
lvec(6,6) = lvec(2,6)
|
|
|
|
|
lvec(6,7) = lvec(2,7)
|
|
|
|
|
|
|
|
|
|
f1 = 1.0d+00 / cc2
|
|
|
|
|
lvec(4,1) = 1.0d+00 - f1 * (v2h - adi_m2d1 * xx)
|
|
|
|
|
lvec(4,5) = - f1
|
|
|
|
|
lvec(4,2) = f1 * qi(ivx)
|
|
|
|
|
lvec(4,3) = f1 * qi(ivy)
|
|
|
|
|
lvec(4,4) = f1 * qi(ivz)
|
|
|
|
|
lvec(4,6) = f1 * qi(iby)
|
|
|
|
|
lvec(4,7) = f1 * qi(ibz)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2022-01-28 10:36:05 -03:00
|
|
|
|
al = abs(lm) * matmul(lvec, ur(ivs,i) - ul(ivs,i))
|
|
|
|
|
df = matmul(al, rvec)
|
|
|
|
|
fi(ivs,i) = 5.0d-01 * ((fl(ivs,i) + fr(ivs,i)) - df(:))
|
|
|
|
|
fi(ibx,i) = fl(ibx,i)
|
|
|
|
|
fi(ibp,i) = fl(ibp,i)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2020-02-22 10:05:42 +07:00
|
|
|
|
end do
|
2019-03-30 22:50:08 -03:00
|
|
|
|
|
2020-02-22 10:05:42 +07:00
|
|
|
|
!-------------------------------------------------------------------------------
|
2019-03-30 22:50:08 -03:00
|
|
|
|
!
|
2020-02-22 10:05:42 +07:00
|
|
|
|
end subroutine riemann_mhd_adi_roe
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2021-12-22 06:44:17 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_MHD_ADI_KEPES:
|
|
|
|
|
! --------------------------------
|
2021-12-24 07:45:30 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional adiabatic magnetohydrodynamic
|
|
|
|
|
! Riemann problem using the entropy stable KEPES method.
|
2021-12-24 07:45:30 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2021-12-24 07:45:30 -03:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Derigs, D., Winters, A. R., Gassner, G. J., Walch, S., Bohm, M.,
|
|
|
|
|
! "Ideal GLM-MHD: About the entropy consistent nine-wave magnetic
|
|
|
|
|
! field divergence diminishing ideal magnetohydrodynamics equations",
|
|
|
|
|
! Journal of Computational Physics, 2018, 364, pp. 420-467,
|
|
|
|
|
! https://doi.org/10.1016/j.jcp.2018.03.002
|
2021-12-24 07:45:30 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_mhd_adi_kepes(ql, qr, fi)
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use coordinates, only : nn => bcells
|
2022-01-26 17:31:57 -03:00
|
|
|
|
use equations , only : nf, adiabatic_index, cglm
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use equations , only : idn, imx, imy, imz, ivx, ivy, ivz, &
|
|
|
|
|
ibx, iby, ibz, ibp, ipr, ien
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
integer :: i
|
2022-01-26 17:31:57 -03:00
|
|
|
|
real(kind=8) :: dna, pra, vxa, vya, vza, bxa, bya, bza, bpa, dnl, prl, pta
|
|
|
|
|
real(kind=8) :: v2l, v2r, b2l, b2r, bl, br, bta, btl, bp2, eka, ema, vva
|
|
|
|
|
real(kind=8) :: ch, ca, cs, cf, ca2, cs2, cf2, aa2, x2, x3, ub2, uba
|
|
|
|
|
real(kind=8) :: alf, als, das, daf, csq, wps, wms, wpf, wmf
|
|
|
|
|
real(kind=8) :: f1, f2, f3, f4, f5
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf) :: v, lm, tm
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
logical , save :: first = .true.
|
|
|
|
|
real(kind=8) , save :: adi_m1, adi_m1x, adi_m1xi
|
|
|
|
|
real(kind=8), dimension(9,9), save :: rm
|
|
|
|
|
!$omp threadprivate(first, adi_m1, adi_m1x, adi_m1xi, rm)
|
|
|
|
|
|
2021-12-24 07:45:30 -03:00
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
if (first) then
|
2022-01-26 17:31:57 -03:00
|
|
|
|
adi_m1 = adiabatic_index - 1.0d+00
|
|
|
|
|
adi_m1x = adi_m1 / adiabatic_index
|
|
|
|
|
adi_m1xi = adiabatic_index / adi_m1
|
2022-01-19 11:53:56 -03:00
|
|
|
|
|
|
|
|
|
rm(:,:) = 0.0d+00
|
|
|
|
|
rm(1,5) = 1.0d+00
|
2022-01-26 17:31:57 -03:00
|
|
|
|
rm(6,4) = 1.0d+00
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(6,6) = 1.0d+00
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
|
|
|
|
first = .false.
|
|
|
|
|
end if
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
|
|
|
|
|
|
|
|
|
v2l = sum(ql(ivx:ivz,i) * ql(ivx:ivz,i))
|
|
|
|
|
v2r = sum(qr(ivx:ivz,i) * qr(ivx:ivz,i))
|
|
|
|
|
b2l = sum(ql(ibx:ibz,i) * ql(ibx:ibz,i))
|
|
|
|
|
b2r = sum(qr(ibx:ibz,i) * qr(ibx:ibz,i))
|
|
|
|
|
bl = ql(idn,i) / ql(ipr,i)
|
|
|
|
|
br = qr(idn,i) / qr(ipr,i)
|
|
|
|
|
|
|
|
|
|
btl = lmean(bl, br)
|
|
|
|
|
bta = amean(bl, br)
|
2022-01-26 17:31:57 -03:00
|
|
|
|
dnl = lmean(ql(idn,i), qr(idn,i))
|
2022-01-04 11:56:55 -03:00
|
|
|
|
dna = amean(ql(idn,i), qr(idn,i))
|
2021-12-24 07:45:30 -03:00
|
|
|
|
vxa = amean(ql(ivx,i), qr(ivx,i))
|
|
|
|
|
vya = amean(ql(ivy,i), qr(ivy,i))
|
|
|
|
|
vza = amean(ql(ivz,i), qr(ivz,i))
|
2022-01-19 11:53:56 -03:00
|
|
|
|
bxa = amean(ql(ibx,i), qr(ibx,i))
|
|
|
|
|
bya = amean(ql(iby,i), qr(iby,i))
|
|
|
|
|
bza = amean(ql(ibz,i), qr(ibz,i))
|
|
|
|
|
bpa = amean(ql(ibp,i), qr(ibp,i))
|
|
|
|
|
prl = lmean(ql(ipr,i), qr(ipr,i))
|
2022-01-26 17:31:57 -03:00
|
|
|
|
pra = dna / bta
|
2022-01-19 11:53:56 -03:00
|
|
|
|
eka = 5.0d-01 * amean(v2l, v2r)
|
|
|
|
|
ema = 5.0d-01 * amean(b2l, b2r)
|
|
|
|
|
pta = pra + ema
|
|
|
|
|
vva = 5.0d-01 * sum(ql(ivx:ivz,i) * qr(ivx:ivz,i))
|
|
|
|
|
ub2 = 5.0d-01 * amean(ql(ivx,i) * b2l, qr(ivx,i) * b2r)
|
|
|
|
|
uba = amean(sum(ql(ivx:ivz,i) * ql(ibx:ibz,i)), &
|
|
|
|
|
sum(qr(ivx:ivz,i) * qr(ibx:ibz,i)))
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
v(idn) = 5.0d-01 * (bl * v2l - br * v2r)
|
|
|
|
|
if (qr(idn,i) > ql(idn,i)) then
|
|
|
|
|
v(idn) = v(idn) + log(qr(idn,i) / ql(idn,i))
|
|
|
|
|
else if (ql(idn,i) > qr(idn,i)) then
|
|
|
|
|
v(idn) = v(idn) - log(ql(idn,i) / qr(idn,i))
|
|
|
|
|
end if
|
|
|
|
|
if (br > bl) then
|
|
|
|
|
v(idn) = v(idn) + log(br / bl) / adi_m1
|
|
|
|
|
else if (bl > br) then
|
|
|
|
|
v(idn) = v(idn) - log(bl / br) / adi_m1
|
|
|
|
|
end if
|
|
|
|
|
v(ivx) = br * qr(ivx,i) - bl * ql(ivx,i)
|
|
|
|
|
v(ivy) = br * qr(ivy,i) - bl * ql(ivy,i)
|
|
|
|
|
v(ivz) = br * qr(ivz,i) - bl * ql(ivz,i)
|
|
|
|
|
v(ipr) = bl - br
|
|
|
|
|
v(ibx) = br * qr(ibx,i) - bl * ql(ibx,i)
|
|
|
|
|
v(iby) = br * qr(iby,i) - bl * ql(iby,i)
|
|
|
|
|
v(ibz) = br * qr(ibz,i) - bl * ql(ibz,i)
|
|
|
|
|
v(ibp) = br * qr(ibp,i) - bl * ql(ibp,i)
|
|
|
|
|
|
|
|
|
|
bp2 = bya * bya + bza * bza
|
|
|
|
|
if (bp2 > 0.0d+00) then
|
|
|
|
|
f1 = sqrt(bp2)
|
|
|
|
|
x2 = bya / f1
|
|
|
|
|
x3 = bza / f1
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else
|
|
|
|
|
x2 = 0.0d+00
|
|
|
|
|
x3 = 0.0d+00
|
|
|
|
|
end if
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
aa2 = adiabatic_index * pra / dnl
|
2022-01-28 11:49:46 -03:00
|
|
|
|
ca2 = bxa * bxa / dnl
|
|
|
|
|
f1 = bp2 / dnl
|
|
|
|
|
f2 = ca2 + f1
|
|
|
|
|
f3 = f2 - aa2
|
|
|
|
|
f4 = sqrt(f3 * f3 + 4.0d+00 * aa2 * f1)
|
|
|
|
|
cf2 = 5.0d-01 * (f2 + aa2 + f4)
|
|
|
|
|
cs2 = aa2 * ca2 / cf2
|
2022-01-26 17:31:57 -03:00
|
|
|
|
|
2022-01-29 18:24:33 -03:00
|
|
|
|
if (cs2 < aa2 .and. aa2 < cf2) then
|
|
|
|
|
f1 = (aa2 - cs2) / (cf2 - cs2)
|
|
|
|
|
alf = sqrt(f1)
|
|
|
|
|
als = sqrt(1.0d+00 - f1)
|
|
|
|
|
else if (aa2 >= cf2) then
|
2022-01-26 17:31:57 -03:00
|
|
|
|
alf = 1.0d+00
|
2022-01-29 18:24:33 -03:00
|
|
|
|
als = 0.0d+00
|
|
|
|
|
else
|
|
|
|
|
alf = 0.0d+00
|
2022-01-26 17:31:57 -03:00
|
|
|
|
als = 1.0d+00
|
2022-01-04 11:56:55 -03:00
|
|
|
|
end if
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
cf = sign(sqrt(cf2), vxa)
|
|
|
|
|
cs = sign(sqrt(cs2), vxa)
|
|
|
|
|
ca = sign(sqrt(ca2), vxa)
|
|
|
|
|
ch = sign( cglm, vxa)
|
|
|
|
|
|
|
|
|
|
lm(1) = vxa + cf
|
|
|
|
|
lm(2) = vxa + ca
|
|
|
|
|
lm(3) = vxa + cs
|
|
|
|
|
lm(4) = vxa + ch
|
|
|
|
|
lm(5) = vxa
|
|
|
|
|
lm(6) = vxa - ch
|
|
|
|
|
lm(7) = vxa - cs
|
|
|
|
|
lm(8) = vxa - ca
|
|
|
|
|
lm(9) = vxa - cf
|
2021-12-24 07:45:30 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
f1 = 5.0d-01 / bta
|
2022-01-26 17:31:57 -03:00
|
|
|
|
f2 = adiabatic_index * dnl
|
|
|
|
|
tm(1) = 5.0d-01 / f2
|
2022-01-19 11:53:56 -03:00
|
|
|
|
tm(2) = f1 / dnl**2
|
|
|
|
|
tm(3) = tm(1)
|
|
|
|
|
tm(4) = f1
|
|
|
|
|
tm(5) = dnl * adi_m1x
|
|
|
|
|
tm(6) = tm(4)
|
|
|
|
|
tm(7) = tm(1)
|
|
|
|
|
tm(8) = tm(2)
|
|
|
|
|
tm(9) = tm(1)
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
das = dnl * als
|
|
|
|
|
daf = dnl * alf
|
|
|
|
|
csq = sqrt(f2 / bta)
|
|
|
|
|
|
|
|
|
|
f3 = vva + adi_m1xi * prl / dnl
|
|
|
|
|
f4 = vya * x2 + vza * x3
|
|
|
|
|
f5 = sqrt(adiabatic_index * bp2 / (dnl * bta))
|
|
|
|
|
f1 = dnl * (als * f3 - alf * f5)
|
|
|
|
|
f2 = dnl * (als * cs * vxa + sign(alf, bxa) * cf * f4)
|
|
|
|
|
wps = f1 + f2
|
|
|
|
|
wms = f1 - f2
|
|
|
|
|
f1 = dnl * (alf * f3 + als * f5)
|
|
|
|
|
f2 = dnl * (alf * cf * vxa - sign(als, bxa) * cs * f4)
|
|
|
|
|
wpf = f1 + f2
|
|
|
|
|
wmf = f1 - f2
|
|
|
|
|
|
|
|
|
|
f1 = daf
|
|
|
|
|
f2 = sign(das, bxa) * cs
|
|
|
|
|
f3 = als * csq
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,1) = f1
|
2022-01-26 17:31:57 -03:00
|
|
|
|
rm(2,1) = f1 * lm(1)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,1) = f1 * vya - f2 * x2
|
|
|
|
|
rm(4,1) = f1 * vza - f2 * x3
|
|
|
|
|
rm(5,1) = wpf
|
|
|
|
|
rm(7,1) = f3 * x2
|
|
|
|
|
rm(8,1) = f3 * x3
|
2022-01-03 17:25:13 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,9) = f1
|
2022-01-26 17:31:57 -03:00
|
|
|
|
rm(2,9) = f1 * lm(9)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,9) = f1 * vya + f2 * x2
|
|
|
|
|
rm(4,9) = f1 * vza + f2 * x3
|
|
|
|
|
rm(5,9) = wmf
|
|
|
|
|
rm(7,9) = rm(7,1)
|
|
|
|
|
rm(8,9) = rm(8,1)
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
f1 = sign(dnl * sqrt(dna), vxa)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,2) = f1 * x3
|
|
|
|
|
rm(4,2) = - f1 * x2
|
|
|
|
|
rm(5,2) = - f1 * (x2 * vza - x3 * vya)
|
|
|
|
|
rm(7,2) = - dnl * x3
|
|
|
|
|
rm(8,2) = dnl * x2
|
2022-01-03 17:25:13 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,8) = - rm(3,2)
|
|
|
|
|
rm(4,8) = - rm(4,2)
|
|
|
|
|
rm(5,8) = - rm(5,2)
|
|
|
|
|
rm(7,8) = rm(7,2)
|
|
|
|
|
rm(8,8) = rm(8,2)
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
f1 = das
|
|
|
|
|
f2 = sign(daf, bxa) * cf
|
|
|
|
|
f3 = - alf * csq
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,3) = f1
|
2022-01-26 17:31:57 -03:00
|
|
|
|
rm(2,3) = f1 * lm(3)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,3) = f1 * vya + f2 * x2
|
|
|
|
|
rm(4,3) = f1 * vza + f2 * x3
|
|
|
|
|
rm(5,3) = wps
|
|
|
|
|
rm(7,3) = f3 * x2
|
|
|
|
|
rm(8,3) = f3 * x3
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(1,7) = f1
|
2022-01-26 17:31:57 -03:00
|
|
|
|
rm(2,7) = f1 * lm(7)
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(3,7) = f1 * vya - f2 * x2
|
|
|
|
|
rm(4,7) = f1 * vza - f2 * x3
|
|
|
|
|
rm(5,7) = wms
|
|
|
|
|
rm(7,7) = rm(7,3)
|
|
|
|
|
rm(8,7) = rm(8,3)
|
|
|
|
|
|
2022-01-26 17:31:57 -03:00
|
|
|
|
f1 = sign(1.0d+00, vxa)
|
|
|
|
|
rm(5,4) = bxa + bpa * f1
|
|
|
|
|
rm(5,6) = bxa - bpa * f1
|
|
|
|
|
rm(9,4) = f1
|
|
|
|
|
rm(9,6) = - f1
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(2,5) = vxa
|
2022-01-04 12:44:10 -03:00
|
|
|
|
rm(3,5) = vya
|
2021-12-24 06:44:56 -03:00
|
|
|
|
rm(4,5) = vza
|
2022-01-19 11:53:56 -03:00
|
|
|
|
rm(5,5) = vva
|
|
|
|
|
|
|
|
|
|
fi(idn,i) = dnl * vxa
|
|
|
|
|
fi(imx,i) = fi(idn,i) * vxa - bxa * bxa + pta
|
|
|
|
|
fi(imy,i) = fi(idn,i) * vya - bxa * bya
|
|
|
|
|
fi(imz,i) = fi(idn,i) * vza - bxa * bza
|
2022-01-26 17:31:57 -03:00
|
|
|
|
fi(ibx,i) = cglm * bpa
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(iby,i) = vxa * bya - bxa * vya
|
|
|
|
|
fi(ibz,i) = vxa * bza - bxa * vza
|
2022-01-26 17:31:57 -03:00
|
|
|
|
fi(ibp,i) = cglm * bxa
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(ien,i) = fi(idn,i) * (1.0d+00 / (adi_m1 * btl) - eka) &
|
|
|
|
|
+ (fi(imx,i) * vxa + fi(imy,i) * vya + fi(imz,i) * vza) &
|
|
|
|
|
+ (fi(ibx,i) * bxa + fi(iby,i) * bya + fi(ibz,i) * bza) &
|
|
|
|
|
+ fi(ibp,i) * bpa - ub2 + bxa * uba &
|
2022-01-26 17:31:57 -03:00
|
|
|
|
- cglm * amean(ql(ibx,i) * ql(ibp,i), qr(ibx,i) * qr(ibp,i))
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fi(:,i) - 5.0d-01 * matmul(rm, (abs(lm) * tm) * matmul(v, rm))
|
2021-12-22 06:44:17 -03:00
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_mhd_adi_kepes
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! RELATIVISTIC ADIABATIC MAGNETOHYDRODYNAMIC RIEMANN SOLVERS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
2021-12-22 06:44:17 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! subroutine RIEMANN_SRMHD_HLLC:
|
|
|
|
|
! -----------------------------
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! Subroutine solves one dimensional Riemann problem using
|
|
|
|
|
! the Harten-Lax-van Leer method with contact discontinuity resolution (HLLC)
|
|
|
|
|
! by Mignone & Bodo.
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! ql, qr - the primitive variables of the left and right Riemann states;
|
|
|
|
|
! fi - the numerical flux at the cell interface;
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
|
|
|
|
! References:
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! [1] Mignone, A. & Bodo, G.
|
|
|
|
|
! "An HLLC Riemann solver for relativistic flows - II.
|
|
|
|
|
! Magnetohydrodynamics",
|
|
|
|
|
! Monthly Notices of the Royal Astronomical Society,
|
|
|
|
|
! 2006, Volume 368, Pages 1040-1054
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
subroutine riemann_srmhd_hllc(ql, qr, fi)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
use algebra , only : quadratic
|
|
|
|
|
use coordinates, only : nn => bcells
|
|
|
|
|
use equations , only : nf, idn, ivx, imx, imy, imz, ien, ibx, iby, ibz, ibp
|
|
|
|
|
use equations , only : prim2cons, fluxspeed
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(:,:), intent(in) :: ql, qr
|
|
|
|
|
real(kind=8), dimension(:,:), intent(out) :: fi
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
integer :: i, nr
|
|
|
|
|
real(kind=8) :: sl, sr, srml, sm
|
|
|
|
|
real(kind=8) :: bx2
|
|
|
|
|
real(kind=8) :: pt, dv, fc, uu, ff, uf
|
|
|
|
|
real(kind=8) :: vv, vb, gi
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
real(kind=8), dimension(nf,nn) :: ul, ur, fl, fr
|
|
|
|
|
real(kind=8), dimension( 2,nn) :: cl, cr
|
|
|
|
|
real(kind=8), dimension(nf ) :: wl, wr, uh, us, fh
|
|
|
|
|
real(kind=8), dimension(3) :: a, vs
|
|
|
|
|
real(kind=8), dimension(2) :: x
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call prim2cons(ql, ul)
|
|
|
|
|
call prim2cons(qr, ur)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
call fluxspeed(ql, ul, fl, cl)
|
|
|
|
|
call fluxspeed(qr, ur, fr, cr)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
do i = 1, nn
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sl = min(cl(1,i), cr(1,i))
|
|
|
|
|
sr = max(cl(2,i), cr(2,i))
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sl >= 0.0d+00) then
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sr <= 0.0d+00) then
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! sl < 0 < sr
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
srml = sr - sl
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wl(:) = sl * ul(:,i) - fl(:,i)
|
|
|
|
|
wr(:) = sr * ur(:,i) - fr(:,i)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uh(:) = ( wr(:) - wl(:)) / srml
|
|
|
|
|
fh(:) = (sl * wr(:) - sr * wl(:)) / srml
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
wl(ien) = wl(ien) + wl(idn)
|
|
|
|
|
wr(ien) = wr(ien) + wr(idn)
|
|
|
|
|
|
|
|
|
|
! calculate Bₓ²
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
bx2 = ql(ibx,i) * qr(ibx,i)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the contact dicontinuity speed solving eq. (41)
|
|
|
|
|
!
|
|
|
|
|
if (bx2 >= 1.0d-16) then
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! prepare the quadratic coefficients, (eq. 42 in [1])
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
uu = sum(uh(iby:ibz) * uh(iby:ibz))
|
|
|
|
|
ff = sum(fh(iby:ibz) * fh(iby:ibz))
|
|
|
|
|
uf = sum(uh(iby:ibz) * fh(iby:ibz))
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
a(1) = uh(imx) - uf
|
|
|
|
|
a(2) = uu + ff - (fh(imx) + uh(ien) + uh(idn))
|
|
|
|
|
a(3) = fh(ien) + fh(idn) - uf
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! solve the quadratic equation
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
nr = quadratic(a(1:3), x(1:2))
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! if Δ < 0, just use the HLL flux
|
2022-01-09 17:48:50 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (nr < 1) then
|
|
|
|
|
fi(:,i) = fh(:)
|
|
|
|
|
else
|
2022-01-09 17:48:50 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! get the contact dicontinuity speed
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
sm = x(1)
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! if the contact discontinuity speed exceeds the sonic speeds, use the HLL flux
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if ((sm <= sl) .or. (sm >= sr)) then
|
|
|
|
|
fi(:,i) = fh(:)
|
|
|
|
|
else
|
2022-01-01 12:36:53 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! substitute magnetic field components from the HLL state (eq. 37 in [1])
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
us(ibx) = ql(ibx,i)
|
|
|
|
|
us(iby) = uh(iby)
|
|
|
|
|
us(ibz) = uh(ibz)
|
|
|
|
|
us(ibp) = ql(ibp,i)
|
|
|
|
|
|
|
|
|
|
! calculate velocity components without Bₓ normalization (eq. 38 in [1])
|
2022-01-01 12:36:53 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vs(1) = sm
|
|
|
|
|
vs(2) = (us(iby) * sm - fh(iby)) / us(ibx)
|
|
|
|
|
vs(3) = (us(ibz) * sm - fh(ibz)) / us(ibx)
|
|
|
|
|
|
|
|
|
|
! calculate v² and v.B
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
vv = sum(vs(1:3) * vs( 1: 3))
|
|
|
|
|
vb = sum(vs(1:3) * us(ibx:ibz))
|
|
|
|
|
|
|
|
|
|
! calculate inverse of Lorentz factor
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
gi = 1.0d+00 - vv
|
|
|
|
|
|
|
|
|
|
! calculate total pressure (eq. 40 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
pt = fh(imx) + gi * bx2 - (fh(ien) + fh(idn) - us(ibx) * vb) * sm
|
|
|
|
|
|
|
|
|
|
! if the pressure is negative, use the HLL flux
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (pt <= 0.0d+00) then
|
|
|
|
|
fi(:,i) = fh(:)
|
|
|
|
|
else
|
|
|
|
|
|
|
|
|
|
! depending in the sign of the contact dicontinuity speed, calculate the proper
|
|
|
|
|
! state and corresponding flux
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sm > 0.0d+00) then
|
|
|
|
|
|
|
|
|
|
! calculate the conserved variable vector (eqs. 43-46 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dv = sl - sm
|
|
|
|
|
fc = (sl - ql(ivx,i)) / dv
|
|
|
|
|
us(idn) = fc * ul(idn,i)
|
|
|
|
|
us(imy) = (sl * ul(imy,i) - fl(imy,i) &
|
|
|
|
|
- us(ibx) * (gi * us(iby) + vs(2) * vb)) / dv
|
|
|
|
|
us(imz) = (sl * ul(imz,i) - fl(imz,i) &
|
|
|
|
|
- us(ibx) * (gi * us(ibz) + vs(3) * vb)) / dv
|
|
|
|
|
us(ien) = (sl * (ul(ien,i) + ul(idn,i)) &
|
|
|
|
|
- (fl(ien,i) + fl(idn,i)) &
|
|
|
|
|
+ pt * sm - us(ibx) * vb) / dv - us(idn)
|
|
|
|
|
|
|
|
|
|
! calculate normal component of momentum
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
us(imx) = (us(ien) + us(idn) + pt) * sm - us(ibx) * vb
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the flux (eq. 14 in [1])
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = fl(:,i) + sl * (us(:) - ul(:,i))
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sm < 0.0d+00) then
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the conserved variable vector (eqs. 43-46 in [1])
|
|
|
|
|
!
|
|
|
|
|
dv = sr - sm
|
|
|
|
|
fc = (sr - qr(ivx,i)) / dv
|
|
|
|
|
us(idn) = fc * ur(idn,i)
|
|
|
|
|
us(imy) = (sr * ur(imy,i) - fr(imy,i) &
|
|
|
|
|
- us(ibx) * (gi * us(iby) + vs(2) * vb)) / dv
|
|
|
|
|
us(imz) = (sr * ur(imz,i) - fr(imz,i) &
|
|
|
|
|
- us(ibx) * (gi * us(ibz) + vs(3) * vb)) / dv
|
|
|
|
|
us(ien) = (sr * (ur(ien,i) + ur(idn,i)) &
|
|
|
|
|
- (fr(ien,i) + fr(idn,i)) &
|
|
|
|
|
+ pt * sm - us(ibx) * vb) / dv - us(idn)
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate normal component of momentum
|
|
|
|
|
!
|
|
|
|
|
us(imx) = (us(ien) + us(idn) + pt) * sm - us(ibx) * vb
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the flux (eq. 14 in [1])
|
|
|
|
|
!
|
|
|
|
|
fi(:,i) = fr(:,i) + sr * (us(:) - ur(:,i))
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! intermediate flux is constant across the contact discontinuity so use HLL flux
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fh(:)
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sm == 0
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! p* < 0
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl < sm < sr
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! nr < 1
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else ! Bx² > 0
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! prepare the quadratic coefficients (eq. 47 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
a(1) = uh(imx)
|
|
|
|
|
a(2) = - (fh(imx) + uh(ien) + uh(idn))
|
|
|
|
|
a(3) = fh(ien) + fh(idn)
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! solve the quadratic equation
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
nr = quadratic(a(1:3), x(1:2))
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! if Δ < 0, just use the HLL flux
|
|
|
|
|
!
|
|
|
|
|
if (nr < 1) then
|
|
|
|
|
fi(:,i) = fh(:)
|
|
|
|
|
else
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! get the contact dicontinuity speed
|
|
|
|
|
!
|
|
|
|
|
sm = x(1)
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! if the contact discontinuity speed exceeds the sonic speeds, use the HLL flux
|
|
|
|
|
!
|
|
|
|
|
if ((sm <= sl) .or. (sm >= sr)) then
|
|
|
|
|
fi(:,i) = fh(:)
|
|
|
|
|
else
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate total pressure (eq. 48 in [1])
|
|
|
|
|
!
|
|
|
|
|
pt = fh(imx) - (fh(ien) + fh(idn)) * sm
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! if the pressure is negative, use the HLL flux
|
|
|
|
|
!
|
|
|
|
|
if (pt <= 0.0d+00) then
|
|
|
|
|
fi(:,i) = fh(:)
|
|
|
|
|
else
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! depending in the sign of the contact dicontinuity speed, calculate the proper
|
|
|
|
|
! state and corresponding flux
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
if (sm > 0.0d+00) then
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the conserved variable vector (eqs. 43-46 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dv = sl - sm
|
|
|
|
|
us(idn) = wl(idn) / dv
|
|
|
|
|
us(imy) = wl(imy) / dv
|
|
|
|
|
us(imz) = wl(imz) / dv
|
|
|
|
|
us(ien) = (wl(ien) + pt * sm) / dv
|
|
|
|
|
us(imx) = (us(ien) + pt) * sm
|
|
|
|
|
us(ien) = us(ien) - us(idn)
|
|
|
|
|
us(ibx) = 0.0d+00
|
|
|
|
|
us(iby) = wl(iby) / dv
|
|
|
|
|
us(ibz) = wl(ibz) / dv
|
|
|
|
|
us(ibp) = ql(ibp,i)
|
|
|
|
|
|
|
|
|
|
! calculate the flux (eq. 27 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fl(:,i) + sl * (us(:) - ul(:,i))
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else if (sm < 0.0d+00) then
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the conserved variable vector (eqs. 43-46 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
dv = sr - sm
|
|
|
|
|
us(idn) = wr(idn) / dv
|
|
|
|
|
us(imy) = wr(imy) / dv
|
|
|
|
|
us(imz) = wr(imz) / dv
|
|
|
|
|
us(ien) = (wr(ien) + pt * sm) / dv
|
|
|
|
|
us(imx) = (us(ien) + pt) * sm
|
|
|
|
|
us(ien) = us(ien) - us(idn)
|
|
|
|
|
us(ibx) = 0.0d+00
|
|
|
|
|
us(iby) = wr(iby) / dv
|
|
|
|
|
us(ibz) = wr(ibz) / dv
|
|
|
|
|
us(ibp) = qr(ibp,i)
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! calculate the flux (eq. 27 in [1])
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fr(:,i) + sr * (us(:) - ur(:,i))
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
else
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
! intermediate flux is constant across the contact discontinuity so use HLL flux
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
fi(:,i) = fh(:)
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sm == 0
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! p* < 0
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! sl < sm < sr
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end if ! nr < 1
|
|
|
|
|
|
|
|
|
|
end if ! Bx² == 0 or > 0
|
|
|
|
|
|
|
|
|
|
end if ! sl < 0 < sr
|
2021-12-23 23:30:46 -03:00
|
|
|
|
|
|
|
|
|
end do
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-19 11:53:56 -03:00
|
|
|
|
end subroutine riemann_srmhd_hllc
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
|
|
|
|
!
|
|
|
|
|
! SUPPORTING SUBROUTINES/FUNCTIONS
|
|
|
|
|
!
|
|
|
|
|
!*******************************************************************************
|
2021-12-23 23:30:46 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
2020-02-22 10:05:42 +07:00
|
|
|
|
!
|
|
|
|
|
! subroutine HIGHER_ORDER_FLUX_CORRECTION:
|
|
|
|
|
! ---------------------------------------
|
|
|
|
|
!
|
|
|
|
|
! Subroutine adds higher order corrections to the numerical fluxes.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! f - the vector of numerical fluxes;
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
subroutine higher_order_flux_correction(f)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
2020-02-22 10:05:42 +07:00
|
|
|
|
! include external procedures
|
2018-02-06 11:32:24 -02:00
|
|
|
|
!
|
2020-02-22 10:05:42 +07:00
|
|
|
|
use interpolations, only : order
|
|
|
|
|
|
|
|
|
|
! local variables are not implicit by default
|
|
|
|
|
!
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
! subroutine arguments
|
|
|
|
|
!
|
|
|
|
|
real(kind=8), dimension(:,:), intent(inout) :: f
|
|
|
|
|
|
|
|
|
|
! local variables
|
|
|
|
|
!
|
|
|
|
|
integer :: n
|
|
|
|
|
|
|
|
|
|
! local arrays to store the states
|
|
|
|
|
!
|
|
|
|
|
real(kind=8), dimension(size(f,1),size(f,2)) :: f2, f4
|
|
|
|
|
!
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
! depending on the scheme order calculate and add higher order corrections,
|
|
|
|
|
! if required
|
|
|
|
|
!
|
|
|
|
|
if (.not. high_order_flux .or. order <= 2) return
|
|
|
|
|
|
|
|
|
|
! get the length of vector
|
|
|
|
|
!
|
|
|
|
|
n = size(f, 2)
|
|
|
|
|
|
|
|
|
|
! 2nd order correction
|
|
|
|
|
!
|
|
|
|
|
f2(:,2:n-1) = (2.0d+00 * f(:,2:n-1) - (f(:,3:n) + f(:,1:n-2))) / 2.4d+01
|
|
|
|
|
f2(:,1 ) = 0.0d+00
|
|
|
|
|
f2(:, n ) = 0.0d+00
|
|
|
|
|
|
|
|
|
|
! 4th order correction
|
|
|
|
|
!
|
|
|
|
|
if (order > 4) then
|
|
|
|
|
|
|
|
|
|
f4(:,3:n-2) = 3.0d+00 * (f(:,1:n-4) + f(:,5:n ) &
|
|
|
|
|
- 4.0d+00 * (f(:,2:n-3) + f(:,4:n-1)) &
|
|
|
|
|
+ 6.0d+00 * f(:,3:n-2)) / 6.4d+02
|
|
|
|
|
f4(:,1 ) = 0.0d+00
|
|
|
|
|
f4(:,2 ) = 0.0d+00
|
|
|
|
|
f4(:, n-1) = 0.0d+00
|
|
|
|
|
f4(:, n ) = 0.0d+00
|
|
|
|
|
|
|
|
|
|
! correct the flux for 4th order
|
|
|
|
|
!
|
|
|
|
|
f(:,:) = f(:,:) + f4(:,:)
|
|
|
|
|
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
! correct the flux for 2nd order
|
|
|
|
|
!
|
|
|
|
|
f(:,:) = f(:,:) + f2(:,:)
|
2018-02-06 11:32:24 -02:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2020-02-22 10:05:42 +07:00
|
|
|
|
end subroutine higher_order_flux_correction
|
2021-12-21 22:09:43 -03:00
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! function LMEAN:
|
|
|
|
|
! --------------
|
|
|
|
|
!
|
2021-12-23 23:45:29 -03:00
|
|
|
|
! Function calculates the logarithmic mean using the optimized algorithm
|
|
|
|
|
! by Ranocha et al.
|
2021-12-21 22:09:43 -03:00
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! l, r - the values to calculate the mean of;
|
|
|
|
|
!
|
2021-12-23 23:45:29 -03:00
|
|
|
|
! References:
|
|
|
|
|
!
|
|
|
|
|
! [1] Ranocha et al.,
|
|
|
|
|
! "Efficient implementation of modern entropy stable and kinetic energy
|
|
|
|
|
! preserving discontinuous Galerkin methods for conservation laws",
|
|
|
|
|
! http://arxiv.org/abs/2112.10517v1
|
|
|
|
|
!
|
2021-12-21 22:09:43 -03:00
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
real(kind=8) function lmean(l, r)
|
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
real(kind=8), intent(in) :: l, r
|
|
|
|
|
|
2022-01-03 11:38:08 -03:00
|
|
|
|
real(kind=8) :: u, d, s
|
2021-12-23 23:45:29 -03:00
|
|
|
|
|
|
|
|
|
real(kind=8), parameter :: c1 = 2.0d+00, c2 = 2.0d+00 / 3.0d+00, &
|
|
|
|
|
c3 = 4.0d-01, c4 = 2.0d+00 / 7.0d+00
|
2021-12-21 22:09:43 -03:00
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
2022-01-03 11:38:08 -03:00
|
|
|
|
d = r - l
|
|
|
|
|
s = r + l
|
2022-01-04 11:52:40 -03:00
|
|
|
|
u = (d / s)**2
|
|
|
|
|
if (u < 1.0d-04) then
|
2022-01-03 11:38:08 -03:00
|
|
|
|
lmean = s / (c1 + u * (c2 + u * (c3 + u * c4)))
|
2021-12-21 22:09:43 -03:00
|
|
|
|
else
|
2022-01-03 11:38:08 -03:00
|
|
|
|
if (d >= 0.0d+00) then
|
|
|
|
|
s = log(r / l)
|
|
|
|
|
else
|
|
|
|
|
s = log(l / r)
|
|
|
|
|
end if
|
|
|
|
|
lmean = abs(d) / s
|
2021-12-21 22:09:43 -03:00
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end function lmean
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
! function AMEAN:
|
|
|
|
|
! --------------
|
|
|
|
|
!
|
|
|
|
|
! Function calculate the arithmetic mean.
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
!
|
|
|
|
|
! l, r - the values to calculate the mean of;
|
|
|
|
|
!
|
|
|
|
|
!===============================================================================
|
|
|
|
|
!
|
|
|
|
|
real(kind=8) function amean(l, r)
|
|
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
|
|
real(kind=8), intent(in) :: l, r
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
amean = 5.0d-01 * (l + r)
|
|
|
|
|
|
|
|
|
|
!-------------------------------------------------------------------------------
|
|
|
|
|
!
|
|
|
|
|
end function amean
|
2008-12-08 19:07:42 -06:00
|
|
|
|
|
2008-12-08 21:04:20 -06:00
|
|
|
|
!===============================================================================
|
2008-12-08 19:07:42 -06:00
|
|
|
|
!
|
2012-08-01 16:38:10 -03:00
|
|
|
|
end module schemes
|