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

Use IntVectExpand or dim3 to reduce dependency on AMREX_SPACEDIM #5265

Open
EZoni opened this issue Sep 13, 2024 · 2 comments
Open

Use IntVectExpand or dim3 to reduce dependency on AMREX_SPACEDIM #5265

EZoni opened this issue Sep 13, 2024 · 2 comments
Assignees
Labels
cleaning Clean code, improve readability

Comments

@EZoni
Copy link
Member

EZoni commented Sep 13, 2024

Another way to write

    const int rj = rr[0];
    const int rk = (AMREX_SPACEDIM > 1) ? rr[1] : 1;
    const int rl = (AMREX_SPACEDIM > 2) ? rr[2] : 1;

would be

    const amrex::IntVectND<3> rr_ex = amrex::IntVectExpand<3>(rr, 1);
    const auto [rj, rk, rl] = rr_ex;

or 

    const auto [rj, rk, rl] = amrex::IntVectExpand<3>(rr, 1);

or 

    const auto [rj, rk, rl] = rr.dim3(1);

(untested)

Originally posted by @AlexanderSinn in #5246 (comment)

@EZoni EZoni self-assigned this Sep 13, 2024
@EZoni
Copy link
Member Author

EZoni commented Sep 13, 2024

Cc: @lucafedeli88 @dpgrote

@EZoni EZoni added the cleaning Clean code, improve readability label Sep 13, 2024
@lucafedeli88
Copy link
Member

On a second thought, this one is actually quite transparent:

    const auto [rj, rk, rl] = amrex::IntVectExpand<3>(rr, 1);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleaning Clean code, improve readability
Projects
None yet
Development

No branches or pull requests

2 participants