Convert conservative variables to primitive variables.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(euler_1D_caf_nf), | intent(in) | :: | self | Euler field. |
||
real(kind=R_P), | intent(in) | :: | conservative(:) | Conservative variables. |
Primitive variables.
pure function conservative2primitive(self, conservative) result(primitive)
!--------------------------------------------------------------------------------------------------------------------------------
!< Convert conservative variables to primitive variables.
!--------------------------------------------------------------------------------------------------------------------------------
class(euler_1D_caf_nf), intent(IN) :: self !< Euler field.
real(R_P), intent(IN) :: conservative(:) !< Conservative variables.
real(R_P) :: primitive(1:self%Np) !< Primitive variables.
real(R_P), allocatable :: c(:) !< Species concentration.
!--------------------------------------------------------------------------------------------------------------------------------
!--------------------------------------------------------------------------------------------------------------------------------
associate(Ns=>self%Ns, cp0=>self%cp0, cv0=>self%cv0)
primitive(1:Ns) = conservative(1:Ns)
primitive(Ns + 3) = sum(conservative(1:Ns))
c = primitive(1:Ns) / primitive(Ns + 3)
primitive(Ns + 4) = dot_product(c, cp0) / dot_product(c, cv0)
primitive(Ns + 1) = conservative(Ns + 1) / primitive(Ns + 3)
primitive(Ns + 2) = (conservative(Ns + 2) - 0.5_R_P * primitive(Ns + 3) * primitive(Ns + 1) * primitive(Ns + 1)) * &
(primitive(Ns + 4) - 1._R_P)
endassociate
return
!--------------------------------------------------------------------------------------------------------------------------------
endfunction conservative2primitive