Skip to content
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

GRCBC #698

Merged
merged 22 commits into from
Nov 17, 2024
Merged

GRCBC #698

merged 22 commits into from
Nov 17, 2024

Conversation

anandrdbz
Copy link
Contributor

@anandrdbz anandrdbz commented Nov 6, 2024

Description

Generalized CBC implementation given by Pirozolli and Colonius (2013). Provides the option to supplement non-reflecting subsonic inflow and subsonic outflow boundary conditions (bc = -7 and -8) with additional terms. Their effect can be turned on by setting bc%grcbc_in and bc%grcbc_out to be true (false by default). Additional option to turn on bc%grcbc_vel_out that includes outflow velocity specification.

If turned on, inflow boundary conditions require inflow velocities, pressure ,density and volume fraction specifications outside the domain. For outflow conditions, pressure and normal velocity specifications needed, although the normal velocity can be turned off using bc%grcbc_vel_out.

Refer to case file 2D_ibm_steady_shock for an example with GRCBC inflow conditions for a shock with a given velocity.

2 additional cases added to the examples directory.

2D_zero_circ_vortex advects a zero circulation isentropic vortex in the middle of the domain from left to right with Subsonic Inflow and subsonic outflow boundary conditions.

2D_acoustic_pulse has a radially outward pressure pulse with subsonic outflow boundary conditions on all 4 sides.

Fixes #(issue) [optional]

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • [x ] New feature (non-breaking change which adds functionality)
  • Something else

Scope

  • [ x] This PR comprises a set of related changes with a common goal

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 A
  • Test B

Test Configuration:

  • What computers and compilers did you use to test this:

Checklist

  • I have added comments for the new code
  • I added Doxygen docstrings to the new code
  • I have made corresponding changes to the documentation (docs/)
  • I have added regression tests to the test suite so that people can verify in the future that the feature is behaving as expected
  • I have added example cases in examples/ that demonstrate my new feature performing as expected.
    They run to completion and demonstrate "interesting physics"
  • I ran ./mfc.sh format before committing my code
  • New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

If 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:

  • Checked that the code compiles using NVHPC compilers
  • Checked that the code compiles using CRAY compilers
  • Ran the code on either V100, A100, or H100 GPUs and ensured the new feature performed as expected (the GPU results match the CPU results)
  • Ran the code on MI200+ GPUs and ensure the new features performed as expected (the GPU results match the CPU results)
  • Enclosed the new feature via nvtx ranges so that they can be identified in profiles
  • Ran a Nsight Systems profile using ./mfc.sh run XXXX --gpu -t simulation --nsys, and have attached the output file (.nsys-rep) and plain text results to this PR
  • Ran an Omniperf profile using ./mfc.sh run XXXX --gpu -t simulation --omniperf, and have attached the output file and plain text results to this PR.
  • Ran my code using various numbers of different GPUs (1, 2, and 8, for example) in parallel and made sure that the results scale similarly to what happens if you run without the new code/feature

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 25 lines in your changes missing coverage. Please review.

Project coverage is 42.98%. Comparing base (9c2d3d9) to head (3792b88).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_cbc.fpp 28.57% 17 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #698      +/-   ##
==========================================
+ Coverage   42.96%   42.98%   +0.01%     
==========================================
  Files          61       61              
  Lines       16339    16384      +45     
  Branches     1881     1889       +8     
==========================================
+ Hits         7020     7042      +22     
- Misses       8278     8293      +15     
- Partials     1041     1049       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sbryngelson
Copy link
Member

Please fix merge conflicts

@anandrdbz
Copy link
Contributor Author

@sbryngelson the checks passed after conflict resolution, so should be ready for merge

@sbryngelson
Copy link
Member

thanks @anandrdbz I will review this soon!

@sbryngelson sbryngelson requested a review from wilfonba November 11, 2024 21:11
| `bc_[x,y,z]%alpha_rho_in` | Real Array | Inflow density |
| `bc_[x,y,z]%alpha_in` | Real Array | Inflow void fraction |

*: This boundary condition can be used for subsonic inflow (`bc_[x,y,z]%[beg,end]` = -7) and subsonic outflow (`bc_[x,y,z]%[beg,end]` = -8) characteristic boundary conditions. These are based on [Pirozzoli (2013)](references.md#Pirozzoli13). This enables to provide inflow and outflow conditions outside the computational domain. The parameters associated with this feature are listed in table [Generalized Characteristic Boundary conditions](#generalized-characteristic-boundary-conditions).
Copy link
Member

Choose a reason for hiding this comment

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

where does the * go?

Copy link
Member

Choose a reason for hiding this comment

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

it doesn't seem to be attached to any variables

Copy link
Member

Choose a reason for hiding this comment

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

The parameters associated with this feature are listed in table Generalized Characteristic Boundary conditions.

This seems to be obvious given that the text is right below the table, no?

@@ -102,6 +102,18 @@ module m_cbc
integer :: cbc_dir, cbc_loc
!$acc declare create(dj, bcxb, bcxe, bcyb, bcye, bczb, bcze, cbc_dir, cbc_loc)

real(kind(0d0)) :: ux_in, ux_out, vx_in, vx_out, wx_in, wx_out, presx_in, presx_out, Delx_in, Delx_out
Copy link
Member

Choose a reason for hiding this comment

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

you need docstrings/doxygen and comments. also this is a very messy way to implement this. you have [u/v/w][x/y/z]_[in/out] for a total of 18 variables. these could easily be stored in a single 3,3,2 array.

!$acc declare create(uy_in, uy_out, vy_in, vy_out, wy_in, wy_out, presy_in, presy_out, Dely_in, Dely_out)
!$acc declare create(uz_in, uz_out, vz_in, vz_out, wz_in, wz_out, presz_in, presz_out, Delz_in, Delz_out)

real(kind(0d0)), allocatable, dimension(:) :: alpha_rhox_in, alphax_in
Copy link
Member

Choose a reason for hiding this comment

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

same comment as above


#:for CBC_DIR, XYZ in [(1, 'x'), (2, 'y'), (3, 'z')]
if (${CBC_DIR}$ == 1) then
u${XYZ}$_in = bc_${XYZ}$%u_in
Copy link
Member

Choose a reason for hiding this comment

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

why use u/v/w when you can use u(1,2,3)?

@@ -1465,6 +1465,9 @@ contains
!$acc update device(bc_y%vb1, bc_y%vb2, bc_y%vb3, bc_y%ve1, bc_y%ve2, bc_y%ve3)
!$acc update device(bc_z%vb1, bc_z%vb2, bc_z%vb3, bc_z%ve1, bc_z%ve2, bc_z%ve3)

!$acc update device(bc_x%grcbc_in, bc_x%grcbc_out, bc_x%grcbc_vel_out)
Copy link
Member

Choose a reason for hiding this comment

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

9 variables when you could just have one?

Copy link
Member

@sbryngelson sbryngelson left a comment

Choose a reason for hiding this comment

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

lots of messy verbose code that can be easily cleaned up. also only three new tests? should have more.

@sbryngelson sbryngelson added the enhancement New feature or request label Nov 13, 2024
@anandrdbz
Copy link
Contributor Author

@sbryngelson I've made most of the suggested changes, the only repetition is in the bc variables, but this is how it's done for all other cases (separate variables for bc_x, bc_y and bc_z). However in the CBC module this is transformed into an array of size (3) as suggested. Most of the verbosity in the code should've been removed now. And I've added 3 more test cases; these should cover every possible line I've added in CBC, so further tests are unnecessary. I've added a few more comments in the CBC file as well

@sbryngelson
Copy link
Member

@sbryngelson I've made most of the suggested changes, the only repetition is in the bc variables, but this is how it's done for all other cases (separate variables for bc_x, bc_y and bc_z). However in the CBC module this is transformed into an array of size (3) as suggested. Most of the verbosity in the code should've been removed now. And I've added 3 more test cases; these should cover every possible line I've added in CBC, so further tests are unnecessary. I've added a few more comments in the CBC file as well

Thanks I will review again shortly!

@anandrdbz
Copy link
Contributor Author

@sbryngelson For some reason the job on Phoenix has been in queue for 2 days, every other test has passed and I've checked the test suite on phoenix on an interactive node

@sbryngelson
Copy link
Member

sbryngelson commented Nov 16, 2024

@anandrdbz Yes those nodes are backed up big time for some reason. I'll merge it once it passes you don't have to do anything.

@sbryngelson sbryngelson merged commit ff6e3e0 into MFlowCode:master Nov 17, 2024
25 checks passed
fomeally pushed a commit to fomeally/MFC that referenced this pull request Nov 19, 2024
Co-authored-by: Anand <anand@lawn-128-61-28-98.lawn.gatech.edu>
Co-authored-by: Anand <anand@lawn-128-61-77-225.lawn.gatech.edu>
Co-authored-by: Anand <anand@ipsec-10-2-68-64.vpn.gatech.edu>
Co-authored-by: Anand Radhakrishnan <aradhakr34@login05.frontier.olcf.ornl.gov>
Co-authored-by: Anand <anand@Anands-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants