- 
                Notifications
    You must be signed in to change notification settings 
- Fork 121
Removement of Duplicate Weno Interpolation of Velocity Field #1005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| PR Reviewer Guide 🔍Here are some key observations to aid the review process: 
 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level Suggestion
Refactor the code to eliminate duplication between the viscous and non-viscous logic paths. Instead of duplicating the reconstruction calls, determine the variable ranges based on viscosity first, then use a single block of code for the reconstruction. [High-level, importance: 8]
Solution Walkthrough:
Before:
if (.not. surface_tension) then
    if (all(Re_size == 0)) then
        ! Reconstruct all variables (1 to sys_size)
        call s_reconstruct_cell_boundary_values(...)
    else
        ! Reconstruct non-velocity variables
        call s_reconstruct_cell_boundary_values(...) ! for 1:contxe
        call s_reconstruct_cell_boundary_values(...) ! for E_idx:sys_size
    end if
else
    if (all(Re_size == 0)) then
        ! Reconstruct in 3 parts, including velocities
        call s_reconstruct_cell_boundary_values(...) ! for 1:E_idx-1
        ...
    else
        ! Reconstruct in 3 parts, excluding velocities
        call s_reconstruct_cell_boundary_values(...) ! for 1:contxe
        ...
    end if
end if
After:
integer :: range1_end
if (all(Re_size == 0)) then
    range1_end = E_idx - 1
else
    range1_end = contxe
end if
if (.not. surface_tension) then
    if (all(Re_size == 0)) then
        call s_reconstruct_cell_boundary_values(...) ! for 1:sys_size
    else
        call s_reconstruct_cell_boundary_values(...) ! for 1:contxe
        call s_reconstruct_cell_boundary_values(...) ! for E_idx:sys_size
    end if
else
    call s_reconstruct_cell_boundary_values(...) ! for 1:range1_end
    call s_reconstruct_cell_boundary_values_first_order(...) ! for E_idx
    call s_reconstruct_cell_boundary_values(...) ! for E_idx+1:sys_size
end if
| iv%beg = E_idx + 1; iv%end = sys_size | ||
| call s_reconstruct_cell_boundary_values( & | ||
| q_prim_qp%vf(iv%beg:iv%end), & | ||
| qL_rsx_vf, qL_rsy_vf, qL_rsz_vf, & | ||
| qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, & | ||
| id) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Add a conditional check to ensure the reconstruction call for variables after the energy index E_idx is only performed if such variables exist, preventing a potentially problematic call with a zero-sized array. [possible issue, importance: 5]
| iv%beg = E_idx + 1; iv%end = sys_size | |
| call s_reconstruct_cell_boundary_values( & | |
| q_prim_qp%vf(iv%beg:iv%end), & | |
| qL_rsx_vf, qL_rsy_vf, qL_rsz_vf, & | |
| qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, & | |
| id) | |
| if (E_idx < sys_size) then | |
| iv%beg = E_idx + 1; iv%end = sys_size | |
| call s_reconstruct_cell_boundary_values( & | |
| q_prim_qp%vf(iv%beg:iv%end), & | |
| qL_rsx_vf, qL_rsy_vf, qL_rsz_vf, & | |
| qR_rsx_vf, qR_rsy_vf, qR_rsz_vf, & | |
| id) | |
| end if | 
| Codecov Report❌ Patch coverage is  
 Additional details and impacted files@@            Coverage Diff             @@
##           master    #1005      +/-   ##
==========================================
- Coverage   41.91%   41.89%   -0.03%     
==========================================
  Files          69       69              
  Lines       19783    19800      +17     
  Branches     2473     2475       +2     
==========================================
+ Hits         8293     8296       +3     
- Misses       9952     9964      +12     
- Partials     1538     1540       +2     ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
 | 
User description
Description
Please include a summary of the changes and the related issue(s) if they exist.
Please also include relevant motivation and context.
Fixes #(issue) [optional]
Type of change
Please delete options that are not relevant.
Scope
If viscosity is enabled then in the rhs module (m_rhs.fpp) the s_get_viscous subroutine is called (line 709). Inside s_get_viscous (in the m_viscous.fpp module) the s_reconstruct_cell_boundary_values_visc (line 557) is called, and this subroutine implements weno interpolation for the velocities. Afterwards in the m_rhs module the Weno reconstruction is being implemented for i=1,sys_size. This was removed now and the weno interpolation is implemented only one time for the velocity field. This bug somehow introduced in the past for example in MFC 4.0, it did not exist https://github.com/MFlowCode/MFC/blob/v4.0.0/src/simulation_code/m_rhs.f90 (line 1137)
If you cannot check the above box, please split your PR into multiple PRs that each have a common goal.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration
Test Configuration:
My Laptop
Checklist
docs/)examples/that demonstrate my new feature performing as expected.They run to completion and demonstrate "interesting physics"
./mfc.sh formatbefore committing my codeIf your code changes any code source files (anything in
src/simulation)To make sure the code is performing as expected on GPU devices, I have:
nvtxranges so that they can be identified in profiles./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR./mfc.sh run XXXX --gpu -t simulation --rsys --hip-trace, and have attached the output file and plain text results to this PR.PR Type
Bug fix
Description
Eliminate duplicate WENO interpolation for velocity fields when viscosity is enabled
Add conditional logic to skip velocity reconstruction when already done in viscous module
Restructure reconstruction calls based on Reynolds number configuration
Diagram Walkthrough
File Walkthrough
m_rhs.fpp
Conditional WENO reconstruction to eliminate velocity duplicationsrc/simulation/m_rhs.fpp
Re_size) to preventduplicate WENO reconstruction
other field variables