AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
536 stars 343 forks source link

Convert Box to BoxND #4016

Closed AlexanderSinn closed 2 months ago

AlexanderSinn commented 3 months ago

Summary

Similar to #3969 and #3988 but for Box.

Additional background

It should be checked that the changes to BoxIndexer do not affect the compiled GPU code. In my testing, it gives the same performance as development. 

Example usage:

amrex::BoxND b1{amrex::IntVectND{1,2,3}, amrex::IntVectND{4,5,6}, amrex::IntVectND{1,0,1}};
// ((1,2,3) (4,5,6) (1,0,1))
auto b2 = amrex::BoxCat(b1, b1, b1);
// ((1,2,3,1,2,3,1,2,3) (4,5,6,4,5,6,4,5,6) (1,0,1,1,0,1,1,0,1))
auto [b3, b4, b5, b6, b7] = amrex::BoxSplit<1, 4, 2, 1, 1>(b2);
// ((1) (4) (1))((2,3,1,2) (5,6,4,5) (0,1,1,0))((3,1) (6,4) (1,1))((2) (5) (0))((3) (6) (1))
auto b8 = amrex::BoxResize<2>(b4);
// ((2,3) (5,6) (0,1))
auto b9 = amrex::BoxResize<5>(b8);
// ((2,3,0,0,0) (5,6,0,0,0) (0,1,0,0,0))

Checklist

The proposed changes:

AlexanderSinn commented 2 months ago

I added IntVectND::dim3(int fill_extra) to make it easier to implement BoxND functions such as end and length. It looks like pyamrex needs an overload_cast for dim3() now.

PR: https://github.com/AMReX-Codes/pyamrex/pull/345

ax3l commented 2 months ago

https://github.com/AMReX-Codes/pyamrex/pull/345 merged - thanks!

WeiqunZhang commented 2 months ago

LGTM. I will do one more pass tomorrow.