Skip to content

Update terminal output and add limiting factor to adaptive output - #1757

Draft
wilfonba wants to merge 2 commits into
MFlowCode:masterfrom
wilfonba:TerminalOutput
Draft

Update terminal output and add limiting factor to adaptive output#1757
wilfonba wants to merge 2 commits into
MFlowCode:masterfrom
wilfonba:TerminalOutput

Conversation

@wilfonba

@wilfonba wilfonba commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

This PR improves the runtime terminal output for simulations. The terminal output width is reduced. The following shows a before and after for a constant delta t simulation

Before:
 [  0%]  Time step        1 of 1001 @ t_step =        0 Time Avg = 0.000000E+00 Time/step= 0.000000E+00 ETA (HH:MM:SS) = 0:00:00
 [  1%]  Time step        2 of 1001 @ t_step =        1 Time Avg = 0.000000E+00 Time/step= 3.007400E-02 ETA (HH:MM:SS) = 0:00:00
 [  1%]  Time step        3 of 1001 @ t_step =        2 Time Avg = 0.000000E+00 Time/step= 2.920300E-02 ETA (HH:MM:SS) = 0:00:00
 [  1%]  Time step        4 of 1001 @ t_step =        3 Time Avg = 2.900600E-02 Time/step= 2.900600E-02 ETA (HH:MM:SS) = 0:00:28
 [  1%]  Time step        5 of 1001 @ t_step =        4 Time Avg = 2.869950E-02 Time/step= 2.839300E-02 ETA (HH:MM:SS) = 0:00:28
 [  1%]  Time step        6 of 1001 @ t_step =        5 Time Avg = 2.865167E-02 Time/step= 2.855600E-02 ETA (HH:MM:SS) = 0:00:28

After:
 [  0%] step 1 of 1001 (t_step 0) t/step  0.00E+00s (avg  0.00E+00s) ETA 0:00:00
 [  1%] step 2 of 1001 (t_step 1) t/step  2.88E-02s (avg  0.00E+00s) ETA 0:00:00
 [  1%] step 3 of 1001 (t_step 2) t/step  2.83E-02s (avg  0.00E+00s) ETA 0:00:00
 [  1%] step 4 of 1001 (t_step 3) t/step  2.75E-02s (avg  2.75E-02s) ETA 0:00:27
 [  1%] step 5 of 1001 (t_step 4) t/step  2.76E-02s (avg  2.76E-02s) ETA 0:00:27
 [  1%] step 6 of 1001 (t_step 5) t/step  2.80E-02s (avg  2.77E-02s) ETA 0:00:27

The output for a cfl_const_dt is identical since the delta t is constant. The following shows the before and after for a cfl_adap_dt simulation

Before:
 [  0%] Time     0.000000E+00 dt =     1.940738E-06 @ Time Step =        0 Time Avg =     0.000000E+00 Time/step = 0.000000E+00 ETA (HH:MM:SS) = 0:00:00
 [  1%] Time     1.940738E-06 dt =     1.940196E-06 @ Time Step =        1 Time Avg =     6.183838E-04 Time/step = 6.122000E-02 ETA (HH:MM:SS) = 0:00:02
 [  1%] Time     3.880934E-06 dt =     1.940727E-06 @ Time Step =        2 Time Avg =     1.212500E-03 Time/step = 6.003000E-02 ETA (HH:MM:SS) = 0:00:04
 [  1%] Time     5.821661E-06 dt =     1.940699E-06 @ Time Step =        3 Time Avg =     1.784436E-03 Time/step = 5.897800E-02 ETA (HH:MM:SS) = 0:00:07
 [  1%] Time     7.762360E-06 dt =     1.940079E-06 @ Time Step =        4 Time Avg =     2.336284E-03 Time/step = 5.807300E-02 ETA (HH:MM:SS) = 0:00:09
 [  1%] Time     9.702439E-06 dt =     1.939277E-06 @ Time Step =        5 Time Avg =     2.875777E-03 Time/step = 5.790400E-02 ETA (HH:MM:SS) = 0:00:11
 [  1%] Time     1.164172E-05 dt =     1.939666E-06 @ Time Step =        6 Time Avg =     3.401279E-03 Time/step = 5.752800E-02 ETA (HH:MM:SS) = 0:00:14
After:
 [  0%] t =  0.0000E+00 dt =  1.9407E-06 (ICFL) @ step 0 t/step  0.00E+00s (avg  0.00E+00s) ETA 0:00:00
 [  1%] t =  1.9407E-06 dt =  1.9402E-06 (ICFL) @ step 1 t/step  6.09E-02s (avg  6.15E-04s) ETA 0:00:02
 [  1%] t =  3.8809E-06 dt =  1.9407E-06 (ICFL) @ step 2 t/step  5.87E-02s (avg  1.20E-03s) ETA 0:00:04
 [  1%] t =  5.8217E-06 dt =  1.9407E-06 (ICFL) @ step 3 t/step  5.83E-02s (avg  1.76E-03s) ETA 0:00:07
 [  1%] t =  7.7624E-06 dt =  1.9401E-06 (ICFL) @ step 4 t/step  5.71E-02s (avg  2.30E-03s) ETA 0:00:09
 [  1%] t =  9.7024E-06 dt =  1.9393E-06 (ICFL) @ step 5 t/step  5.73E-02s (avg  2.84E-03s) ETA 0:00:11

Contribution Policy

We do not accept pull requests generated primarily by AI without genuine understanding or real-world usage context.

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.


Acknowledgement

  • I confirm this PR meets the above expectations and reflects my own understanding and real-world context.

PR template credit: junegunn

Copilot AI lite review requested due to automatic review settings August 24, 2026 15:18
@wilfonba
wilfonba requested a review from sbryngelson as a code owner August 24, 2026 15:18
dt_cfl_glb = (/icfl_dt_local, vcfl_dt_local, ccfl_dt_local/)
else
call s_mpi_allreduce_min(dt_local, dt)
call s_mpi_allreduce_min_vec((/icfl_dt_local, vcfl_dt_local, ccfl_dt_local/), dt_cfl_glb)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the kind of notation that could get expensive on amd compilers. did you do any testing

@wilfonba wilfonba Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not... I'll make this a constant size array rather than a constructed array in the subroutine call

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR refines simulation runtime terminal output formatting and adds visibility into which CFL criterion (inviscid/viscous/capillary) is limiting the adaptive time step.

Changes:

  • Track per-criterion CFL candidate time steps and select the global limiting criterion.
  • Add an MPI helper to allreduce elementwise minima for small real vectors.
  • Update printed progress lines to be shorter and (for adaptive CFL) include the limiting criterion tag.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/simulation/m_time_steppers.fpp Computes per-criterion dt candidates, reduces globally, and records which criterion limits dt.
src/simulation/m_start_up.fpp Updates progress/ETA print formatting and appends limiter tag for adaptive dt runs.
src/simulation/m_sim_helpers.fpp Exposes dt_limiter state and expands CFL helper to return 3 candidate dts.
src/common/m_mpi_common.fpp Adds s_mpi_allreduce_min_vec for elementwise global minima of real vectors.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +445 to +456
impure subroutine s_mpi_allreduce_min_vec(var_loc, var_glb)

real(wp), dimension(:), intent(in) :: var_loc
real(wp), dimension(:), intent(out) :: var_glb

#ifdef MFC_MPI
integer :: ierr !< Generic flag used to identify and report MPI errors

call MPI_ALLREDUCE(var_loc, var_glb, size(var_loc), mpi_p, MPI_MIN, MPI_COMM_WORLD, ierr)
#else
var_glb = var_loc
#endif
Comment on lines +17 to +21
private; public :: s_compute_enthalpy, s_compute_stability_from_dt, s_compute_dt_from_cfl, dt_limiter, dt_limiter_names

!> Stability criterion currently limiting the adaptive time step (ICFL, VCFL, or CCFL)
character(len=4) :: dt_limiter = 'none'
character(len=4), dimension(3), parameter :: dt_limiter_names = (/'ICFL', 'VCFL', 'CCFL'/)
real(wp), dimension(num_vels), intent(in) :: vel
real(wp), intent(in) :: c, rho
real(wp), intent(inout) :: max_dt
real(wp), dimension(3), intent(inout) :: max_dt
dt_cfl_glb = (/icfl_dt_local, vcfl_dt_local, ccfl_dt_local/)
else
call s_mpi_allreduce_min(dt_local, dt)
call s_mpi_allreduce_min_vec((/icfl_dt_local, vcfl_dt_local, ccfl_dt_local/), dt_cfl_glb)
@wilfonba
wilfonba marked this pull request as draft August 24, 2026 17:18
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/common/m_mpi_common.fpp 1484 +10
src/simulation/m_time_steppers.fpp 835 +7
src/simulation/m_sim_helpers.fpp 200 +4
src/simulation/m_start_up.fpp 1248 +4
Directory Lines Diff
common 9783 +10
simulation 27924 +15
total 45540 +25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants