MPI-AMRVAC  3.0
The MPI - Adaptive Mesh Refinement - Versatile Advection Code
mod_mhd_ppm.t
Go to the documentation of this file.
1 module mod_mhd_ppm
2  use mod_mhd_phys
3 
4  implicit none
5  private
6 
7  public :: mhd_ppm_init
8 
9 contains
10 
11  subroutine mhd_ppm_init()
12  use mod_physics_ppm
13 
16  end subroutine mhd_ppm_init
17 
18  subroutine mhd_ppm_flatcd(ixI^L,ixO^L,ixL^L,ixR^L,w,d2w,drho,dp)
20 
21  integer, intent(in) :: ixI^L,ixO^L,ixL^L,ixR^L
22  double precision, intent(in) :: w(ixI^S,nw),d2w(ixI^S,1:nwflux)
23  double precision, intent(inout) :: drho(ixI^S),dp(ixI^S)
24 
25  if(mhd_energy) then
26  drho(ixo^s) =mhd_gamma*dabs(d2w(ixo^s,rho_))&
27  /min(w(ixl^s,rho_),w(ixr^s,rho_))
28  dp(ixo^s) = dabs(d2w(ixo^s,p_))/min(w(ixl^s,p_),w(ixr^s,p_))
29  else
30  call mpistop("PPM with flatcd=.true. can not be used without energy equation!")
31  end if
32  end subroutine mhd_ppm_flatcd
33 
34  ! based on Mignone and Miller and Collela 2002
35  ! PPM flattening at shocks: we use total pressure and not thermal pressure
36  subroutine mhd_ppm_flatsh(ixI^L,ixO^L,ixLL^L,ixL^L,ixR^L,ixRR^L,idims,w,drho,dp,dv)
38  use mod_geometry
39 
40  integer, intent(in) :: ixI^L,ixO^L,ixLL^L,ixL^L,ixR^L,ixRR^L
41  integer, intent(in) :: idims
42  double precision, intent(in) :: w(ixI^S,nw)
43  double precision, intent(inout) :: drho(ixI^S),dp(ixI^S),dv(ixI^S)
44  double precision :: ptot(ixI^S)
45 
46  if(mhd_energy) then
47  ! eq. B15, page 218, Mignone and Bodo 2005, ApJS (beta1)
48  ptot(ixo^s)=w(ixo^s,p_)+half*sum(w(ixo^s,mag(:))**2,dim=ndim+1)
49  where (dabs(ptot(ixrr^s)-ptot(ixll^s))>smalldouble)
50  drho(ixo^s) = dabs((ptot(ixr^s)-ptot(ixl^s))&
51  /(ptot(ixrr^s)-ptot(ixll^s)))
52  elsewhere
53  drho(ixo^s) = zero
54  end where
55 
56  ! eq. B76, page 48, Miller and Collela 2002, JCP 183, 26
57  ! use "dp" to save squared sound speed, assume primitive in w
58  dp(ixo^s)=(mhd_gamma*w(ixo^s,p_)/w(ixo^s,rho_))
59 
60  dp(ixo^s) = dabs(ptot(ixr^s)-ptot(ixl^s))&
61  /(w(ixo^s,rho_)*dp(ixo^s))
62  ! recycle ptot to store v
63  ptot(ixi^s)= w(ixi^s,mom(idims))
64  call gradient(ptot,ixi^l,ixo^l,idims,dv)
65  else
66  call mpistop("PPM with flatsh=.true. can not be used without energy equation!")
67  end if
68 
69  end subroutine mhd_ppm_flatsh
70 
71 end module mod_mhd_ppm
subroutine mpistop(message)
Exit MPI-AMRVAC with an error message.
Definition: comm_lib.t:194
Module with geometry-related routines (e.g., divergence, curl)
Definition: mod_geometry.t:2
subroutine gradient(q, ixIL, ixOL, idir, gradq)
Calculate gradient of a scalar q within ixL in direction idir.
Definition: mod_geometry.t:320
This module contains definitions of global parameters and variables and some generic functions/subrou...
integer, parameter ndim
Number of spatial dimensions for grid variables.
Magneto-hydrodynamics module.
Definition: mod_mhd_phys.t:2
integer, dimension(:), allocatable, public, protected mom
Indices of the momentum density.
Definition: mod_mhd_phys.t:124
double precision, public mhd_gamma
The adiabatic index.
Definition: mod_mhd_phys.t:150
integer, dimension(:), allocatable, public, protected mag
Indices of the magnetic field.
Definition: mod_mhd_phys.t:133
logical, public, protected mhd_energy
Whether an energy equation is used.
Definition: mod_mhd_phys.t:16
integer, public, protected p_
Index of the gas pressure (-1 if not present) should equal e_.
Definition: mod_mhd_phys.t:130
integer, public, protected rho_
Index of the density (in the w array)
Definition: mod_mhd_phys.t:121
subroutine, public mhd_ppm_init()
Definition: mod_mhd_ppm.t:12
subroutine mhd_ppm_flatcd(ixIL, ixOL, ixLL, ixRL, w, d2w, drho, dp)
Definition: mod_mhd_ppm.t:19
subroutine mhd_ppm_flatsh(ixIL, ixOL, ixLLL, ixLL, ixRL, ixRRL, idims, w, drho, dp, dv)
Definition: mod_mhd_ppm.t:37
procedure(sub_ppm_flatcd), pointer phys_ppm_flatcd
procedure(sub_ppm_flatsh), pointer phys_ppm_flatsh