to_conservative Subroutine

public pure subroutine to_conservative(u)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(inout) :: u(nw_phys)

Called by

proc~~to_conservative~~CalledByGraph proc~to_conservative to_conservative proc~phys_to_conserved phys_to_conserved proc~phys_to_conserved->proc~to_conservative

Source Code

  pure subroutine to_conservative(u)
    
    real(dp), intent(inout) :: u(nw_phys)

    real(dp) :: rho,rhoh,pth
    real(dp) :: E,E_th

    rhoh=(u(iw_mom(1))**2+u(iw_mom(2))**2+u(iw_mom(3))**2)
    u(lfac_)=dsqrt(1.0d0+rhoh)

    rho=u(iw_rho)
    pth=u(iw_e)
    !! begin: call srhd_get_enthalpy_eos(rho,pth,rhoh)
    if(srhd_eos) then
     E_th = pth*inv_gamma_1
     E    = E_th+dsqrt(E_th**2+rho**2)
     ! writing rho/E on purpose, for numerics 
     rhoh = 0.5_dp*((srhd_gamma+1.0_dp)*E &
                   - gamma_1*rho*(rho/E))
    else
     rhoh = rho+gamma_to_gamma_1*pth
    end if
    !! end: call srhd_get_enthalpy_eos(rho,pth,rhoh)

    rhoh=rhoh*u(lfac_)
    u(xi_)=u(lfac_)*rhoh

    u(iw_rho)=u(lfac_)*rho
    u(iw_mom(1))=rhoh*u(iw_mom(1))
    u(iw_mom(2))=rhoh*u(iw_mom(2))
    u(iw_mom(3))=rhoh*u(iw_mom(3))
    u(iw_e)=u(xi_)-pth-u(iw_rho)

  end subroutine to_conservative