Skip to content

Commit bdf3709

Browse files
output_partial_domain for post-processing (#768)
Co-authored-by: Spencer Bryngelson <[email protected]>
1 parent e6695af commit bdf3709

File tree

7 files changed

+173
-121
lines changed

7 files changed

+173
-121
lines changed

docs/documentation/case.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ To restart the simulation from $k$-th time step, see [Restarting Cases](running.
522522
| `probe_wrt` | Logical | Write the flow chosen probes data files for each time step |
523523
| `num_probes` | Integer | Number of probes |
524524
| `probe(i)%[x,y,z]` | Real | Coordinates of probe $i$ |
525+
| `output_partial_domain` | Logical | Output part of the domain |
526+
| `[x,y,z]_output%beg` | Real | Beginning of the output domain in the [x,y,z]-direction |
527+
| `[x,y,z]_output%end` | Real | End of the output domain in the [x,y,z]-direction |
525528

526529
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.
527530

@@ -549,6 +552,11 @@ If `file_per_process` is true, then pre_process, simulation, and post_process mu
549552

550553
- `probe_wrt` activates the output of state variables at coordinates specified by `probe(i)%[x;y,z]`.
551554

555+
- `output_partial_domain` activates the output of part of the domain specified by `[x,y,z]_output%beg` and `[x,y,z]_output%end`.
556+
This is useful for large domains where only a portion of the domain is of interest.
557+
It is not supported when `precision = 1` and `format = 1`.
558+
It also cannot be enabled with `flux_wrt`, `heat_ratio_wrt`, `pres_inf_wrt`, `c_wrt`, `omega_wrt`, `ib`, `schlieren_wrt`, or `qm_wrt`.
559+
552560
### 8. Acoustic Source {#acoustic-source}
553561

554562
| Parameter | Type | Description |

src/post_process/m_checker.fpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ contains
2626
subroutine s_check_inputs
2727

2828
call s_check_inputs_output_format
29+
call s_check_inputs_partial_domain
2930
call s_check_inputs_partial_density
3031
call s_check_inputs_velocity
3132
call s_check_inputs_flux_limiter
@@ -43,6 +44,21 @@ contains
4344
@:PROHIBIT(precision /= 1 .and. precision /= 2)
4445
end subroutine s_check_inputs_output_format
4546

47+
!> Checks constraints on partial domain parameters
48+
subroutine s_check_inputs_partial_domain
49+
@:PROHIBIT(output_partial_domain .and. format == 1)
50+
@:PROHIBIT(output_partial_domain .and. precision == 1)
51+
@:PROHIBIT(output_partial_domain .and. any([flux_wrt, heat_ratio_wrt, pres_inf_wrt, c_wrt, schlieren_wrt, qm_wrt, ib, any(omega_wrt)]))
52+
53+
@:PROHIBIT(output_partial_domain .and. (f_is_default(x_output%beg) .or. f_is_default(x_output%end)))
54+
@:PROHIBIT(output_partial_domain .and. n /= 0 .and. (f_is_default(y_output%beg) .or. f_is_default(y_output%end)))
55+
@:PROHIBIT(output_partial_domain .and. p /= 0 .and. (f_is_default(z_output%beg) .or. f_is_default(z_output%end)))
56+
57+
#:for X in ['x', 'y', 'z']
58+
@:PROHIBIT(${X}$_output%beg > ${X}$_output%end)
59+
#:endfor
60+
end subroutine s_check_inputs_partial_domain
61+
4662
!> Checks constraints on partial density parameters
4763
subroutine s_check_inputs_partial_density
4864
character(len=5) :: iStr

src/post_process/m_data_output.fpp

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ module m_data_output
2828
implicit none
2929

3030
private; public :: s_initialize_data_output_module, &
31+
s_define_output_region, &
3132
s_open_formatted_database_file, &
3233
s_open_intf_data_file, &
3334
s_open_energy_data_file, &
@@ -365,6 +366,9 @@ contains
365366
! Pressure
366367
if (pres_wrt .or. prim_vars_wrt) dbvars = dbvars + 1
367368
369+
! Elastic stresses
370+
if (hypoelasticity) dbvars = dbvars + (num_dims*(num_dims + 1))/2
371+
368372
! Volume fraction(s)
369373
if ((model_eqns == 2) .or. (model_eqns == 3)) then
370374
@@ -430,6 +434,42 @@ contains
430434
431435
end subroutine s_initialize_data_output_module ! --------------------------
432436
437+
subroutine s_define_output_region
438+
439+
integer :: i
440+
integer :: lower_bound, upper_bound
441+
442+
#:for X, M in [('x', 'm'), ('y', 'n'), ('z', 'p')]
443+
444+
if (${M}$ == 0) return ! Early return for y or z if simulation is 1D or 2D
445+
446+
lower_bound = -offset_${X}$%beg
447+
upper_bound = ${M}$+offset_${X}$%end
448+
449+
do i = lower_bound, upper_bound
450+
if (${X}$_cc(i) > ${X}$_output%beg) then
451+
${X}$_output_idx%beg = i + offset_${X}$%beg
452+
exit
453+
end if
454+
end do
455+
456+
do i = upper_bound, lower_bound, -1
457+
if (${X}$_cc(i) < ${X}$_output%end) then
458+
${X}$_output_idx%end = i + offset_${X}$%beg
459+
exit
460+
end if
461+
end do
462+
463+
! If no grid points are within the output region
464+
if ((${X}$_cc(lower_bound) > ${X}$_output%end) .or. (${X}$_cc(upper_bound) < ${X}$_output%beg)) then
465+
${X}$_output_idx%beg = 0
466+
${X}$_output_idx%end = 0
467+
end if
468+
469+
#:endfor
470+
471+
end subroutine s_define_output_region
472+
433473
subroutine s_open_formatted_database_file(t_step) ! --------------------
434474
! Description: This subroutine opens a new formatted database file, or
435475
! replaces an old one, and readies it for the data storage
@@ -520,7 +560,14 @@ contains
520560
! file by describing in it the dimensionality of post-processed
521561
! data as well as the total number of flow variable(s) that will
522562
! eventually be stored in it
523-
write (dbfile) m, n, p, dbvars
563+
if (output_partial_domain) then
564+
write (dbfile) x_output_idx%end - x_output_idx%beg, &
565+
y_output_idx%end - y_output_idx%beg, &
566+
z_output_idx%end - z_output_idx%beg, &
567+
dbvars
568+
else
569+
write (dbfile) m, n, p, dbvars
570+
end if
524571
525572
! Next, analogous steps to the ones above are carried out by the
526573
! root process to create and setup the formatted database master
@@ -539,7 +586,11 @@ contains
539586
'. Exiting ...')
540587
end if
541588
542-
write (dbroot) m_root, 0, 0, dbvars
589+
if (output_partial_domain) then
590+
write (dbroot) x_output_idx%end - x_output_idx%beg, 0, 0, dbvars
591+
else
592+
write (dbroot) m_root, 0, 0, dbvars
593+
end if
543594
544595
end if
545596
@@ -729,15 +780,26 @@ contains
729780
real(y_cb, sp), &
730781
real(z_cb, sp)
731782
else
732-
write (dbfile) x_cb, y_cb, z_cb
783+
if (output_partial_domain) then
784+
write (dbfile) x_cb(x_output_idx%beg - 1:x_output_idx%end), &
785+
y_cb(y_output_idx%beg - 1:y_output_idx%end), &
786+
z_cb(z_output_idx%beg - 1:z_output_idx%end)
787+
else
788+
write (dbfile) x_cb, y_cb, z_cb
789+
end if
733790
end if
734791
735792
elseif (n > 0) then
736793
if (precision == 1) then
737794
write (dbfile) real(x_cb, sp), &
738795
real(y_cb, sp)
739796
else
740-
write (dbfile) x_cb, y_cb
797+
if (output_partial_domain) then
798+
write (dbfile) x_cb(x_output_idx%beg - 1:x_output_idx%end), &
799+
y_cb(y_output_idx%beg - 1:y_output_idx%end)
800+
else
801+
write (dbfile) x_cb, y_cb
802+
end if
741803
end if
742804
743805
! One-dimensional local grid data is written to the formatted
@@ -746,9 +808,13 @@ contains
746808
else
747809
748810
if (precision == 1) then
749-
write (dbfile) real(x_cb, wp)
811+
write (dbfile) real(x_cb, sp)
750812
else
751-
write (dbfile) x_cb
813+
if (output_partial_domain) then
814+
write (dbfile) x_cb(x_output_idx%beg - 1:x_output_idx%end)
815+
else
816+
write (dbfile) x_cb
817+
end if
752818
end if
753819
754820
if (num_procs > 1) then
@@ -761,7 +827,11 @@ contains
761827
if (precision == 1) then
762828
write (dbroot) real(x_root_cb, wp)
763829
else
764-
write (dbroot) x_root_cb
830+
if (output_partial_domain) then
831+
write (dbroot) x_root_cb(x_output_idx%beg - 1:x_output_idx%end)
832+
else
833+
write (dbroot) x_root_cb
834+
end if
765835
end if
766836
end if
767837

src/post_process/m_global_parameters.fpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ module m_global_parameters
197197

198198
integer :: precision !< Floating point precision of the database file(s)
199199

200+
logical :: output_partial_domain !< Specify portion of domain to output for post-processing
201+
202+
type(bounds_info) :: x_output, y_output, z_output !< Portion of domain to output for post-processing
203+
type(int_bounds_info) :: x_output_idx, y_output_idx, z_output_idx !< Indices of domain to output for post-processing
204+
200205
!> @name Size of the ghost zone layer in the x-, y- and z-coordinate directions.
201206
!! The definition of the ghost zone layers is only necessary when using the
202207
!! Silo database file format in multidimensions. These zones provide VisIt
@@ -432,6 +437,15 @@ contains
432437
! IBM
433438
num_ibs = dflt_int
434439

440+
! Output partial domain
441+
output_partial_domain = .false.
442+
x_output%beg = dflt_real
443+
x_output%end = dflt_real
444+
y_output%beg = dflt_real
445+
y_output%end = dflt_real
446+
z_output%beg = dflt_real
447+
z_output%end = dflt_real
448+
435449
end subroutine s_assign_default_values_to_user_inputs
436450

437451
!> Computation of parameters, allocation procedures, and/or
@@ -692,6 +706,15 @@ contains
692706
species_idx%end = 1
693707
end if
694708

709+
if (output_partial_domain) then
710+
x_output_idx%beg = 0
711+
x_output_idx%end = 0
712+
y_output_idx%beg = 0
713+
y_output_idx%end = 0
714+
z_output_idx%beg = 0
715+
z_output_idx%end = 0
716+
end if
717+
695718
momxb = mom_idx%beg
696719
momxe = mom_idx%end
697720
advxb = adv_idx%beg

src/post_process/m_mpi_proxy.fpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ contains
170170
& 'prim_vars_wrt', 'c_wrt', 'qm_wrt','schlieren_wrt', 'bubbles_euler', 'qbmm', &
171171
& 'polytropic', 'polydisperse', 'file_per_process', 'relax', 'cf_wrt', &
172172
& 'adv_n', 'ib', 'cfl_adap_dt', 'cfl_const_dt', 'cfl_dt', &
173-
& 'surface_tension', 'hyperelasticity', 'bubbles_lagrange', 'rkck_adap_dt']
173+
& 'surface_tension', 'hyperelasticity', 'bubbles_lagrange', 'rkck_adap_dt', 'output_partial_domain']
174174
call MPI_BCAST(${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
175175
#:endfor
176176
@@ -191,7 +191,9 @@ contains
191191
end do
192192
193193
#:for VAR in [ 'pref', 'rhoref', 'R0ref', 'poly_sigma', 'Web', 'Ca', &
194-
& 'Re_inv', 'sigma', 't_save', 't_stop' ]
194+
& 'Re_inv', 'sigma', 't_save', 't_stop', &
195+
& 'x_output%beg', 'x_output%end', 'y_output%beg', &
196+
& 'y_output%end', 'z_output%beg', 'z_output%end' ]
195197
call MPI_BCAST(${VAR}$, 1, mpi_p, 0, MPI_COMM_WORLD, ierr)
196198
#:endfor
197199
call MPI_BCAST(schlieren_alpha(1), num_fluids_max, mpi_p, 0, MPI_COMM_WORLD, ierr)

0 commit comments

Comments
 (0)