Refactor and unify common routines for boundary conditions#1629
Refactor and unify common routines for boundary conditions#1629wilfonba wants to merge 4 commits into
Conversation
s_populate_grid_variables_buffers set the local offset_x/y/z to buff_size unconditionally, but in post_process the cell-boundary arrays x_cb/y_cb/z_cb are allocated to the smaller module offset_x/y/z. When buff_size > offset (e.g. weno_order 5 with omega_wrt adding fd_number), the ghost extrapolation wrote past x_cb bounds, corrupting memory into NaN under -O3 (lid_driven_cavity cases). Restore the MFC_SIMULATION guard so post_process uses the module offsets, and pass the offset into s_mpi_sendrecv_grid_variables_buffers so the processor-boundary path bounds the cell-boundary recompute by offset while cell centers keep buff_size.
|
Pushed Root cause: the refactor made The recompute that was relocated into Fix (2 files, +27/−9):
In simulation |
There was a problem hiding this comment.
Pull request overview
This PR refactors boundary-condition related code to centralize “boundary primitives” in src/common/m_boundary_primitives.fpp, unify buffer-population logic under m_boundary_common, and narrow m_boundary_io to boundary-condition I/O responsibilities (plus supporting MPI I/O datatypes).
Changes:
- Moved capillary color-function and IGR Jacobian ghost-cell primitive routines into
m_boundary_primitives, and refactored capillary/IGR buffer population into direction/location helpers inm_boundary_common. - Refactored grid-variable buffer population into
m_boundary_commonwith a shared per-direction dispatcher; enhanced MPI grid buffer exchange to accept anoffsetargument and update derived grid-location ghosts. - Updated startup / I/O call sites to import boundary I/O routines from
m_boundary_iodirectly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/simulation/m_start_up.fpp | Imports m_boundary_io directly so boundary I/O routines remain available after refactor. |
| src/pre_process/m_data_output.fpp | Imports m_boundary_io directly for boundary-condition output routines. |
| src/post_process/m_start_up.fpp | Imports m_boundary_io directly for post-process initialization needs. |
| src/post_process/m_data_input.f90 | Imports m_boundary_io directly for boundary-condition input routines. |
| src/common/m_mpi_common.fpp | Extends MPI grid-variable buffer exchange to accept offset and update grid-location ghosts accordingly. |
| src/common/m_checker_common.fpp | Tightens public exports (removes wp from the public list). |
| src/common/m_boundary_primitives.fpp | Adds capillary/IGR/grid boundary primitive routines consolidated from other modules. |
| src/common/m_boundary_io.fpp | Removes non-I/O buffer-population routines, leaving boundary-condition I/O and related helpers. |
| src/common/m_boundary_common.fpp | Becomes the unified home for capillary/IGR/grid buffer population orchestration and dispatch. |
| !> The goal of this procedure is to populate the buffers of the grid variables by communicating with the neighboring processors. | ||
| !! Note that only the buffers of the cell-width distributions are handled in such a way. This is because the buffers of | ||
| !! cell-boundary locations may be calculated directly from those of the cell-width distributions. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1629 +/- ##
==========================================
+ Coverage 60.88% 61.07% +0.18%
==========================================
Files 83 83
Lines 19836 19925 +89
Branches 2953 2975 +22
==========================================
+ Hits 12077 12169 +92
+ Misses 5767 5753 -14
- Partials 1992 2003 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
This PR reorganizes and refactors code that was misplaced by agentic coding. The buffer exchange routines for variable buffers, surface tension, F_igr, and grid variables have been unified under a common abstraction. Relevant "boundary primitives" were moved into the
src/common/m_boundary_primitives.fppmodule. As a result of this refactor,src/common/m_boundary_io.fpponly contains routines relevant to boundary condition IO.Closes #(issue number).
Type of change (delete unused ones)
Testing
Checklist
See the developer guide for full coding standards.
GPU changes (expand if you modified
src/simulation/)AI code reviews
Reviews are not retriggered automatically. To request a review, comment on the PR:
@claude full review— Claude full review (also triggers on PR open/reopen/ready)claude-full-review— Claude full review via label