1# 1 "/home/runner/work/MFC/MFC/src/post_process/m_derived_variables.fpp"
14 use m_mpi_proxy !< message passing interface (mpi) module proxy
34 real(wp),
allocatable,
dimension(:, :, :) ::
gm_rho_sf
44 real(wp),
allocatable,
dimension(:, :),
public ::
fd_coeff_x
45 real(wp),
allocatable,
dimension(:, :),
public ::
fd_coeff_y
46 real(wp),
allocatable,
dimension(:, :),
public ::
fd_coeff_z
49 integer,
private ::
flg
121 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
122 intent(inout) :: q_sf
146 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
147 intent(inout) :: q_sf
173 dimension(sys_size), &
174 intent(in) :: q_prim_vf
177 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
178 intent(inout) :: q_sf
183 real(wp) :: blkmod1, blkmod2
194 q_prim_vf(
e_idx)%sf(i,
j,
k) + &
198 blkmod1 = ((
gammas(1) + 1._wp)*q_prim_vf(
e_idx)%sf(i,
j,
k) + &
200 blkmod2 = ((
gammas(2) + 1._wp)*q_prim_vf(
e_idx)%sf(i,
j,
k) + &
203 (1._wp - q_prim_vf(
adv_idx%beg)%sf(i,
j,
k))/blkmod2)))
207 q_sf(i,
j,
k) = 1.e-16_wp
209 q_sf(i,
j,
k) = sqrt(q_sf(i,
j,
k))
227 integer,
intent(in) :: i
229 type(
scalar_field),
dimension(sys_size),
intent(in) :: q_prim_vf
231 real(wp),
dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
232 intent(inout) :: q_sf
234 real(wp) :: top, bottom, slope
241 if (q_prim_vf(
cont_idx%end + i)%sf(
j,
k,
l) >= 0._wp)
then
244 bottom = q_prim_vf(
adv_idx%beg)%sf(
j + 1,
k,
l) - &
247 top = q_prim_vf(
adv_idx%beg)%sf(
j + 2,
k,
l) - &
249 bottom = q_prim_vf(
adv_idx%beg)%sf(
j + 1,
k,
l) - &
253 if (q_prim_vf(
cont_idx%end + i)%sf(
j,
k,
l) >= 0._wp)
then
256 bottom = q_prim_vf(
adv_idx%beg)%sf(
j,
k + 1,
l) - &
259 top = q_prim_vf(
adv_idx%beg)%sf(
j,
k + 2,
l) - &
261 bottom = q_prim_vf(
adv_idx%beg)%sf(
j,
k + 1,
l) - &
265 if (q_prim_vf(
cont_idx%end + i)%sf(
j,
k,
l) >= 0._wp)
then
268 bottom = q_prim_vf(
adv_idx%beg)%sf(
j,
k,
l + 1) - &
271 top = q_prim_vf(
adv_idx%beg)%sf(
j,
k,
l + 2) - &
273 bottom = q_prim_vf(
adv_idx%beg)%sf(
j,
k,
l + 1) - &
278 if (abs(top) < 1.e-8_wp) top = 0._wp
279 if (abs(bottom) < 1.e-8_wp) bottom = 0._wp
288 slope = (top*bottom)/(bottom**2._wp + 1.e-16_wp)
293 q_sf(
j,
k,
l) = max(0._wp, min(1._wp, slope))
295 q_sf(
j,
k,
l) = max(0._wp, min(2._wp*slope, 5.e-1_wp*(1._wp + slope), 2._wp))
297 q_sf(
j,
k,
l) = (15.e-1_wp*(slope**2._wp + slope))/(slope**2._wp + slope + 1._wp)
299 q_sf(
j,
k,
l) = max(0._wp, min(1._wp, 2._wp*slope), min(slope, 2._wp))
301 q_sf(
j,
k,
l) = max(0._wp, min(15.e-1_wp*slope, 1._wp), min(slope, 15.e-1_wp))
303 q_sf(
j,
k,
l) = (slope**2._wp + slope)/(slope**2._wp + 1._wp)
305 q_sf(
j,
k,
l) = (abs(slope) + slope)/(1._wp + abs(slope))
319 integer,
intent(in) :: ndim
320 real(wp),
dimension(ndim, ndim),
intent(inout) :: a
321 real(wp),
dimension(ndim),
intent(inout) :: b
322 real(wp),
dimension(ndim),
intent(out) :: sol
332 j = i - 1 + maxloc(abs(a(i:ndim, i)), 1)
341 a(i, :) = a(i, :)/a(i, i)
343 b(k) = b(k) - a(k, i)*b(i)
344 a(k, :) = a(k, :) - a(k, i)*a(i, :)
352 sol(i) = sol(i) - a(i, k)*sol(k)
369 integer,
intent(in) :: i
372 dimension(sys_size), &
373 intent(in) :: q_prim_vf
376 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
377 intent(inout) :: q_sf
379 integer ::
j,
k,
l, r
387 q_sf(
j,
k,
l) = 0._wp
416 q_sf(
j,
k,
l) = 0._wp
444 q_sf(
j,
k,
l) = 0._wp
469 dimension(sys_size), &
470 intent(in) :: q_prim_vf
473 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
474 intent(inout) :: q_sf
477 dimension(1:3, 1:3) :: q_jacobian_sf, s, s2, o, o2
479 real(wp) :: trs, q, iis
480 integer ::
j,
k,
l, r, jj, kk
487 q_jacobian_sf(:, :) = 0._wp
492 q_jacobian_sf(jj, 1) = &
493 q_jacobian_sf(jj, 1) + &
495 q_prim_vf(
mom_idx%beg + jj - 1)%sf(r +
j,
k,
l)
497 q_jacobian_sf(jj, 2) = &
498 q_jacobian_sf(jj, 2) + &
500 q_prim_vf(
mom_idx%beg + jj - 1)%sf(
j, r +
k,
l)
502 q_jacobian_sf(jj, 3) = &
503 q_jacobian_sf(jj, 3) + &
505 q_prim_vf(
mom_idx%beg + jj - 1)%sf(
j,
k, r +
l)
512 s(jj, kk) = 0.5_wp* &
513 (q_jacobian_sf(jj, kk) + q_jacobian_sf(kk, jj))
514 o(jj, kk) = 0.5_wp* &
515 (q_jacobian_sf(jj, kk) - q_jacobian_sf(kk, jj))
522 o2(jj, kk) = o(jj, 1)*o(kk, 1) + &
523 o(jj, 2)*o(kk, 2) + &
525 s2(jj, kk) = s(jj, 1)*s(kk, 1) + &
526 s(jj, 2)*s(kk, 2) + &
532 q = 0.5_wp*((o2(1, 1) + o2(2, 2) + o2(3, 3)) - &
533 (s2(1, 1) + s2(2, 2) + s2(3, 3)))
534 trs = s(1, 1) + s(2, 2) + s(3, 3)
535 iis = 0.5_wp*((s(1, 1) + s(2, 2) + s(3, 3))**2 - &
536 (s2(1, 1) + s2(2, 2) + s2(3, 3)))
537 q_sf(
j,
k,
l) = q + iis
550 integer,
parameter :: nm = 3
552 dimension(sys_size), &
553 intent(in) :: q_prim_vf
556 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
557 intent(out) :: liutex_mag
560 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end, nm), &
561 intent(out) :: liutex_axis
563 character,
parameter :: ivl =
'N'
564 character,
parameter :: ivr =
'V'
565 real(wp),
dimension(nm, nm) :: vgt
566 real(wp),
dimension(nm) :: lr, li
567 real(wp),
dimension(nm, nm) :: vl, vr
568 integer,
parameter :: lwork = 4*nm
569 real(wp),
dimension(lwork) :: work
572 real(wp),
dimension(nm) :: eigvec
573 real(wp) :: eigvec_mag
574 real(wp) :: omega_proj
578 integer ::
j,
k,
l, r, i
594 q_prim_vf(
mom_idx%beg + i - 1)%sf(r +
j,
k,
l)
599 q_prim_vf(
mom_idx%beg + i - 1)%sf(
j, r +
k,
l)
604 q_prim_vf(
mom_idx%beg + i - 1)%sf(
j,
k, r +
l)
609#ifdef MFC_SINGLE_PRECISION
610 call sgeev(ivl, ivr, nm, vgt, nm, lr, li, vl, nm, vr, nm, work, lwork, info)
612 call dgeev(ivl, ivr, nm, vgt, nm, lr, li, vl, nm, vr, nm, work, lwork, info)
618 if (abs(li(r)) < abs(li(idx)))
then
625 eigvec_mag = sqrt(eigvec(1)**2._wp &
628 if (eigvec_mag > sgm_eps)
then
629 eigvec = eigvec/eigvec_mag
635 omega_proj = (vgt(3, 2) - vgt(2, 3))*eigvec(1) &
636 + (vgt(1, 3) - vgt(3, 1))*eigvec(2) &
637 + (vgt(2, 1) - vgt(1, 2))*eigvec(3)
641 if (omega_proj < 0._wp)
then
643 omega_proj = -omega_proj
647 lci = li(mod(idx, 3) + 1)
650 alpha = omega_proj**2._wp - 4._wp*lci**2._wp
651 if (alpha > 0._wp)
then
652 liutex_mag(
j,
k,
l) = omega_proj - sqrt(alpha)
654 liutex_mag(
j,
k,
l) = omega_proj
658 liutex_axis(
j,
k,
l, 1) = eigvec(1)
659 liutex_axis(
j,
k,
l, 2) = eigvec(2)
660 liutex_axis(
j,
k,
l, 3) = eigvec(3)
678 dimension(sys_size), &
682 dimension(-offset_x%beg:m + offset_x%end, &
-offset_y%beg:n + offset_y%end, &
-offset_z%beg:p + offset_z%end), &
683 intent(inout) :: q_sf
685 real(wp) :: drho_dx, drho_dy, drho_dz
688 real(wp),
dimension(2) :: gm_rho_max
694 integer :: i,
j,
k,
l
757 if (
num_procs > 1)
call s_mpi_reduce_maxloc(gm_rho_max)
777 q_sf(
j,
k,
l) = 0._wp
type(scalar_field), dimension(sys_size), intent(inout) q_cons_vf
Shared derived types for field data, patch geometry, bubble dynamics, and MPI I/O structures.
Computes derived flow quantities (sound speed, vorticity, Schlieren, etc.) from conservative and prim...
subroutine s_solve_linear_system(a, b, sol, ndim)
Computes the solution to the linear system Ax=b w/ sol = x.
real(wp), dimension(:, :), allocatable, public fd_coeff_z
integer, private flg
Flagging (flg) variable used to annotate the dimensionality of the dataset that is undergoing the pos...
real(wp), dimension(:, :), allocatable, public fd_coeff_y
impure subroutine, public s_derive_liutex(q_prim_vf, liutex_mag, liutex_axis)
This subroutine gets as inputs the primitive variables. From those inputs, it proceeds to calculate t...
subroutine, public s_derive_specific_heat_ratio(q_sf)
This subroutine receives as input the specific heat ratio function, gamma_sf, and derives from it the...
subroutine, public s_derive_liquid_stiffness(q_sf)
This subroutine admits as inputs the specific heat ratio function and the liquid stiffness function,...
real(wp), dimension(:, :, :), allocatable gm_rho_sf
Gradient magnitude (gm) of the density for each cell of the computational sub-domain....
impure subroutine, public s_initialize_derived_variables_module
Computation of parameters, allocation procedures, and/or any other tasks needed to properly setup the...
real(wp), dimension(:, :), allocatable, public fd_coeff_x
subroutine, public s_derive_vorticity_component(i, q_prim_vf, q_sf)
This subroutine receives as inputs the indicator of the component of the vorticity that should be out...
subroutine, public s_derive_sound_speed(q_prim_vf, q_sf)
This subroutine admits as inputs the primitive variables, the density, the specific heat ratio functi...
impure subroutine, public s_derive_numerical_schlieren_function(q_cons_vf, q_sf)
This subroutine gets as inputs the conservative variables and density. From those inputs,...
subroutine, public s_derive_flux_limiter(i, q_prim_vf, q_sf)
This subroutine derives the flux_limiter at cell boundary i+1/2. This is an approximation because the...
impure subroutine, public s_finalize_derived_variables_module
Deallocation procedures for the module.
subroutine, public s_derive_qm(q_prim_vf, q_sf)
This subroutine gets as inputs the primitive variables. From those inputs, it proceeds to calculate t...
Global parameters for the post-process: domain geometry, equation of state, and output database setti...
type(int_bounds_info) offset_y
type(int_bounds_info) mom_idx
Indexes of first & last momentum eqns.
real(wp), dimension(num_fluids_max) schlieren_alpha
Amplitude coefficients of the numerical Schlieren function that are used to adjust the intensity of n...
real(wp), dimension(:), allocatable y_cc
integer proc_rank
Rank of the local processor.
logical mixture_err
Mixture error limiter.
logical alt_soundspeed
Alternate sound speed.
type(int_bounds_info) cont_idx
Indexes of first & last continuity eqns.
integer fd_number
The finite-difference number is given by MAX(1, fd_order/2). Essentially, it is a measure of the half...
integer model_eqns
Multicomponent flow model.
type(int_bounds_info) offset_x
logical, dimension(3) omega_wrt
integer num_procs
Number of processors.
type(int_bounds_info) adv_idx
Indexes of first & last advection eqns.
type(int_bounds_info) offset_z
integer e_idx
Index of energy equation.
Basic floating-point utilities: approximate equality, default detection, and coordinate bounds.
logical elemental function, public f_approx_equal(a, b, tol_input)
This procedure checks if two floating point numbers of wp are within tolerance.
MPI gather and scatter operations for distributing post-process grid and flow-variable data.
Conservative-to-primitive variable conversion, mixture property evaluation, and pressure computation.
real(wp), dimension(:), allocatable, public gammas
real(wp), dimension(:, :, :), allocatable, public pi_inf_sf
Scalar liquid stiffness function.
subroutine s_compute_speed_of_sound(pres, rho, gamma, pi_inf, h, adv, vel_sum, c_c, c, qv)
Computes the speed of sound from thermodynamic state variables, supporting multiple equation-of-state...
real(wp), dimension(:, :, :), allocatable, public rho_sf
Scalar density function.
real(wp), dimension(:, :, :), allocatable, public gamma_sf
Scalar sp. heat ratio function.
real(wp), dimension(:), allocatable, public pi_infs
Derived type annexing a scalar field (SF).