Exawind / amr-wind

AMReX-based structured wind solver
https://exawind.github.io/amr-wind
Other
103 stars 78 forks source link

DRAFT PR: inflow-outflow boundary condition #1066

Open mukul1992 opened 1 month ago

mukul1992 commented 1 month ago

Summary

Enabling the mass_inflow_outflow (MIO) BC which allows for both inflow and outflow cells in a boundary.

Pull request type

Please check the type of change introduced:

Checklist

The following is included:

This PR was tested by running:

Additional background

This functionality would be required for coupling with ERF and was started after discussions with @gdeskos and @mchurchf, along with @asalmgren, as it was a desired functionality within AMR-Wind too. Additionally, @hgopalan has expressed interest, and @marchdf has helped along the way.

Description

The changes required can be organized into six categories:

  1. adding MIO as one of the BCs, mapping it to a custom math BC, and adding the mechanics required for enabling UDFs.
  2. the new TwoLayer UDF for testing, currently it implements a simple two-layer x-direction flow in opposite directions as a test, but this UDF can be modified to test progressively more complex cases, finishing with a regression test case such as vortex initialization and advection across the boundary.
  3. the custom Neumann function for filling the outflow boundary cells in MassInflowOutflowBC.cpp
  4. adding the inflow and outflow conditions in the WENO upwinding functions to map to ext_dir and foextrap behavior respectively.
  5. calling the enforceSolvability routine in AMReX-Hydro before the mac-projection, which adjusts the outflux to match with influx (will link to the corresponding PR in Hydro).
  6. the cmake scripts and input files for testing, these can be reorganized and cleaned up ultimately into a proper regression test as development completes. The input file being used for testing is input_inout.
marchdf commented 1 month ago

Most of my comments right now are just noting the obvious things to clean up before actually merging. Thank you for taking this task on!!

mbkuhn commented 1 month ago

Speaking of merging, it looks like there are some complicated merge conflicts between this branch and main. It may be helpful to rebase your branch to upstream/main to remove some of those conflicts and get the unrelated parts of this branch up-to-date. Removing the merge conflicts will also allow the CI tests to run.

mukul1992 commented 1 month ago

@marchdf Yes, I will certainly clean up all the debug statements and incorporate other changes you recommended.

@mbkuhn Yes, I will do the rebase over the next week along with cleaning things up.

Thanks for the early feedback!

mukul1992 commented 3 weeks ago

PS. I have been able to rebase this code with the latest changes in the Exawind/amr-wind repo. I have also updated the amrex submod in the index (let me know if I did it incorrectly). And have updated the BCType from user_1 to direction_dependent in the code. And finally, here's the draft PR for AMReX-Hydro that includes the outflow-correction for enforcing solvability.