From e24624830bb009459d4f57c1bc7c48d299793114 Mon Sep 17 00:00:00 2001 From: ChrisZYJ Date: Sat, 21 Dec 2024 22:45:17 -0800 Subject: [PATCH 1/4] output partial --- src/post_process/m_data_output.fpp | 83 ++++++++++-- src/post_process/m_global_parameters.fpp | 23 ++++ src/post_process/m_mpi_proxy.fpp | 6 +- src/post_process/m_start_up.f90 | 153 ++++++----------------- toolchain/mfc/run/case_dicts.py | 4 + 5 files changed, 148 insertions(+), 121 deletions(-) diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index 959d8ba14b..21276fe987 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -28,6 +28,7 @@ module m_data_output implicit none private; public :: s_initialize_data_output_module, & + s_define_output_region, & s_open_formatted_database_file, & s_open_intf_data_file, & s_open_energy_data_file, & @@ -354,6 +355,9 @@ contains ! Pressure if (pres_wrt .or. prim_vars_wrt) dbvars = dbvars + 1 + ! Elastic stresses + if (hypoelasticity) dbvars = dbvars + (num_dims*(num_dims + 1))/2 + ! Volume fraction(s) if ((model_eqns == 2) .or. (model_eqns == 3)) then @@ -419,6 +423,41 @@ contains end subroutine s_initialize_data_output_module ! -------------------------- + subroutine s_define_output_region + + integer :: i + integer :: lower_bound, upper_bound + + #:for X, M in [('x', 'm'), ('y', 'n'), ('z', 'p')] + + if (${M}$ == 0) return ! Early return for y or z if simulation is 1D or 2D + + lower_bound = -offset_${X}$%beg + upper_bound = ${M}$ + offset_${X}$%end + + do i = lower_bound, upper_bound + if (${X}$_cc(i) > ${X}$_output%beg) then + ${X}$_output_idx%beg = i + offset_${X}$%beg + exit + end if + end do + + do i = upper_bound, lower_bound, -1 + if (${X}$_cc(i) < ${X}$_output%end) then + ${X}$_output_idx%end = i + offset_${X}$%beg + exit + end if + end do + + ! If no grid points are within the output region + if ((${X}$_cc(lower_bound) > ${X}$_output%end) .or. (${X}$_cc(upper_bound) < ${X}$_output%beg)) then + call s_mpi_abort('No grid points are within the output region. Exiting ...') + end if + + #:endfor + + end subroutine s_define_output_region + subroutine s_open_formatted_database_file(t_step) ! -------------------- ! Description: This subroutine opens a new formatted database file, or ! replaces an old one, and readies it for the data storage @@ -509,7 +548,14 @@ contains ! file by describing in it the dimensionality of post-processed ! data as well as the total number of flow variable(s) that will ! eventually be stored in it - write (dbfile) m, n, p, dbvars + if (output_partial_domain) then + write (dbfile) x_output_idx%end - x_output_idx%beg, & + y_output_idx%end - y_output_idx%beg, & + z_output_idx%end - z_output_idx%beg, & + dbvars + else + write (dbfile) m, n, p, dbvars + end if ! Next, analogous steps to the ones above are carried out by the ! root process to create and setup the formatted database master @@ -528,7 +574,11 @@ contains '. Exiting ...') end if - write (dbroot) m_root, 0, 0, dbvars + if (output_partial_domain) then + write (dbroot) x_output_idx%end-x_output_idx%beg, 0, 0, dbvars + else + write (dbroot) m_root, 0, 0, dbvars + end if end if @@ -718,7 +768,13 @@ contains real(y_cb, sp), & real(z_cb, sp) else - write (dbfile) x_cb, y_cb, z_cb + if (output_partial_domain) then + write (dbfile) x_cb( x_output_idx%beg-1 : x_output_idx%end ), & + y_cb( y_output_idx%beg-1 : y_output_idx%end ), & + z_cb( z_output_idx%beg-1 : z_output_idx%end ) + else + write (dbfile) x_cb, y_cb, z_cb + end if end if elseif (n > 0) then @@ -726,7 +782,12 @@ contains write (dbfile) real(x_cb, sp), & real(y_cb, sp) else - write (dbfile) x_cb, y_cb + if (output_partial_domain) then + write (dbfile) x_cb( x_output_idx%beg-1 : x_output_idx%end ), & + y_cb( y_output_idx%beg-1 : y_output_idx%end ) + else + write (dbfile) x_cb, y_cb + end if end if ! One-dimensional local grid data is written to the formatted @@ -735,9 +796,13 @@ contains else if (precision == 1) then - write (dbfile) real(x_cb, wp) + write (dbfile) real(x_cb, sp) else - write (dbfile) x_cb + if (output_partial_domain) then + write (dbfile) x_cb( x_output_idx%beg-1 : x_output_idx%end ) + else + write (dbfile) x_cb + end if end if if (num_procs > 1) then @@ -750,7 +815,11 @@ contains if (precision == 1) then write (dbroot) real(x_root_cb, wp) else - write (dbroot) x_root_cb + if (output_partial_domain) then + write (dbroot) x_root_cb( x_output_idx%beg-1 : x_output_idx%end ) + else + write (dbroot) x_root_cb + end if end if end if diff --git a/src/post_process/m_global_parameters.fpp b/src/post_process/m_global_parameters.fpp index 25b2ddfa4e..4297d750b8 100644 --- a/src/post_process/m_global_parameters.fpp +++ b/src/post_process/m_global_parameters.fpp @@ -196,6 +196,11 @@ module m_global_parameters integer :: precision !< Floating point precision of the database file(s) + logical :: output_partial_domain !< Specify portion of domain to output for post-processing + + type(bounds_info) :: x_output, y_output, z_output !< Portion of domain to output for post-processing + type(int_bounds_info) :: x_output_idx, y_output_idx, z_output_idx !< Indices of domain to output for post-processing + !> @name Size of the ghost zone layer in the x-, y- and z-coordinate directions. !! The definition of the ghost zone layers is only necessary when using the !! Silo database file format in multidimensions. These zones provide VisIt @@ -422,6 +427,15 @@ contains ! IBM num_ibs = dflt_int + ! Output partial domain + output_partial_domain = .false. + x_output%beg = dflt_real + x_output%end = dflt_real + y_output%beg = dflt_real + y_output%end = dflt_real + z_output%beg = dflt_real + z_output%end = dflt_real + end subroutine s_assign_default_values_to_user_inputs !> Computation of parameters, allocation procedures, and/or @@ -682,6 +696,15 @@ contains species_idx%end = 1 end if + if (output_partial_domain) then + x_output_idx%beg = 0 + x_output_idx%end = 0 + y_output_idx%beg = 0 + y_output_idx%end = 0 + z_output_idx%beg = 0 + z_output_idx%end = 0 + end if + momxb = mom_idx%beg momxe = mom_idx%end advxb = adv_idx%beg diff --git a/src/post_process/m_mpi_proxy.fpp b/src/post_process/m_mpi_proxy.fpp index fca4533c31..d7927f4c63 100644 --- a/src/post_process/m_mpi_proxy.fpp +++ b/src/post_process/m_mpi_proxy.fpp @@ -170,7 +170,7 @@ contains & 'prim_vars_wrt', 'c_wrt', 'qm_wrt','schlieren_wrt', 'bubbles', 'qbmm', & & 'polytropic', 'polydisperse', 'file_per_process', 'relax', 'cf_wrt', & & 'adv_n', 'ib', 'cfl_adap_dt', 'cfl_const_dt', 'cfl_dt', & - & 'surface_tension', 'hyperelasticity' ] + & 'surface_tension', 'hyperelasticity', 'output_partial_domain' ] call MPI_BCAST(${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr) #:endfor @@ -191,7 +191,9 @@ contains end do #:for VAR in [ 'pref', 'rhoref', 'R0ref', 'poly_sigma', 'Web', 'Ca', & - & 'Re_inv', 'sigma', 't_save', 't_stop' ] + & 'Re_inv', 'sigma', 't_save', 't_stop', & + & 'x_output%beg', 'x_output%end', 'y_output%beg', & + & 'y_output%end', 'z_output%beg', 'z_output%end' ] call MPI_BCAST(${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr) #:endfor call MPI_BCAST(schlieren_alpha(1), num_fluids_max, mpi_p, 0, MPI_COMM_WORLD, ierr) diff --git a/src/post_process/m_start_up.f90 b/src/post_process/m_start_up.f90 index 6ce012b2b2..5e14b946b9 100644 --- a/src/post_process/m_start_up.f90 +++ b/src/post_process/m_start_up.f90 @@ -70,6 +70,7 @@ subroutine s_read_input_file num_fluids, mpp_lim, & weno_order, bc_x, & bc_y, bc_z, fluid_pp, format, precision, & + output_partial_domain, x_output, y_output, z_output, & hypoelasticity, G, & chem_wrt_Y, chem_wrt_T, avg_state, & alpha_rho_wrt, rho_wrt, mom_wrt, vel_wrt, & @@ -197,6 +198,25 @@ subroutine s_save_data(t_step, varname, pres, c, H) integer :: i, j, k, l + integer :: x_beg, x_end, y_beg, y_end, z_beg, z_end + + if (output_partial_domain) then + call s_define_output_region + x_beg = -offset_x%beg + x_output_idx%beg + x_end = offset_x%end + x_output_idx%end + y_beg = -offset_y%beg + y_output_idx%beg + y_end = offset_y%end + y_output_idx%end + z_beg = -offset_z%beg + z_output_idx%beg + z_end = offset_z%end + z_output_idx%end + else + x_beg = -offset_x%beg + x_end = offset_x%end + m + y_beg = -offset_y%beg + y_end = offset_y%end + n + z_beg = -offset_z%beg + z_end = offset_z%end + p + end if + ! Opening a new formatted database file call s_open_formatted_database_file(t_step) @@ -238,11 +258,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if ((model_eqns == 2) .or. (model_eqns == 3) .or. (model_eqns == 4)) then do i = 1, num_fluids if (alpha_rho_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then - - q_sf = q_cons_vf(i)%sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) if (model_eqns /= 4) then write (varname, '(A,I0)') 'alpha_rho', i else @@ -261,11 +277,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (rho_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then - - q_sf = rho_sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = rho_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'rho' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -277,12 +289,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! Adding the momentum to the formatted database file ------------------- do i = 1, E_idx - mom_idx%beg if (mom_wrt(i) .or. cons_vars_wrt) then - - q_sf = q_cons_vf(i + cont_idx%end)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_cons_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'mom', i call s_write_variable_to_formatted_database_file(varname, t_step) @@ -295,12 +302,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! Adding the velocity to the formatted database file ------------------- do i = 1, E_idx - mom_idx%beg if (vel_wrt(i) .or. prim_vars_wrt) then - - q_sf = q_prim_vf(i + cont_idx%end)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_prim_vf(i + cont_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'vel', i call s_write_variable_to_formatted_database_file(varname, t_step) @@ -314,10 +316,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (chemistry) then do i = 1, num_species if (chem_wrt_Y(i) .or. prim_vars_wrt) then - q_sf = q_prim_vf(chemxb + i - 1)%sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_prim_vf(chemxb + i - 1)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,A)') 'Y_', trim(species_names(i)) call s_write_variable_to_formatted_database_file(varname, t_step) @@ -327,10 +326,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) end do if (chem_wrt_T) then - q_sf = q_T_sf%sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_T_sf%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'T' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -354,11 +350,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! Adding the energy to the formatted database file --------------------- if (E_wrt .or. cons_vars_wrt) then - - q_sf = q_cons_vf(E_idx)%sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_cons_vf(E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'E' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -370,10 +362,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (elasticity) then do i = 1, stress_idx%end - stress_idx%beg + 1 if (prim_vars_wrt) then - q_sf = q_prim_vf(i - 1 + stress_idx%beg)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_prim_vf(i - 1 + stress_idx%beg)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'tau', i call s_write_variable_to_formatted_database_file(varname, t_step) end if @@ -383,10 +372,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (hyperelasticity) then do i = 1, xiend - xibeg + 1 if (prim_vars_wrt) then - q_sf = q_prim_vf(i - 1 + xibeg)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_prim_vf(i - 1 + xibeg)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'xi', i call s_write_variable_to_formatted_database_file(varname, t_step) end if @@ -398,11 +384,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! Adding the pressure to the formatted database file ------------------- if (pres_wrt .or. prim_vars_wrt) then - - q_sf = q_prim_vf(E_idx)%sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_prim_vf(E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'pres' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -418,12 +400,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) do i = 1, num_fluids - 1 if (alpha_wrt(i) .or. (cons_vars_wrt .or. prim_vars_wrt)) then - - q_sf = q_cons_vf(i + E_idx)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_cons_vf(i + E_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'alpha', i call s_write_variable_to_formatted_database_file(varname, t_step) @@ -435,12 +412,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (alpha_wrt(num_fluids) & .or. & (cons_vars_wrt .or. prim_vars_wrt)) then - - q_sf = q_cons_vf(adv_idx%end)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_cons_vf(adv_idx%end)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'alpha', num_fluids call s_write_variable_to_formatted_database_file(varname, t_step) @@ -455,11 +427,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (gamma_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then - - q_sf = gamma_sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = gamma_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'gamma' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -485,11 +453,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (pi_inf_wrt & .or. & (model_eqns == 1 .and. (cons_vars_wrt .or. prim_vars_wrt))) then - - q_sf = pi_inf_sf(-offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = pi_inf_sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'pi_inf' call s_write_variable_to_formatted_database_file(varname, t_step) @@ -602,23 +566,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! Adding the color function to formatted database file if (cf_wrt) then - q_sf = q_cons_vf(c_idx)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - - !do k = -offset_z%beg, p + offset_z%end - ! do j = -offset_y%beg, n + offset_y%end - ! do i = -offset_x%beg, m + offset_x%end - ! if (q_sf(i,j,k) > 0.5) then - ! q_sf(i,j,k) = 100000 + 8/0.15 - ! else - ! q_sf(i,j,k) = 100000 - ! end if - ! end do - ! end do - !end do - + q_sf = q_cons_vf(c_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'color_function' call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' @@ -629,11 +577,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! Adding the volume fraction(s) to the formatted database file --------- if (bubbles) then do i = adv_idx%beg, adv_idx%end - q_sf = q_cons_vf(i)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) - + q_sf = q_cons_vf(i)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I0)') 'alpha', i - E_idx call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' @@ -644,10 +588,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if (bubbles) then !nR do i = 1, nb - q_sf = q_cons_vf(bub_idx%rs(i))%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_cons_vf(bub_idx%rs(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I3.3)') 'nR', i call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' @@ -655,10 +596,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) !nRdot do i = 1, nb - q_sf = q_cons_vf(bub_idx%vs(i))%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_cons_vf(bub_idx%vs(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I3.3)') 'nV', i call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' @@ -666,10 +604,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) if ((polytropic .neqv. .true.) .and. (.not. qbmm)) then !nP do i = 1, nb - q_sf = q_cons_vf(bub_idx%ps(i))%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_cons_vf(bub_idx%ps(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I3.3)') 'nP', i call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' @@ -677,10 +612,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) !nM do i = 1, nb - q_sf = q_cons_vf(bub_idx%ms(i))%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_cons_vf(bub_idx%ms(i))%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A,I3.3)') 'nM', i call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' @@ -689,10 +621,7 @@ subroutine s_save_data(t_step, varname, pres, c, H) ! number density if (adv_n) then - q_sf = q_cons_vf(n_idx)%sf( & - -offset_x%beg:m + offset_x%end, & - -offset_y%beg:n + offset_y%end, & - -offset_z%beg:p + offset_z%end) + q_sf = q_cons_vf(n_idx)%sf(x_beg:x_end, y_beg:y_end, z_beg:z_end) write (varname, '(A)') 'n' call s_write_variable_to_formatted_database_file(varname, t_step) varname(:) = ' ' diff --git a/toolchain/mfc/run/case_dicts.py b/toolchain/mfc/run/case_dicts.py index 52854e4e2e..97609e014c 100644 --- a/toolchain/mfc/run/case_dicts.py +++ b/toolchain/mfc/run/case_dicts.py @@ -369,6 +369,7 @@ def analytic(self): 't_stop': ParamType.REAL, 'n_start': ParamType.INT, 'surface_tension': ParamType.LOG, + 'output_partial_domain': ParamType.LOG, }) for cmp_id in range(1,3+1): @@ -376,6 +377,9 @@ def analytic(self): POST_PROCESS[f'bc_{cmp}%beg'] = ParamType.INT POST_PROCESS[f'bc_{cmp}%end'] = ParamType.INT + + POST_PROCESS[f'{cmp}_output%beg'] = ParamType.REAL + POST_PROCESS[f'{cmp}_output%end'] = ParamType.REAL for real_attr in ["mom_wrt", "vel_wrt", "flux_wrt", "omega_wrt"]: POST_PROCESS[f'{real_attr}({cmp_id})'] = ParamType.LOG From 07147fc0fac8726650abc109112e5c671d822732 Mon Sep 17 00:00:00 2001 From: ChrisZYJ Date: Sat, 21 Dec 2024 23:03:40 -0800 Subject: [PATCH 2/4] checker and docs --- docs/documentation/case.md | 8 ++++++++ src/post_process/m_checker.fpp | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/documentation/case.md b/docs/documentation/case.md index 183d326a3c..c059fc1754 100644 --- a/docs/documentation/case.md +++ b/docs/documentation/case.md @@ -522,6 +522,9 @@ To restart the simulation from $k$-th time step, see [Restarting Cases](running. | `probe_wrt` | Logical | Write the flow chosen probes data files for each time step | | `num_probes` | Integer | Number of probes | | `probe(i)%[x,y,z]` | Real | Coordinates of probe $i$ | +| `output_partial_domain` | Logical | Output part of the domain | +| `[x,y,z]_output%beg` | Real | Beginning of the output domain in the [x,y,z]-direction | +| `[x,y,z]_output%end` | Real | End of the output domain in the [x,y,z]-direction | The table lists formatted database output parameters. The parameters define variables that are outputted from simulation and file types and formats of data as well as options for post-processing. @@ -549,6 +552,11 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu - `probe_wrt` activates the output of state variables at coordinates specified by `probe(i)%[x;y,z]`. +- `output_partial_domain` activates the output of part of the domain specified by `[x,y,z]_output%beg` and `[x,y,z]_output%end`. +This is useful for large domains where only a portion of the domain is of interest. +It is not supported when `precision = 1` and `format = 1`. +It also cannot be enabled with `flux_wrt`, `heat_ratio_wrt`, `pres_inf_wrt`, `c_wrt`, `omega_wrt`, `ib`, `schlieren_wrt`, or `qm_wrt`. + ### 8. Acoustic Source {#acoustic-source} | Parameter | Type | Description | diff --git a/src/post_process/m_checker.fpp b/src/post_process/m_checker.fpp index 817e2ce004..2e587eea12 100644 --- a/src/post_process/m_checker.fpp +++ b/src/post_process/m_checker.fpp @@ -26,6 +26,7 @@ contains subroutine s_check_inputs call s_check_inputs_output_format + call s_check_inputs_partial_domain call s_check_inputs_partial_density call s_check_inputs_velocity call s_check_inputs_flux_limiter @@ -43,6 +44,21 @@ contains @:PROHIBIT(precision /= 1 .and. precision /= 2) end subroutine s_check_inputs_output_format + !> Checks constraints on partial domain parameters + subroutine s_check_inputs_partial_domain + @:PROHIBIT(output_partial_domain .and. format == 1) + @:PROHIBIT(output_partial_domain .and. precision == 1) + @:PROHIBIT(output_partial_domain .and. any([flux_wrt, heat_ratio_wrt, pres_inf_wrt, c_wrt, schlieren_wrt, qm_wrt, ib, any(omega_wrt)])) + + @:PROHIBIT(output_partial_domain .and. (f_is_default(x_output%beg) .or. f_is_default(x_output%end))) + @:PROHIBIT(output_partial_domain .and. n /= 0 .and. (f_is_default(y_output%beg) .or. f_is_default(y_output%end))) + @:PROHIBIT(output_partial_domain .and. p /= 0 .and. (f_is_default(z_output%beg) .or. f_is_default(z_output%end))) + + #:for X in ['x', 'y', 'z'] + @:PROHIBIT(${X}$_output%beg > ${X}$_output%end) + #:endfor + end subroutine s_check_inputs_partial_domain + !> Checks constraints on partial density parameters subroutine s_check_inputs_partial_density character(len=5) :: iStr From 9b021f426d3da4c92d09a24c38b73af71bd83063 Mon Sep 17 00:00:00 2001 From: ChrisZYJ Date: Sat, 21 Dec 2024 23:05:50 -0800 Subject: [PATCH 3/4] formatting --- src/post_process/m_data_output.fpp | 28 ++++++++++++++-------------- toolchain/mfc/run/case_dicts.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index 21276fe987..bfe4f0550b 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -427,13 +427,13 @@ contains integer :: i integer :: lower_bound, upper_bound - + #:for X, M in [('x', 'm'), ('y', 'n'), ('z', 'p')] if (${M}$ == 0) return ! Early return for y or z if simulation is 1D or 2D lower_bound = -offset_${X}$%beg - upper_bound = ${M}$ + offset_${X}$%end + upper_bound = ${M}$+offset_${X}$%end do i = lower_bound, upper_bound if (${X}$_cc(i) > ${X}$_output%beg) then @@ -549,10 +549,10 @@ contains ! data as well as the total number of flow variable(s) that will ! eventually be stored in it if (output_partial_domain) then - write (dbfile) x_output_idx%end - x_output_idx%beg, & - y_output_idx%end - y_output_idx%beg, & - z_output_idx%end - z_output_idx%beg, & - dbvars + write (dbfile) x_output_idx%end - x_output_idx%beg, & + y_output_idx%end - y_output_idx%beg, & + z_output_idx%end - z_output_idx%beg, & + dbvars else write (dbfile) m, n, p, dbvars end if @@ -575,7 +575,7 @@ contains end if if (output_partial_domain) then - write (dbroot) x_output_idx%end-x_output_idx%beg, 0, 0, dbvars + write (dbroot) x_output_idx%end - x_output_idx%beg, 0, 0, dbvars else write (dbroot) m_root, 0, 0, dbvars end if @@ -769,9 +769,9 @@ contains real(z_cb, sp) else if (output_partial_domain) then - write (dbfile) x_cb( x_output_idx%beg-1 : x_output_idx%end ), & - y_cb( y_output_idx%beg-1 : y_output_idx%end ), & - z_cb( z_output_idx%beg-1 : z_output_idx%end ) + write (dbfile) x_cb(x_output_idx%beg - 1:x_output_idx%end), & + y_cb(y_output_idx%beg - 1:y_output_idx%end), & + z_cb(z_output_idx%beg - 1:z_output_idx%end) else write (dbfile) x_cb, y_cb, z_cb end if @@ -783,8 +783,8 @@ contains real(y_cb, sp) else if (output_partial_domain) then - write (dbfile) x_cb( x_output_idx%beg-1 : x_output_idx%end ), & - y_cb( y_output_idx%beg-1 : y_output_idx%end ) + write (dbfile) x_cb(x_output_idx%beg - 1:x_output_idx%end), & + y_cb(y_output_idx%beg - 1:y_output_idx%end) else write (dbfile) x_cb, y_cb end if @@ -799,7 +799,7 @@ contains write (dbfile) real(x_cb, sp) else if (output_partial_domain) then - write (dbfile) x_cb( x_output_idx%beg-1 : x_output_idx%end ) + write (dbfile) x_cb(x_output_idx%beg - 1:x_output_idx%end) else write (dbfile) x_cb end if @@ -816,7 +816,7 @@ contains write (dbroot) real(x_root_cb, wp) else if (output_partial_domain) then - write (dbroot) x_root_cb( x_output_idx%beg-1 : x_output_idx%end ) + write (dbroot) x_root_cb(x_output_idx%beg - 1:x_output_idx%end) else write (dbroot) x_root_cb end if diff --git a/toolchain/mfc/run/case_dicts.py b/toolchain/mfc/run/case_dicts.py index 97609e014c..dd6778d893 100644 --- a/toolchain/mfc/run/case_dicts.py +++ b/toolchain/mfc/run/case_dicts.py @@ -377,7 +377,7 @@ def analytic(self): POST_PROCESS[f'bc_{cmp}%beg'] = ParamType.INT POST_PROCESS[f'bc_{cmp}%end'] = ParamType.INT - + POST_PROCESS[f'{cmp}_output%beg'] = ParamType.REAL POST_PROCESS[f'{cmp}_output%end'] = ParamType.REAL From c7bc283b2f2310548b46f0a55de766362060e23f Mon Sep 17 00:00:00 2001 From: ChrisZYJ Date: Sun, 22 Dec 2024 19:30:38 -0800 Subject: [PATCH 4/4] fix parallel bug --- src/post_process/m_data_output.fpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/post_process/m_data_output.fpp b/src/post_process/m_data_output.fpp index bfe4f0550b..ceac210ec7 100644 --- a/src/post_process/m_data_output.fpp +++ b/src/post_process/m_data_output.fpp @@ -451,7 +451,8 @@ contains ! If no grid points are within the output region if ((${X}$_cc(lower_bound) > ${X}$_output%end) .or. (${X}$_cc(upper_bound) < ${X}$_output%beg)) then - call s_mpi_abort('No grid points are within the output region. Exiting ...') + ${X}$_output_idx%beg = 0 + ${X}$_output_idx%end = 0 end if #:endfor