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

WarpX class: move shiftMF to anonymous namespace in WarpXMovingWindow.cpp #5609

Merged

Conversation

lucafedeli88
Copy link
Member

@lucafedeli88 lucafedeli88 commented Jan 27, 2025

This PR moves the static function shiftMF from the WarpX class to an anonymous namespace in WarpXMovingWindow.cpp, where it is actually used.
This is done to simplify the Warpx class.

@lucafedeli88 lucafedeli88 added the cleaning Clean code, improve readability label Jan 27, 2025
@lucafedeli88 lucafedeli88 changed the title [WIP] WarpX class: move shiftMF to anonymous namespace in WarpXMovingWindow.cpp WarpX class: move shiftMF to anonymous namespace in WarpXMovingWindow.cpp Jan 29, 2025
Source/Utils/WarpXMovingWindow.cpp Outdated Show resolved Hide resolved
Source/Utils/WarpXMovingWindow.cpp Show resolved Hide resolved
const int nc = mf.nComp();
const amrex::IntVect& ng = mf.nGrowVect();

AMREX_ALWAYS_ASSERT(ng[dir] >= std::abs(num_shift));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, this was AMREX_ALWAYS_ASSERT(ng[dir] >= num_shift);
however, it seems to me that, since num_shift can be negative, we need an absolute value here. What do you think @ax3l ?

Copy link
Member

@ax3l ax3l Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, we can shift backwards (or just know it is technically possible because num_shift is an int)? :D

Either way, LGTM ;)

} else {
amrex::IntVect ng_mw = amrex::IntVect::TheUnitVector();
// Enough guard cells in the MW direction
ng_mw[dir] = std::abs(num_shift);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. This was ng_mw[dir] = num_shift;, but I think that the absolute value is necessary here.

@lucafedeli88 lucafedeli88 requested a review from ax3l January 30, 2025 15:34
@ax3l ax3l self-assigned this Feb 4, 2025
@ax3l ax3l enabled auto-merge (squash) February 11, 2025 05:07
@ax3l ax3l merged commit 6dfa3ba into ECP-WarpX:development Feb 11, 2025
37 checks passed
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

Successfully merging this pull request may close these issues.

2 participants