Skip to content

Commit 0b1abfa

Browse files
authored
Add ib_markers to Silo Output (#496)
1 parent fefed37 commit 0b1abfa

File tree

7 files changed

+129
-8
lines changed

7 files changed

+129
-8
lines changed

src/common/m_mpi_common.fpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ contains
133133
end if
134134
#endif
135135
136-
#ifndef MFC_POST_PROCESS
137136
if (present(ib_markers)) then
138137
139138
#ifdef MFC_PRE_PROCESS
@@ -146,7 +145,6 @@ contains
146145
call MPI_TYPE_COMMIT(MPI_IO_IB_DATA%view, ierr)
147146
148147
end if
149-
#endif
150148
151149
#ifndef MFC_POST_PROCESS
152150
if (present(ib_markers)) then

src/post_process/m_data_input.f90

Lines changed: 108 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ end subroutine s_read_abstract_data_files
5151
type(scalar_field), allocatable, dimension(:), public :: q_prim_vf !<
5252
!! Primitive variables
5353

54+
! type(scalar_field), public :: ib_markers !<
55+
type(integer_field), public :: ib_markers
56+
5457
procedure(s_read_abstract_data_files), pointer :: s_read_data_files => null()
5558

5659
contains
@@ -75,6 +78,11 @@ subroutine s_read_serial_data_files(t_step)
7578
!! Used to store the variable position, in character form, of the
7679
!! currently manipulated conservative variable file
7780

81+
character(LEN=len_trim(case_dir) + 2*name_len) :: t_step_ib_dir !<
82+
!! Location of the time-step directory associated with t_step
83+
84+
character(LEN=len_trim(case_dir) + 3*name_len) :: file_loc_ib !<
85+
7886
logical :: dir_check !<
7987
!! Generic logical used to test the existence of a particular folder
8088

@@ -87,9 +95,14 @@ subroutine s_read_serial_data_files(t_step)
8795
write (t_step_dir, '(A,I0,A,I0)') '/p_all/p', proc_rank, '/', t_step
8896
t_step_dir = trim(case_dir)//trim(t_step_dir)
8997

98+
write (t_step_ib_dir, '(A,I0,A,I0)') '/p_all/p', proc_rank, '/', 0
99+
t_step_ib_dir = trim(case_dir)//trim(t_step_ib_dir)
100+
90101
! Inquiring as to the existence of the time-step directory
91102
file_loc = trim(t_step_dir)//'/.'
92103

104+
file_loc_ib = trim(t_step_ib_dir)//'/.'
105+
93106
call my_inquire(file_loc, dir_check)
94107

95108
! If the time-step directory is missing, the post-process exits.
@@ -98,6 +111,14 @@ subroutine s_read_serial_data_files(t_step)
98111
' is missing. Exiting ...')
99112
end if
100113

114+
call my_inquire(file_loc_ib, dir_check)
115+
116+
! If the time-step directory is missing, the post-process exits.
117+
if (dir_check .neqv. .true.) then
118+
call s_mpi_abort('Time-step folder '//trim(t_step_ib_dir)// &
119+
' is missing. Exiting ...')
120+
end if
121+
101122
! Reading the Grid Data File for the x-direction ===================
102123

103124
! Checking whether x_cb.dat exists
@@ -205,6 +226,19 @@ subroutine s_read_serial_data_files(t_step)
205226

206227
end do
207228

229+
if (ib) then
230+
write (file_loc_ib, '(A,I0,A)') &
231+
trim(t_step_ib_dir)//'/ib.dat'
232+
inquire (FILE=trim(file_loc_ib), EXIST=file_check)
233+
if (file_check) then
234+
open (2, FILE=trim(file_loc_ib), &
235+
FORM='unformatted', &
236+
ACTION='read', &
237+
STATUS='old')
238+
call s_mpi_abort(trim(file_loc)//' is missing. Exiting ...')
239+
end if
240+
end if
241+
208242
! ==================================================================
209243

210244
end subroutine s_read_serial_data_files
@@ -317,7 +351,11 @@ subroutine s_read_parallel_data_files(t_step)
317351
call MPI_FILE_OPEN(MPI_COMM_SELF, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
318352

319353
! Initialize MPI data I/O
320-
call s_initialize_mpi_data(q_cons_vf)
354+
if (ib) then
355+
call s_initialize_mpi_data(q_cons_vf, ib_markers)
356+
else
357+
call s_initialize_mpi_data(q_cons_vf)
358+
end if
321359

322360
! Size of local arrays
323361
data_size = (m + 1)*(n + 1)*(p + 1)
@@ -351,6 +389,29 @@ subroutine s_read_parallel_data_files(t_step)
351389
call s_mpi_barrier()
352390

353391
call MPI_FILE_CLOSE(ifile, ierr)
392+
393+
if (ib) then
394+
395+
write (file_loc, '(A)') 'ib.dat'
396+
file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc)
397+
inquire (FILE=trim(file_loc), EXIST=file_exist)
398+
399+
if (file_exist) then
400+
401+
call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
402+
403+
disp = 0
404+
405+
call MPI_FILE_SET_VIEW(ifile, disp, MPI_INTEGER, MPI_IO_IB_DATA%view, &
406+
'native', mpi_info_int, ierr)
407+
call MPI_FILE_READ(ifile, MPI_IO_IB_DATA%var%sf, data_size, &
408+
MPI_INTEGER, status, ierr)
409+
410+
else
411+
call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting...')
412+
end if
413+
414+
end if
354415
else
355416
call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting...')
356417
end if
@@ -364,7 +425,11 @@ subroutine s_read_parallel_data_files(t_step)
364425
call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
365426

366427
! Initialize MPI data I/O
367-
call s_initialize_mpi_data(q_cons_vf)
428+
if (ib) then
429+
call s_initialize_mpi_data(q_cons_vf, ib_markers)
430+
else
431+
call s_initialize_mpi_data(q_cons_vf)
432+
end if
368433

369434
! Size of local arrays
370435
data_size = (m + 1)*(n + 1)*(p + 1)
@@ -408,6 +473,28 @@ subroutine s_read_parallel_data_files(t_step)
408473
call s_mpi_barrier()
409474

410475
call MPI_FILE_CLOSE(ifile, ierr)
476+
477+
if (ib) then
478+
479+
write (file_loc, '(A)') 'ib.dat'
480+
file_loc = trim(case_dir)//'/restart_data'//trim(mpiiofs)//trim(file_loc)
481+
inquire (FILE=trim(file_loc), EXIST=file_exist)
482+
483+
if (file_exist) then
484+
485+
call MPI_FILE_OPEN(MPI_COMM_WORLD, file_loc, MPI_MODE_RDONLY, mpi_info_int, ifile, ierr)
486+
487+
disp = 0
488+
489+
call MPI_FILE_SET_VIEW(ifile, disp, MPI_INTEGER, MPI_IO_IB_DATA%view, &
490+
'native', mpi_info_int, ierr)
491+
call MPI_FILE_READ(ifile, MPI_IO_IB_DATA%var%sf, data_size, &
492+
MPI_INTEGER, status, ierr)
493+
494+
else
495+
call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting...')
496+
end if
497+
end if
411498
else
412499
call s_mpi_abort('File '//trim(file_loc)//' is missing. Exiting...')
413500
end if
@@ -1079,6 +1166,12 @@ subroutine s_initialize_data_input_module
10791166
-buff_size:p + buff_size))
10801167
end do
10811168

1169+
if (ib) then
1170+
allocate (ib_markers%sf(-buff_size:m + buff_size, &
1171+
-buff_size:n + buff_size, &
1172+
-buff_size:p + buff_size))
1173+
end if
1174+
10821175
! Simulation is 2D
10831176
else
10841177

@@ -1091,6 +1184,11 @@ subroutine s_initialize_data_input_module
10911184
0:0))
10921185
end do
10931186

1187+
if (ib) then
1188+
allocate (ib_markers%sf(-buff_size:m + buff_size, &
1189+
-buff_size:n + buff_size, &
1190+
0:0))
1191+
end if
10941192
end if
10951193

10961194
! Simulation is 1D
@@ -1105,6 +1203,10 @@ subroutine s_initialize_data_input_module
11051203
0:0))
11061204
end do
11071205

1206+
if (ib) then
1207+
allocate (ib_markers%sf(-buff_size:m + buff_size, 0:0, 0:0))
1208+
end if
1209+
11081210
end if
11091211

11101212
if (parallel_io .neqv. .true.) then
@@ -1129,6 +1231,10 @@ subroutine s_finalize_data_input_module
11291231
deallocate (q_cons_vf)
11301232
deallocate (q_prim_vf)
11311233

1234+
if (ib) then
1235+
deallocate (ib_markers%sf)
1236+
end if
1237+
11321238
s_read_data_files => null()
11331239

11341240
end subroutine s_finalize_data_input_module

src/post_process/m_global_parameters.fpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ module m_global_parameters
128128
#ifdef MFC_MPI
129129

130130
type(mpi_io_var), public :: MPI_IO_DATA
131+
type(mpi_io_ib_var), public :: MPI_IO_IB_DATA
131132

132133
#endif
133134

@@ -191,6 +192,7 @@ module m_global_parameters
191192
logical :: qm_wrt
192193
logical :: schlieren_wrt
193194
logical :: cf_wrt
195+
logical :: ib
194196
!> @}
195197

196198
real(kind(0d0)), dimension(num_fluids_max) :: schlieren_alpha !<
@@ -334,6 +336,7 @@ contains
334336
qm_wrt = .false.
335337
schlieren_wrt = .false.
336338
cf_wrt = .false.
339+
ib = .false.
337340

338341
schlieren_alpha = dflt_real
339342

@@ -598,6 +601,8 @@ contains
598601
allocate (MPI_IO_DATA%var(i)%sf(0:m, 0:n, 0:p))
599602
MPI_IO_DATA%var(i)%sf => null()
600603
end do
604+
605+
if (ib) allocate (MPI_IO_IB_DATA%var%sf(0:m, 0:n, 0:p))
601606
#endif
602607

603608
! Size of the ghost zone layer is non-zero only when post-processing
@@ -752,6 +757,7 @@ contains
752757
deallocate (MPI_IO_DATA%view)
753758
end if
754759

760+
if (ib) MPI_IO_IB_DATA%var%sf => null()
755761
#endif
756762

757763
end subroutine s_finalize_global_parameters_module

src/post_process/m_mpi_proxy.fpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ contains
168168
& 'heat_ratio_wrt', 'pi_inf_wrt', 'pres_inf_wrt', 'cons_vars_wrt', &
169169
& 'prim_vars_wrt', 'c_wrt', 'qm_wrt','schlieren_wrt', 'bubbles', 'qbmm', &
170170
& 'polytropic', 'polydisperse', 'file_per_process', 'relax', 'cf_wrt', &
171-
& 'adv_n' ]
171+
& 'adv_n', 'ib' ]
172172
call MPI_BCAST(${VAR}$, 1, MPI_LOGICAL, 0, MPI_COMM_WORLD, ierr)
173173
#:endfor
174174

src/post_process/m_start_up.f90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ subroutine s_read_input_file
7474
parallel_io, rhoref, pref, bubbles, qbmm, sigR, &
7575
R0ref, nb, polytropic, thermal, Ca, Web, Re_inv, &
7676
polydisperse, poly_sigma, file_per_process, relax, &
77-
relax_model, cf_wrt, sigma, adv_n
77+
relax_model, cf_wrt, sigma, adv_n, ib
7878

7979
! Inquiring the status of the post_process.inp file
8080
file_loc = 'post_process.inp'
@@ -496,6 +496,12 @@ subroutine s_save_data(t_step, varname, pres, c, H)
496496
end if
497497
! ----------------------------------------------------------------------
498498

499+
if (ib) then
500+
q_sf = real(ib_markers%sf(-offset_x%beg:m + offset_x%end, -offset_y%beg:n + offset_y%end, -offset_z%beg:p + offset_z%end))
501+
varname = 'ib_markers'
502+
call s_write_variable_to_formatted_database_file(varname, t_step)
503+
end if
504+
499505
! Adding Q_M to the formatted database file ------------------
500506
if (p > 0 .and. qm_wrt) then
501507
call s_derive_qm(q_prim_vf, q_sf)

src/simulation/m_data_output.fpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,11 @@ contains
931931
else
932932
! Initialize MPI data I/O
933933

934-
call s_initialize_mpi_data(q_cons_vf)
934+
if (ib) then
935+
call s_initialize_mpi_data(q_cons_vf, ib_markers)
936+
else
937+
call s_initialize_mpi_data(q_cons_vf)
938+
end if
935939

936940
! Open the file to write all flow variables
937941
write (file_loc, '(I0,A)') t_step, '.dat'

toolchain/mfc/run/case_dicts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ def analytic(self):
308308
'omega_wrt': ParamType.LOG,
309309
'qbmm': ParamType.LOG,
310310
'qm_wrt': ParamType.LOG,
311-
'cf_wrt': ParamType.LOG
311+
'cf_wrt': ParamType.LOG,
312+
'ib': ParamType.LOG
312313
})
313314

314315
for cmp_id in range(1,3+1):

0 commit comments

Comments
 (0)