Output Immersed Boundary load and state data#1302
Output Immersed Boundary load and state data#1302sbryngelson merged 17 commits intoMFlowCode:masterfrom
Conversation
organize the code. Adds new case parameter ib_force_wrt to toggle output.
This reverts commit 647d4c0. By reverting this commit, it returns gitignore to the MFC master version.
Merge MFC changes into ibdata-output
Keep ib_state_wrt addition, apply ruff formatting from master. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix ib_data.dat/ib.dat mismatch: update serial reader in m_data_input.f90 to match renamed writer - Replace hard-coded unit 92 with newunit= for IB state file I/O - Remove contradictory POSITION='append' from open statement - Add ib_state_wrt requires ib validation in case_validator.py and m_checker.fpp - Replace print*/return with s_mpi_abort in post_process error handling - Make rank guard consistent: move proc_rank==0 to call site Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Code ReviewHead SHA: 02f3448 Files changed:
Summary:
Findings: 1. [Correctness] Stale force/torque written for Suggested fix — add an unconditional force-computation pass when if (moving_immersed_boundary_flag) then
call s_propagate_immersed_boundaries(s)
end if
if (ib_state_wrt .and. s == nstage) then
call s_compute_ib_forces(q_prim_vf, fluid_pp)
end if
if (proc_rank == 0 .and. ib_state_wrt .and. s == nstage) then
call s_write_ib_state_file()
end if(Guard with a flag if the double-computation for 2. [Minor] Misleading comment 3. [Testing] No regression test added |
- Add iostat= + s_mpi_abort to the open call for consistent error handling with the rest of the file - Initialize ib_state_unit = -1 as a sentinel to make misuse detectable at runtime Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds an optional output path for Immersed Boundary (IB) loads/state during simulation and a post-processing conversion routine, controlled by a new ib_state_wrt input parameter.
Changes:
- Introduces
ib_state_wrtas a new logical user input (toolchain + simulation + post_process). - Writes IB state/load records to a binary stream file (
D/ib_state.dat) during simulation. - Post-process reads
D/ib_state.datand emits per-IB time-history text files; also renames serial IB marker output toib_data.dat.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| toolchain/mfc/params/definitions.py | Registers ib_state_wrt as an output logical parameter. |
| toolchain/mfc/case_validator.py | Adds validation: ib_state_wrt requires ib. |
| src/simulation/m_time_steppers.fpp | Opens/closes IB state output and writes records at RK final stage. |
| src/simulation/m_start_up.fpp | Adds ib_state_wrt to the simulation namelist. |
| src/simulation/m_mpi_proxy.fpp | Broadcasts ib_state_wrt across ranks. |
| src/simulation/m_global_parameters.fpp | Declares/defaults ib_state_wrt. |
| src/simulation/m_data_output.fpp | Implements binary ib_state.dat open/write/close routines. |
| src/simulation/m_checker.fpp | Adds runtime prohibition: ib_state_wrt requires ib. |
| src/post_process/p_main.fpp | Triggers IB state conversion at the end of post_process. |
| src/post_process/m_start_up.fpp | Adds ib_state_wrt to the post_process namelist. |
| src/post_process/m_mpi_proxy.fpp | Broadcasts ib_state_wrt across ranks. |
| src/post_process/m_global_parameters.fpp | Declares/defaults ib_state_wrt. |
| src/post_process/m_data_output.fpp | Reads ib_state.dat and writes per-IB formatted time histories. |
| src/post_process/m_data_input.f90 | Updates serial IB marker filename to ib_data.dat. |
| docs/documentation/case.md | Documents ib_state_wrt behavior. |
| write (out_file, '(A,I0,A)') trim(file_loc)//'/ib_', i, '.txt' | ||
| open (newunit=iu_out(i), file=trim(out_file), form='formatted', status='replace', action='write', iostat=ios) | ||
| if (ios /= 0) then | ||
| call s_mpi_abort('Cannot open IB state output file: '//trim(out_file)) | ||
| end if | ||
| write (iu_out(i), '(A)') & | ||
| 'mytime fx fy fz Tau_x Tau_y Tau_z vx vy vz omega_x omega_y omega_z angle_x angle_y angle_z x_c y_c z_c' | ||
| end do |
| read (iu_in, iostat=ios) rec_time, rec_id, & | ||
| rec_force, rec_torque, rec_vel, rec_angular_vel, rec_angles, & | ||
| rec_centroid(1), rec_centroid(2), rec_centroid(3) | ||
| if (ios /= 0) exit |
| impure subroutine s_open_ib_state_file | ||
| character(len=path_len + 2*name_len) :: file_loc | ||
| integer :: ios | ||
|
|
||
| write (file_loc, '(A)') 'ib_state.dat' | ||
| file_loc = trim(case_dir)//'/D/'//trim(file_loc) | ||
| open (newunit=ib_state_unit, file=trim(file_loc), & | ||
| form='unformatted', & | ||
| access='stream', & | ||
| status='replace', & | ||
| iostat=ios) | ||
| if (ios /= 0) call s_mpi_abort('Cannot open IB state output file: '//trim(file_loc)) |
| allocate (iu_out(num_ibs)) | ||
| do i = 1, num_ibs | ||
| write (out_file, '(A,I0,A)') trim(file_loc)//'/ib_', i, '.txt' | ||
| open (newunit=iu_out(i), file=trim(out_file), form='formatted', status='replace', action='write', iostat=ios) | ||
| if (ios /= 0) then | ||
| call s_mpi_abort('Cannot open IB state output file: '//trim(out_file)) | ||
| end if | ||
| write (iu_out(i), '(A)') & | ||
| 'mytime fx fy fz Tau_x Tau_y Tau_z vx vy vz omega_x omega_y omega_z angle_x angle_y angle_z x_c y_c z_c' | ||
| end do | ||
|
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1302 +/- ##
==========================================
- Coverage 45.27% 45.13% -0.14%
==========================================
Files 70 70
Lines 20480 20546 +66
Branches 1952 1959 +7
==========================================
+ Hits 9272 9274 +2
- Misses 10084 10146 +62
- Partials 1124 1126 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
This adds binary output of IB load and state data during the simulation run, and conversion to a CSV file in post processing. Including the parameter ib_state_wrt="T" will activate the output routines. Output files can be found under the "/D" folder.
Fixes #(issue)
Type of change
Testing
Ran lint, format, test -a on a MacBookPro (10 core) and on (4) Tuo GPUs.
Checklist
See the developer guide for full coding standards.
GPU changes (expand if you modified
src/simulation/)Tests ran considerably faster on MacBook CPUs than on Tuolumne GPUs.
AI code reviews
Reviews are not triggered automatically. To request a review, comment on the PR:
@coderabbitai review— incremental review (new changes only)/review— Qodo review/improve— Qodo code suggestions