Skip to content

Commit

Permalink
Convert IntVect to IntVectND (#3969)
Browse files Browse the repository at this point in the history
## Summary

As described in #3955, this PR converts IntVect to the n dimensional
IntVectND and adds
`using IntVect = IntVectND<AMREX_SPACEDIM>;`. Additionally, deduction
guides, support for structured bindings and the helper functions
`IntVectCat`, `IntVectSplit` and `IntVectResize` were added to
IntVectND.

## Additional background

Using structured binding support of `amrex::GpuTuple`, the following
code should work (on GPU):
```C++
int i, j, k, n;
...
// amrex::IntVectND<4>
amrex::IntVectND iv1 (i, j, k, n);
// amrex::IntVectND<8>
amrex::IntVectND iv2 = amrex::IntVectCat(iv1, iv1);
// ... = amrex::GpuTuple<amrex::IntVectND<3>,amrex::IntVectND<2>,amrex::IntVectND<2>,amrex::IntVectND<1>>
auto [iv3, iv4, iv5, iv6] = amrex::IntVectSplit<3,2,2,1>(iv2); 
// int, int, int = amrex::IntVectND<3>
auto [i2, j2, k2] = iv3;
// int = amrex::IntVectND<1>
auto [n2] = iv6;

assert(i==i2 && j==j2 && k==k2 && n==n2);
```
  • Loading branch information
AlexanderSinn committed Jun 12, 2024
1 parent 5bdac91 commit dad25a4
Show file tree
Hide file tree
Showing 5 changed files with 749 additions and 351 deletions.
4 changes: 3 additions & 1 deletion Src/Base/AMReX_BaseFwd.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class DistributionMapping;
class Geometry;

class Box;
class IntVect;
template<int dim>
class IntVectND;
using IntVect = IntVectND<AMREX_SPACEDIM>;
class IndexType;
struct Dim3;
struct XDim3;
Expand Down
Loading

0 comments on commit dad25a4

Please sign in to comment.