Skip to content

Commit 49c194f

Browse files
committed
improve run_time.inf output
1 parent 9b70f9d commit 49c194f

File tree

3 files changed

+123
-49
lines changed

3 files changed

+123
-49
lines changed

src/common/m_mpi_common.fpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,21 @@ contains
417417
impure subroutine s_mpi_reduce_stability_criteria_extrema(icfl_max_loc, &
418418
vcfl_max_loc, &
419419
Rc_min_loc, &
420+
ccfl_max_loc, &
420421
icfl_max_glb, &
421422
vcfl_max_glb, &
422-
Rc_min_glb)
423+
Rc_min_glb, &
424+
ccfl_max_glb)
423425
424426
real(wp), intent(in) :: icfl_max_loc
425427
real(wp), intent(in) :: vcfl_max_loc
426428
real(wp), intent(in) :: Rc_min_loc
429+
real(wp), intent(in) :: ccfl_max_loc
427430
428431
real(wp), intent(out) :: icfl_max_glb
429432
real(wp), intent(out) :: vcfl_max_glb
430433
real(wp), intent(out) :: Rc_min_glb
434+
real(wp), intent(out) :: ccfl_max_glb
431435
432436
#ifdef MFC_SIMULATION
433437
#ifdef MFC_MPI
@@ -448,6 +452,12 @@ contains
448452
MPI_COMM_WORLD, ierr)
449453
end if
450454
455+
if (surface_tension) then
456+
call MPI_REDUCE(Rc_min_loc, Rc_min_glb, 1, &
457+
mpi_p, MPI_MIN, 0, &
458+
MPI_COMM_WORLD, ierr)
459+
end if
460+
451461
#else
452462
453463
icfl_max_glb = icfl_max_loc
@@ -457,6 +467,8 @@ contains
457467
Rc_min_glb = Rc_min_loc
458468
end if
459469
470+
if (surface_tension) ccfl_max_glb = ccfl_max_loc
471+
460472
#endif
461473
#endif
462474

src/simulation/m_data_output.fpp

Lines changed: 70 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module m_data_output
3636

3737
implicit none
3838

39-
private;
39+
private;
4040
public :: s_initialize_data_output_module, &
4141
s_open_run_time_information_file, &
4242
s_open_com_files, &
@@ -157,24 +157,20 @@ contains
157157
write (3, '(A)') ''; write (3, '(A)') ''
158158

159159
! Generating table header for the stability criteria to be outputted
160-
if (cfl_dt) then
161-
if (viscous) then
162-
write (3, '(A)') ' Time-steps dt = Time ICFL '// &
163-
'Max VCFL Max Rc Min ='
164-
else
165-
write (3, '(A)') ' Time-steps dt Time '// &
166-
' ICFL Max '
167-
end if
168-
else
169-
if (viscous) then
170-
write (3, '(A)') ' Time-steps Time ICFL '// &
171-
'Max VCFL Max Rc Min '
172-
else
173-
write (3, '(A)') ' Time-steps Time '// &
174-
' ICFL Max '
175-
end if
160+
write (3, '(13X,A8,13X,A10,13X,A10,13X,A10,)', advance="no") &
161+
trim('Time-steps'), trim('dt'), trim('Time'), trim('ICFL Max')
162+
163+
if (viscous) then
164+
write(3, '(13X,A10,13X,A16)', advance="no") &
165+
trim('VCFL Max'), trim('Rc Min')
176166
end if
177167

168+
if (surface_tension) then
169+
write(3, '(13X,A10)', advance="no") trim('CCFL Max')
170+
end if
171+
172+
write(3, *) ! new line
173+
178174
end subroutine s_open_run_time_information_file
179175

180176
!> This opens a formatted data file where the root processor
@@ -295,8 +291,12 @@ contains
295291

296292
call s_compute_speed_of_sound(pres, rho, gamma, pi_inf, H, alpha, vel_sum, 0._wp, c)
297293

298-
if (viscous) then
299-
call s_compute_stability_from_dt(vel, c, rho, Re, j, k, l, icfl_sf, vcfl_sf, Rc_sf)
294+
if (viscous .and. surface_tension) then
295+
call s_compute_stability_from_dt(vel, c, rho, Re, j, k, l, icfl_sf, vcfl_sf=vcfl_sf, Rc_sf=Rc_sf, ccfl_sf=ccfl_sf)
296+
elseif (viscous) then
297+
call s_compute_stability_from_dt(vel, c, rho, Re, j, k, l, icfl_sf, vcfl_sf=vcfl_sf, Rc_sf=Rc_sf)
298+
elseif (surface_tension) then
299+
call s_compute_stability_from_dt(vel, c, rho, Re, j, k, l, icfl_sf, ccfl_sf=ccfl_sf)
300300
else
301301
call s_compute_stability_from_dt(vel, c, rho, Re, j, k, l, icfl_sf)
302302
end if
@@ -311,17 +311,18 @@ contains
311311

312312
#ifdef _CRAYFTN
313313
$:GPU_UPDATE(host='[icfl_sf]')
314-
315-
if (viscous) then
316-
$:GPU_UPDATE(host='[vcfl_sf,Rc_sf]')
317-
end if
318-
319314
icfl_max_loc = maxval(icfl_sf)
320315

321316
if (viscous) then
317+
$:GPU_UPDATE(host='[vcfl_sf,Rc_sf]')
322318
vcfl_max_loc = maxval(vcfl_sf)
323319
Rc_min_loc = minval(Rc_sf)
324320
end if
321+
322+
if (surface_tension) then
323+
$:GPU_UPDATE(host='[ccfl_sf]')
324+
ccfl_max_loc = maxval(ccfl_sf)
325+
end if
325326
#else
326327
#:call GPU_PARALLEL(copyout='[icfl_max_loc]', copyin='[icfl_sf]')
327328
icfl_max_loc = maxval(icfl_sf)
@@ -332,20 +333,29 @@ contains
332333
Rc_min_loc = minval(Rc_sf)
333334
#:endcall GPU_PARALLEL
334335
end if
336+
337+
if (surface_tension) then
338+
#:call GPU_PARALLEL(copyout='[ccfl_max_loc]', copyin='[ccfl_sf]')
339+
ccfl_max_loc = maxval(ccfl_sf)
340+
#:endcall GPU_PARALLEL
341+
end if
335342
#endif
336343

337344
! Determining global stability criteria extrema at current time-step
338345
if (num_procs > 1) then
339346
call s_mpi_reduce_stability_criteria_extrema(icfl_max_loc, &
340347
vcfl_max_loc, &
341348
Rc_min_loc, &
349+
ccfl_max_loc, &
342350
icfl_max_glb, &
343351
vcfl_max_glb, &
344-
Rc_min_glb)
352+
Rc_min_glb, &
353+
ccfl_max_glb)
345354
else
346355
icfl_max_glb = icfl_max_loc
347356
if (viscous) vcfl_max_glb = vcfl_max_loc
348357
if (viscous) Rc_min_glb = Rc_min_loc
358+
if (surface_tension) ccfl_max_glb = ccfl_max_loc
349359
end if
350360

351361
! Determining the stability criteria extrema over all the time-steps
@@ -356,18 +366,28 @@ contains
356366
if (Rc_min_glb < Rc_min) Rc_min = Rc_min_glb
357367
end if
358368

369+
if (surface_tension) then
370+
if (ccfl_max_glb > ccfl_max) ccfl_max = ccfl_max_glb
371+
end if
372+
359373
! Outputting global stability criteria extrema at current time-step
360374
if (proc_rank == 0) then
375+
write (3, '(13X,I8,13X,F10.6,13X,F10.6,13X,F10.6)', advance="no") &
376+
t_step, dt, t_step*dt, icfl_max_glb
377+
361378
if (viscous) then
362-
write (3, '(6X,I8,F10.6,6X,6X,F10.6,6X,F9.6,6X,F9.6,6X,F10.6)') &
363-
t_step, dt, t_step*dt, icfl_max_glb, &
379+
write (3, '(13X,F10.6,13X,ES16.6)', advance="no") &
364380
vcfl_max_glb, &
365381
Rc_min_glb
366-
else
367-
write (3, '(13X,I8,14X,F10.6,14X,F10.6,13X,F9.6)') &
368-
t_step, dt, t_step*dt, icfl_max_glb
369382
end if
370383

384+
if (surface_tension) then
385+
write (3, '(13X,F10.6)', advance="no") &
386+
ccfl_max_glb
387+
end if
388+
389+
write(3, *) ! new line
390+
371391
if (.not. f_approx_equal(icfl_max_glb, icfl_max_glb)) then
372392
call s_mpi_abort('ICFL is NaN. Exiting.')
373393
elseif (icfl_max_glb > 1._wp) then
@@ -383,6 +403,15 @@ contains
383403
call s_mpi_abort('VCFL is greater than 1.0. Exiting.')
384404
end if
385405
end if
406+
407+
if (surface_tension) then
408+
if (.not. f_approx_equal(ccfl_max_glb, ccfl_max_glb)) then
409+
call s_mpi_abort('CCFL is NaN. Exiting.')
410+
elseif (ccfl_max_glb > 1._wp) then
411+
print *, 'ccfl', ccfl_max_glb
412+
call s_mpi_abort('CCFL is greater than 1.0. Exiting.')
413+
end if
414+
end if
386415
end if
387416

388417
call s_mpi_barrier()
@@ -1756,7 +1785,8 @@ contains
17561785

17571786
write (3, '(A,F9.6)') 'ICFL Max: ', icfl_max
17581787
if (viscous) write (3, '(A,F9.6)') 'VCFL Max: ', vcfl_max
1759-
if (viscous) write (3, '(A,F10.6)') 'Rc Min: ', Rc_min
1788+
if (viscous) write (3, '(A,ES16.6)') 'Rc Min: ', Rc_min
1789+
if (surface_tension) write (3, '(A,F10.6)') 'CCFL Max: ', ccfl_max
17601790

17611791
call cpu_time(run_time)
17621792

@@ -1805,7 +1835,12 @@ contains
18051835
@:ALLOCATE(Rc_sf (0:m, 0:n, 0:p))
18061836

18071837
vcfl_max = 0._wp
1808-
Rc_min = 1.e3_wp
1838+
Rc_min = 1.e12_wp
1839+
end if
1840+
1841+
if (surface_tension) then
1842+
@:ALLOCATE(ccfl_sf(0:m, 0:n, 0:p))
1843+
ccfl_max = 0._wp
18091844
end if
18101845
end if
18111846

@@ -1841,6 +1876,9 @@ contains
18411876
if (viscous) then
18421877
@:DEALLOCATE(vcfl_sf, Rc_sf)
18431878
end if
1879+
if (surface_tension) then
1880+
@:DEALLOCATE(ccfl_sf)
1881+
end if
18441882
end if
18451883

18461884
if (down_sample) then

src/simulation/m_sim_helpers.fpp

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ contains
181181
!! @param icfl_sf cell-centered inviscid cfl number
182182
!! @param vcfl_sf (optional) cell-centered viscous CFL number
183183
!! @param Rc_sf (optional) cell centered Rc
184-
pure subroutine s_compute_stability_from_dt(vel, c, rho, Re_l, j, k, l, icfl_sf, vcfl_sf, Rc_sf)
184+
pure subroutine s_compute_stability_from_dt(vel, c, rho, Re_l, j, k, l, icfl_sf, vcfl_sf, Rc_sf, ccfl_sf)
185185
$:GPU_ROUTINE(parallelism='[seq]')
186186
real(wp), intent(in), dimension(num_vels) :: vel
187187
real(wp), intent(in) :: c, rho
188188
real(wp), dimension(0:m, 0:n, 0:p), intent(inout) :: icfl_sf
189-
real(wp), dimension(0:m, 0:n, 0:p), intent(inout), optional :: vcfl_sf, Rc_sf
189+
real(wp), dimension(0:m, 0:n, 0:p), intent(inout), optional :: vcfl_sf, Rc_sf, ccfl_sf
190190
real(wp), dimension(2), intent(in) :: Re_l
191191
integer, intent(in) :: j, k, l
192192

@@ -203,8 +203,7 @@ contains
203203

204204
! Viscous calculations
205205
if (viscous) then
206-
if (p > 0) then
207-
!3D
206+
if (p > 0) then ! 3D
208207
if (grid_geometry == 3) then
209208
fltr_dtheta = f_compute_filtered_dtheta(k, l)
210209
vcfl_sf(j, k, l) = maxval(dt/Re_l/rho) &
@@ -221,19 +220,30 @@ contains
221220
dz(l)*(abs(vel(3)) + c)) &
222221
/maxval(1._wp/Re_l)
223222
end if
224-
elseif (n > 0) then
225-
!2D
223+
elseif (n > 0) then ! 2D
226224
vcfl_sf(j, k, l) = maxval(dt/Re_l/rho)/min(dx(j), dy(k))**2._wp
227225
Rc_sf(j, k, l) = min(dx(j)*(abs(vel(1)) + c), &
228226
dy(k)*(abs(vel(2)) + c)) &
229227
/maxval(1._wp/Re_l)
230-
else
231-
!1D
228+
else ! 1D
232229
vcfl_sf(j, k, l) = maxval(dt/Re_l/rho)/dx(j)**2._wp
233230
Rc_sf(j, k, l) = dx(j)*(abs(vel(1)) + c)/maxval(1._wp/Re_l)
234231
end if
235232
end if
236233

234+
if (surface_tension) then
235+
if (p > 0) then ! 3D
236+
if (grid_geometry == 3) then
237+
fltr_dtheta = f_compute_filtered_dtheta(k, l)
238+
ccfl_sf(j, k, l) = dt/sqrt(rho * max(dx(j), dy(k), fltr_dtheta)**3._wp / sigma)
239+
else
240+
ccfl_sf(j, k, l) = dt/sqrt(rho * max(dx(j), dy(k), dz(l))**3._wp / sigma)
241+
end if
242+
elseif (n > 0) then ! 2D
243+
ccfl_sf(j, k, l) = dt/sqrt(rho * max(dx(j), dy(k))**3._wp / sigma)
244+
end if
245+
end if
246+
237247
end subroutine s_compute_stability_from_dt
238248

239249
!> Computes dt for a specified CFL number
@@ -252,7 +262,7 @@ contains
252262
real(wp), dimension(2), intent(in) :: Re_l
253263
integer, intent(in) :: j, k, l
254264

255-
real(wp) :: icfl_dt, vcfl_dt
265+
real(wp) :: icfl_dt, vcfl_dt, ccfl_dt
256266
real(wp) :: fltr_dtheta
257267

258268
! Inviscid CFL calculation
@@ -266,8 +276,7 @@ contains
266276

267277
! Viscous calculations
268278
if (viscous) then
269-
if (p > 0) then
270-
!3D
279+
if (p > 0) then ! 3D
271280
if (grid_geometry == 3) then
272281
fltr_dtheta = f_compute_filtered_dtheta(k, l)
273282
vcfl_dt = cfl_target*(min(dx(j), dy(k), fltr_dtheta)**2._wp) &
@@ -276,17 +285,32 @@ contains
276285
vcfl_dt = cfl_target*(min(dx(j), dy(k), dz(l))**2._wp) &
277286
/minval(1/(rho*Re_l))
278287
end if
279-
elseif (n > 0) then
280-
!2D
288+
elseif (n > 0) then ! 2D
281289
vcfl_dt = cfl_target*(min(dx(j), dy(k))**2._wp)/maxval((1/Re_l)/rho)
282-
else
283-
!1D
290+
else ! 1D
284291
vcfl_dt = cfl_target*(dx(j)**2._wp)/minval(1/(rho*Re_l))
285292
end if
286293
end if
287294

288-
if (any(Re_size > 0)) then
295+
if (surface_tension) then
296+
if (p > 0) then ! 3D
297+
if (grid_geometry == 3) then
298+
fltr_dtheta = f_compute_filtered_dtheta(k, l)
299+
ccfl_dt = cfl_target*sqrt(rho * max(dx(j), dy(k), fltr_dtheta)**3._wp / sigma)
300+
else
301+
ccfl_dt = cfl_target*sqrt(rho * max(dx(j), dy(k), dz(l))**3._wp / sigma)
302+
end if
303+
elseif (n > 0) then ! 2D
304+
ccfl_dt = cfl_target*sqrt(rho * max(dx(j), dy(k))**3._wp / sigma)
305+
end if
306+
end if
307+
308+
if (any(Re_size > 0) .and. sigma > 0) then
309+
max_dt(j, k, l) = min(icfl_dt, vcfl_dt, ccfl_dt)
310+
elseif (any(Re_size > 0)) then
289311
max_dt(j, k, l) = min(icfl_dt, vcfl_dt)
312+
elseif (sigma > 0) then
313+
max_dt(j, k, l) = min(icfl_dt, ccfl_dt)
290314
else
291315
max_dt(j, k, l) = icfl_dt
292316
end if

0 commit comments

Comments
 (0)