From 0ab85c095a7433e0ddad275460e2ca5653d96b3c Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sat, 12 Sep 2026 21:35:51 -0500 Subject: [PATCH] Remove the fluid center-of-mass output, which no case can ask for or turn off --- src/simulation/m_data_output.fpp | 86 +----------- src/simulation/m_derived_variables.fpp | 174 +------------------------ 2 files changed, 6 insertions(+), 254 deletions(-) diff --git a/src/simulation/m_data_output.fpp b/src/simulation/m_data_output.fpp index 57f7eaf9fa..d8cd932c42 100644 --- a/src/simulation/m_data_output.fpp +++ b/src/simulation/m_data_output.fpp @@ -24,13 +24,10 @@ module m_data_output implicit none private - public :: s_initialize_data_output_module, s_open_run_time_information_file, s_open_com_files, s_open_probe_files, & + public :: s_initialize_data_output_module, s_open_run_time_information_file, s_open_probe_files, & & s_write_run_time_information, s_write_data_files, s_write_serial_data_files, s_write_parallel_data_files, & - & s_write_ib_data_file, s_write_com_files, s_write_probe_files, s_write_ib_state_file, s_close_run_time_information_file, & - & s_close_com_files, s_close_probe_files, s_finalize_data_output_module - - real(wp), public, allocatable, dimension(:,:) :: c_mass - $:GPU_DECLARE(create='[c_mass]') + & s_write_ib_data_file, s_write_probe_files, s_write_ib_state_file, s_close_run_time_information_file, & + & s_close_probe_files, s_finalize_data_output_module !> @name ICFL, VCFL, CCFL, and Rc stability criteria extrema over all the time-steps !> @{ @@ -108,31 +105,6 @@ contains end subroutine s_open_run_time_information_file - !> Open center-of-mass data files for writing - impure subroutine s_open_com_files() - - character(len=path_len + 3*name_len) :: file_path !< Relative path to the CoM file in the case directory - integer :: i !< Generic loop iterator - - do i = 1, num_fluids - write (file_path, '(A,I0,A)') '/fluid', i, '_com.dat' - file_path = trim(case_dir) // trim(file_path) - open (i + 120, file=trim(file_path), form='formatted', position='append', status='unknown') - if (n == 0) then - write (i + 120, '(A)') ' Non-Dimensional Time ' // ' Total Mass ' // ' x-loc ' // ' Total Volume ' - else if (p == 0) then - write (i + 120, & - & '(A)') ' Non-Dimensional Time ' // ' Total Mass ' // ' x-loc ' // ' y-loc ' & - & // ' Total Volume ' - else - write (i + 120, & - & '(A)') ' Non-Dimensional Time ' // ' Total Mass ' // ' x-loc ' // ' y-loc ' // ' z-loc ' & - & // ' Total Volume ' - end if - end do - - end subroutine s_open_com_files - !> Open flow probe data files for writing impure subroutine s_open_probe_files @@ -1115,39 +1087,6 @@ contains end subroutine s_write_ib_state_file - !> Write center-of-mass data at the current time step - impure subroutine s_write_com_files(t_step, c_mass_in) - - integer, intent(in) :: t_step - real(wp), dimension(num_fluids, 5), intent(in) :: c_mass_in - integer :: i !< Generic loop iterator - real(wp) :: nondim_time !< Non-dimensional time - - if (t_step_old /= dflt_int) then - nondim_time = real(t_step + t_step_old, wp)*dt - else - nondim_time = real(t_step, wp)*dt - end if - - if (proc_rank == 0) then - if (n == 0) then - do i = 1, num_fluids - write (i + 120, '(6X,4F24.12)') nondim_time, c_mass_in(i, 1), c_mass_in(i, 2), c_mass_in(i, 5) - end do - else if (p == 0) then - do i = 1, num_fluids - write (i + 120, '(6X,5F24.12)') nondim_time, c_mass_in(i, 1), c_mass_in(i, 2), c_mass_in(i, 3), c_mass_in(i, 5) - end do - else - do i = 1, num_fluids - write (i + 120, '(6X,6F24.12)') nondim_time, c_mass_in(i, 1), c_mass_in(i, 2), c_mass_in(i, 3), c_mass_in(i, & - & 4), c_mass_in(i, 5) - end do - end if - end if - - end subroutine s_write_com_files - !> Write flow probe data at the current time step impure subroutine s_write_probe_files(t_step, q_cons_vf, accel_mag) @@ -1632,17 +1571,6 @@ contains end subroutine s_close_run_time_information_file - !> Closes communication files - impure subroutine s_close_com_files() - - integer :: i !< Generic loop iterator - - do i = 1, num_fluids - close (i + 120) - end do - - end subroutine s_close_com_files - !> Closes probe files impure subroutine s_close_probe_files @@ -1670,10 +1598,6 @@ contains end if end if - if (probe_wrt) then - @:ALLOCATE(c_mass(num_fluids,5)) - end if - if (down_sample) then m_ds = int((m + 1)/3) - 1 n_ds = int((n + 1)/3) - 1 @@ -1692,10 +1616,6 @@ contains integer :: i - if (probe_wrt) then - @:DEALLOCATE(c_mass) - end if - if (down_sample) then do i = 1, sys_size deallocate (q_cons_temp_ds(i)%sf) diff --git a/src/simulation/m_derived_variables.fpp b/src/simulation/m_derived_variables.fpp index 6a4b92ddce..ec0def1d36 100644 --- a/src/simulation/m_derived_variables.fpp +++ b/src/simulation/m_derived_variables.fpp @@ -10,7 +10,6 @@ module m_derived_variables use m_derived_types use m_global_parameters - use m_mpi_proxy use m_data_output use m_compile_specific use m_helper @@ -67,7 +66,6 @@ contains ! Opening and writing header of flow probe files if (proc_rank == 0 .and. probe_wrt) then call s_open_probe_files() - call s_open_com_files() end if ! Computing centered finite difference coefficients call s_compute_finite_difference_coefficients(m, x_cc, fd_coeff_x, buff_size, fd_number, fd_order) @@ -122,11 +120,7 @@ contains $:GPU_UPDATE(host='[accel_mag]') - call s_derive_center_of_mass(q_prim_ts2(2)%vf, c_mass) - call s_write_probe_files(t_step, q_cons_vf, accel_mag) - - call s_write_com_files(t_step, c_mass) end if end subroutine s_compute_derived_variables @@ -336,174 +330,12 @@ contains end subroutine s_derive_acceleration_component - !> Compute the center of mass for each fluid from the primitive variables - impure subroutine s_derive_center_of_mass(q_vf, c_m) - - type(scalar_field), dimension(sys_size), intent(in) :: q_vf - real(wp), dimension(1:num_fluids,1:5), intent(inout) :: c_m - integer :: i, j, k, l !< Generic loop iterators - real(wp) :: tmp, tmp_out !< Temporary variable to store quantity for mpi_allreduce - real(wp) :: dV !< Discrete cell volume - - c_m(:,:) = 0.0_wp - - $:GPU_UPDATE(device='[c_m]') - - if (n == 0) then ! 1D simulation - $:GPU_PARALLEL_LOOP(collapse=3,private='[j, k, l, dV]') - do l = 0, p ! Loop over grid - do k = 0, n - do j = 0, m - $:GPU_LOOP(parallelism='[seq]') - do i = 1, num_fluids ! Loop over individual fluids - dV = dx(j) - ! Mass - $:GPU_ATOMIC(atomic='update') - c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! x-location weighted - $:GPU_ATOMIC(atomic='update') - c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! Volume fraction - $:GPU_ATOMIC(atomic='update') - c_m(i, 5) = c_m(i, 5) + q_vf(i + eqn_idx%adv%beg - 1)%sf(j, k, l)*dV - end do - end do - end do - end do - $:END_GPU_PARALLEL_LOOP() - else if (p == 0) then ! 2D simulation - $:GPU_PARALLEL_LOOP(collapse=3,private='[j, k, l, dV]') - do l = 0, p ! Loop over grid - do k = 0, n - do j = 0, m - $:GPU_LOOP(parallelism='[seq]') - do i = 1, num_fluids ! Loop over individual fluids - dV = dx(j)*dy(k) - ! Mass - $:GPU_ATOMIC(atomic='update') - c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! x-location weighted - $:GPU_ATOMIC(atomic='update') - c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! y-location weighted - $:GPU_ATOMIC(atomic='update') - c_m(i, 3) = c_m(i, 3) + q_vf(i)%sf(j, k, l)*dV*y_cc(k) - ! Volume fraction - $:GPU_ATOMIC(atomic='update') - c_m(i, 5) = c_m(i, 5) + q_vf(i + eqn_idx%adv%beg - 1)%sf(j, k, l)*dV - end do - end do - end do - end do - $:END_GPU_PARALLEL_LOOP() - else ! 3D simulation - $:GPU_PARALLEL_LOOP(collapse=3,private='[j, k, l, dV]') - do l = 0, p ! Loop over grid - do k = 0, n - do j = 0, m - $:GPU_LOOP(parallelism='[seq]') - do i = 1, num_fluids ! Loop over individual fluids - dV = dx(j)*dy(k)*dz(l) - ! Mass - $:GPU_ATOMIC(atomic='update') - c_m(i, 1) = c_m(i, 1) + q_vf(i)%sf(j, k, l)*dV - ! x-location weighted - $:GPU_ATOMIC(atomic='update') - c_m(i, 2) = c_m(i, 2) + q_vf(i)%sf(j, k, l)*dV*x_cc(j) - ! y-location weighted - $:GPU_ATOMIC(atomic='update') - c_m(i, 3) = c_m(i, 3) + q_vf(i)%sf(j, k, l)*dV*y_cc(k) - ! z-location weighted - $:GPU_ATOMIC(atomic='update') - c_m(i, 4) = c_m(i, 4) + q_vf(i)%sf(j, k, l)*dV*z_cc(l) - ! Volume fraction - $:GPU_ATOMIC(atomic='update') - c_m(i, 5) = c_m(i, 5) + q_vf(i + eqn_idx%adv%beg - 1)%sf(j, k, l)*dV - end do - end do - end do - end do - $:END_GPU_PARALLEL_LOOP() - end if - - $:GPU_UPDATE(host='[c_m]') - - if (n == 0) then ! 1D simulation - do i = 1, num_fluids ! Loop over individual fluids - ! Sum all components across all processors using MPI_ALLREDUCE - if (num_procs > 1) then - tmp = c_m(i, 1) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 1) = tmp_out - tmp = c_m(i, 2) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 2) = tmp_out - tmp = c_m(i, 5) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 5) = tmp_out - end if - ! Compute quotients - c_m(i, 2) = c_m(i, 2)/c_m(i, 1) - end do - else if (p == 0) then ! 2D simulation - do i = 1, num_fluids ! Loop over individual fluids - ! Sum all components across all processors using MPI_ALLREDUCE - if (num_procs > 1) then - tmp = c_m(i, 1) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 1) = tmp_out - tmp = c_m(i, 2) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 2) = tmp_out - tmp = c_m(i, 3) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 3) = tmp_out - tmp = c_m(i, 5) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 5) = tmp_out - end if - ! Compute quotients - c_m(i, 2) = c_m(i, 2)/c_m(i, 1) - c_m(i, 3) = c_m(i, 3)/c_m(i, 1) - end do - else ! 3D simulation - do i = 1, num_fluids ! Loop over individual fluids - ! Sum all components across all processors using MPI_ALLREDUCE - if (num_procs > 1) then - tmp = c_m(i, 1) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 1) = tmp_out - tmp = c_m(i, 2) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 2) = tmp_out - tmp = c_m(i, 3) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 3) = tmp_out - tmp = c_m(i, 4) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 4) = tmp_out - tmp = c_m(i, 5) - call s_mpi_allreduce_sum(tmp, tmp_out) - c_m(i, 5) = tmp_out - end if - ! Compute quotients - c_m(i, 2) = c_m(i, 2)/c_m(i, 1) - c_m(i, 3) = c_m(i, 3)/c_m(i, 1) - c_m(i, 4) = c_m(i, 4)/c_m(i, 1) - end do - end if - - end subroutine s_derive_center_of_mass - !> Deallocation procedures for the module impure subroutine s_finalize_derived_variables_module - ! Closing CoM and flow probe files - if (proc_rank == 0) then - call s_close_com_files() - if (probe_wrt) then - call s_close_probe_files() - end if + ! Closing flow probe files + if (proc_rank == 0 .and. probe_wrt) then + call s_close_probe_files() end if if (probe_wrt .or. ib) then