AMReX-Fluids / AMReX-Hydro

AMReX-based hydro routines
https://amrex-fluids.github.io/amrex-hydro/docs_html
Other
11 stars 24 forks source link

Enforcing inflow-outflow boundary solvability #129

Open mukul1992 opened 1 month ago

mukul1992 commented 1 month ago

Introduces routines to calculate outflux and influx at the in-out boundaries and then correct the outflux to match with influx.

Three steps:

  1. set masks for tagging cells at the boundary for inflow or outflow
  2. calculate influx and outflux using reductions
  3. correct outflow velocities using the correction factor
mukul1992 commented 2 weeks ago

Hello @cgilet @ajnonaka Ann asked me to ping you for reviewing this PR. Could you please take a look? I'd appreciate it.

We are adding a "mass-inflow-outflow" BC in amr-wind that can manage both inflow and outflow cells within the same boundary. The strategy is to scale the outflow to match with the inflow to enforce solvability and then use Neumann conditions for the MAC/nodal projections. The functions here aim to achieve the "outflow-correction" part.

I think the only thing currently missing is the accompanying documentation. I am figuring out how to work well with the rst files on my computer. Meanwhile I'm attaching a screenshot of the implementation. While the language here is for the MAC-projection, the function is expected to handle both cell-centered and face-centered velocities.

Screenshot 2024-07-01 at 4 43 04 PM

asalmgren commented 1 week ago

Or you can still treat them like bools so have in_mask be 1 if inflow and 0 if outflow ...

On Tue, Jul 2, 2024 at 10:57 AM Mukul Dave @.***> wrote:

@.**** commented on this pull request.

In Utils/hydro_enforce_inout_solvability.cpp https://github.com/AMReX-Fluids/AMReX-Hydro/pull/129#discussion_r1662951155 :

+

  • // create a 2D box normal to dir at the low/high bndry
  • Box box2d(box); box2d.setRange(dir, bndry);
  • auto vel_arr = vel_mf->array(mfi);
  • auto in_mask = inflow_mask.array(mfi);
  • auto out_mask = outflow_mask.array(mfi);
  • // tag cells as inflow or outflow by checking vel direction
  • ParallelFor(box2d, [=] AMREX_GPU_DEVICE (int i, int j, int k)
  • {
  • if ((side == Orientation::low && vel_arr(i,j,k) >= 0)
  • || (side == Orientation::high && vel_arr(i,j,k) <= 0)) {
  • in_mask(i,j,k) = 1;
  • } else {
  • out_mask(i,j,k) = 1;

Oh that's a good point! For instance, I could have a value of -1 for inflow and +1 for outflow as these masks are integers and not boolean and then use those values for the if conditions in the reduction.

Thanks, I'll try this out and let you know when I've implemented it.

— Reply to this email directly, view it on GitHub https://github.com/AMReX-Fluids/AMReX-Hydro/pull/129#discussion_r1662951155, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACRE6YSKJWHYXQ5GUTCIHBTZKLSW5AVCNFSM6AAAAABI7BK7QCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDCNJUGUYTQMZYGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Ann Almgren Senior Scientist; Dept. Head, Applied Mathematics Pronouns: she/her/hers

mukul1992 commented 1 week ago

Or you can still treat them like bools so have in_mask be 1 if inflow and 0 if outflow ...

I think that wouldn't work because for the reduction, I also need to differentiate between the interior and boundary cells as the reduction loops over everything. So 0 would be for interior cells and -1, 1 can be for in/outflow. Let me know if there is a better way to do the reduction, we could disucss it tomorrow morning.

mukul1992 commented 1 week ago

I have now added a description to the sphinx docs.