77!! Currently, the available derived variables include the unadvected
88!! volume fraction, specific heat ratio, liquid stiffness, speed of
99!! sound, vorticity and the numerical Schlieren function.
10+
11+ #:include ' inline_conversions.fpp'
12+
1013module m_derived_variables
1114
1215 ! Dependencies =============================================================
@@ -15,6 +18,8 @@ module m_derived_variables
1518 use m_global_parameters !< Global parameters for the code
1619
1720 use m_mpi_proxy !< Message passing interface (MPI) module proxy
21+
22+ use m_variables_conversion
1823 ! ==========================================================================
1924
2025 implicit none
@@ -28,7 +33,8 @@ module m_derived_variables
2833 s_derive_vorticity_component, &
2934 s_derive_qm, &
3035 s_derive_numerical_schlieren_function, &
31- s_finalize_derived_variables_module
36+ s_finalize_derived_variables_module, &
37+ s_compute_speed_of_sound
3238
3339 real (kind (0d0 )), allocatable, dimension (:, :, :) :: gm_rho_sf !<
3440 !! Gradient magnitude (gm) of the density for each cell of the computational
@@ -570,14 +576,14 @@ subroutine s_derive_vorticity_component(i, q_prim_vf, q_sf) ! ----------
570576
571577 end subroutine s_derive_vorticity_component ! --------------------------
572578
573- ! > This subroutine gets as inputs the primitive variables. From those
574- ! ! inputs, it proceeds to calculate the value of the Q_M
575- ! ! function, which are subsequently stored in the derived flow
576- ! ! quantity storage variable, q_sf.
577- ! ! @param q_prim_vf Primitive variables
578- ! ! @param q_sf Q_M
579- subroutine s_derive_qm (q_prim_vf ,q_sf )
580- type (scalar_field), &
579+ !> This subroutine gets as inputs the primitive variables. From those
580+ !! inputs, it proceeds to calculate the value of the Q_M
581+ !! function, which are subsequently stored in the derived flow
582+ !! quantity storage variable, q_sf.
583+ !! @param q_prim_vf Primitive variables
584+ !! @param q_sf Q_M
585+ subroutine s_derive_qm(q_prim_vf,q_sf)
586+ type(scalar_field), &
581587 dimension(sys_size), &
582588 intent(IN) :: q_prim_vf
583589
@@ -590,71 +596,73 @@ subroutine s_derive_qm(q_prim_vf,q_sf)
590596 real(kind(0d0)), &
591597 dimension(1:3, 1:3) :: q_jacobian_sf, S, S2, O, O2
592598
593- real (kind (0d0 )) :: trS, trS2, trO2, Q, IIS
599+ real(kind(0d0)) :: trS, trS2, trO2, Q, IIS
594600 integer :: j, k, l, r, jj, kk !< Generic loop iterators
595601
596602 do l = -offset_z%beg, p + offset_z%end
597603 do k = -offset_y%beg, n + offset_y%end
598604 do j = -offset_x%beg, m + offset_x%end
599605
600- ! Get velocity gradient tensor
606+ ! Get velocity gradient tensor
601607 q_jacobian_sf(:, :) = 0d0
602-
608+
603609 do r = -fd_number, fd_number
604- do jj = 1 , 3
605- ! d()/dx
606- q_jacobian_sf(jj, 1 ) = &
607- q_jacobian_sf(jj, 1 )+ &
608- fd_coeff_x(r, j)* &
609- q_prim_vf(mom_idx% beg+ jj-1 )% sf(r + j, k, l)
610- ! d()/dy
611- q_jacobian_sf(jj, 2 ) = &
612- q_jacobian_sf(jj, 2 )+ &
613- fd_coeff_y(r, k)* &
614- q_prim_vf(mom_idx% beg+ jj-1 )% sf(j, r + k, l)
615- ! d()/dz
616- q_jacobian_sf(jj, 3 ) = &
617- q_jacobian_sf(jj, 3 )+ &
618- fd_coeff_z(r, l)* &
619- q_prim_vf(mom_idx% beg+ jj-1 )% sf(j, k, r + l)
620- end do
621- end do
622-
623- ! Decompose J into asymmetric matrix, S, and a skew-symmetric matrix, O
624- do jj = 1 , 3
625- do kk = 1 , 3
626- S(jj, kk) = 0.5D0 * &
627- (q_jacobian_sf(jj, kk) + q_jacobian_sf(kk, jj))
628- O(jj, kk) = 0.5D0 * &
629- (q_jacobian_sf(jj, kk) - q_jacobian_sf(kk, jj))
630- end do
631- end do
632-
633- ! Compute S2 = S*S'
634- do jj = 1 , 3
635- do kk = 1 , 3
636- O2(jj, kk) = O(jj,1 )* O(kk,1 )+ &
637- O(jj,2 )* O(kk,2 )+ &
638- O(jj,3 )* O(kk,3 )
639- S2(jj, kk) = S(jj,1 )* S(kk,1 )+ &
640- S(jj,2 )* S(kk,2 )+ &
641- S(jj,3 )* S(kk,3 )
642- end do
643- end do
644-
645- ! Compute Q
646- Q = 0.5 * ((O2(1 ,1 )+ O2(2 ,2 )+ O2(3 ,3 ))- &
647- (S2(1 ,1 )+ S2(2 ,2 )+ S2(3 ,3 )))
648- trS = S(1 ,1 )+ S(2 ,2 )+ S(3 ,3 )
649- IIS = 0.5 * ((S(1 ,1 )+ S(2 ,2 )+ S(3 ,3 ))** 2 - &
650- (S2(1 ,1 )+ S2(2 ,2 )+ S2(3 ,3 )))
651- q_sf(j, k, l) = Q+ IIS
610+ do jj = 1, 3
611+ ! d()/dx
612+ q_jacobian_sf(jj, 1) = &
613+ q_jacobian_sf(jj, 1)+ &
614+ fd_coeff_x(r, j)* &
615+ q_prim_vf(mom_idx%beg+jj-1)%sf(r + j, k, l)
616+ ! d()/dy
617+ q_jacobian_sf(jj, 2) = &
618+ q_jacobian_sf(jj, 2)+ &
619+ fd_coeff_y(r, k)* &
620+ q_prim_vf(mom_idx%beg+jj-1)%sf(j, r + k, l)
621+ ! d()/dz
622+ q_jacobian_sf(jj, 3) = &
623+ q_jacobian_sf(jj, 3)+ &
624+ fd_coeff_z(r, l)* &
625+ q_prim_vf(mom_idx%beg+jj-1)%sf(j, k, r + l)
626+ end do
627+ end do
628+
629+ ! Decompose J into asymmetric matrix, S, and a skew-symmetric matrix, O
630+ do jj = 1, 3
631+ do kk = 1, 3
632+ S(jj, kk) = 0.5D0* &
633+ (q_jacobian_sf(jj, kk) + q_jacobian_sf(kk, jj))
634+ O(jj, kk) = 0.5D0* &
635+ (q_jacobian_sf(jj, kk) - q_jacobian_sf(kk, jj))
636+ end do
637+ end do
638+
639+ ! Compute S2 = S*S'
640+ do jj = 1 , 3
641+ do kk = 1 , 3
642+ O2(jj, kk) = O(jj,1 )* O(kk,1 )+ &
643+ O(jj,2 )* O(kk,2 )+ &
644+ O(jj,3 )* O(kk,3 )
645+ S2(jj, kk) = S(jj,1 )* S(kk,1 )+ &
646+ S(jj,2 )* S(kk,2 )+ &
647+ S(jj,3 )* S(kk,3 )
648+ end do
649+ end do
650+
651+ ! Compute Q
652+ Q = 0.5 * ((O2(1 ,1 )+ O2(2 ,2 )+ O2(3 ,3 ))- &
653+ (S2(1 ,1 )+ S2(2 ,2 )+ S2(3 ,3 )))
654+ trS = S(1 ,1 )+ S(2 ,2 )+ S(3 ,3 )
655+ IIS = 0.5 * ((S(1 ,1 )+ S(2 ,2 )+ S(3 ,3 ))** 2 - &
656+ (S2(1 ,1 )+ S2(2 ,2 )+ S2(3 ,3 )))
657+ q_sf(j, k, l) = Q+ IIS
652658
653659 end do
654660 end do
655- end do
661+ end do
662+
663+ end subroutine s_derive_qm
656664
657- end subroutine s_derive_qm
665+ @:s_compute_speed_of_sound()
658666
659667 !> This subroutine gets as inputs the conservative variables
660668 !! and density. From those inputs, it proceeds to calculate
@@ -833,4 +841,4 @@ subroutine s_finalize_derived_variables_module() ! -------------------
833841
834842 end subroutine s_finalize_derived_variables_module ! -----------------
835843
836- end module m_derived_variables
844+ end module m_derived_variables
0 commit comments