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

Fix bug with MLMG solver, always pass ghost cells to SumBoundary #4078

Merged
merged 3 commits into from
Jul 27, 2023

Conversation

EZoni
Copy link
Member

@EZoni EZoni commented Jul 12, 2023

Following up on a bug raised by @aeriforme related to the convergence of the MLMG solver, and based on a comment posted on Slack by @WeiqunZhang (channel #general, May 30, 2023),

There are three versions of SumBoundary's in ablastr/utils/Communication.cpp. Their differences are about the number of ghost cells included in the operation. I think we should remove two of them and force us to explicitly think and state the number of source and destination ghost cells.

let's try to keep only the most general version of SumBoundary (the last one among the three shown below)

void SumBoundary (amrex::MultiFab &mf,
bool do_single_precision_comms,
const amrex::Periodicity &period = amrex::Periodicity::NonPeriodic());
void SumBoundary (amrex::MultiFab &mf,
int start_comp,
int num_comps, amrex::IntVect ng,
bool do_single_precision_comms,
const amrex::Periodicity &period = amrex::Periodicity::NonPeriodic());
void
SumBoundary (amrex::MultiFab &mf,
int start_comp,
int num_comps,
amrex::IntVect src_ng,
amrex::IntVect dst_ng,
bool do_single_precision_comms,
const amrex::Periodicity &period = amrex::Periodicity::NonPeriodic());

and request that developers pass the number of source and destination ghost cells explicitly, each time.

@aeriforme @WeiqunZhang
Do you have a workflow to test this PR on the MLMG convergence bug? Did you expect SumBoundary to be called in many other parts of the code? I found only a few instances related to the deposition of the charge density rho, and I'm not sure which one(s) of these should use rho->nGrowVect() instead of amrex::IntVect(0) as dst_ng in order to fix the MLMG convergence bug. Do you know?

@ax3l @RemiLehe
Please feel free to comment or suggest alternative solutions.
Here I'm trying to implement @WeiqunZhang's idea above.

@EZoni EZoni added bug Something isn't working bug: affects latest release Bug also exists in latest release version component: parallelization Guard cell exchanges and particle redistribution component: ABLASTR components shared with other PIC codes labels Jul 12, 2023
Source/Particles/MultiParticleContainer.cpp Outdated Show resolved Hide resolved
Source/Particles/WarpXParticleContainer.cpp Outdated Show resolved Hide resolved
Source/Particles/WarpXParticleContainer.cpp Outdated Show resolved Hide resolved
@EZoni EZoni changed the title [WIP] Must pass number of ghost cells to call SumBoundary Must pass number of ghost cells to call SumBoundary Jul 24, 2023
@EZoni EZoni changed the title Must pass number of ghost cells to call SumBoundary Fix bug with MLMG solver, always pass ghost cells to SumBoundary Jul 24, 2023
@ax3l
Copy link
Member

ax3l commented Jul 24, 2023

Something to double-check in ImpactX, too?
https://github.com/ECP-WarpX/impactx/tree/development/src/particles/spacecharge

@EZoni
Copy link
Member Author

EZoni commented Jul 24, 2023

@lijiangdong1999
This is the PR mentioned on Gitter, which you can try to run on your AWAKE input setup.

@lijiangdong1999
Copy link

lijiangdong1999 commented Jul 25, 2023

@lijiangdong1999 This is the PR mentioned on Gitter, which you can try to run on your AWAKE input setup.

Thanks for your reply. But I use spack to install warpx, I can't find the "Source/Particles/WarpXParticleContainer.cpp".

Copy link
Member Author

@EZoni EZoni left a comment

Choose a reason for hiding this comment

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

Add inline comments on possible performance optimization.

Source/Particles/MultiParticleContainer.cpp Show resolved Hide resolved
Source/Particles/WarpXParticleContainer.cpp Show resolved Hide resolved
Source/Particles/WarpXParticleContainer.cpp Outdated Show resolved Hide resolved
@EZoni
Copy link
Member Author

EZoni commented Jul 25, 2023

For future reference, on this input deck, the MLMG solver fails on the development branch and converges on this branch.

@ax3l ax3l merged commit 1f1b15b into ECP-WarpX:development Jul 27, 2023
32 checks passed
@EZoni EZoni deleted the sum_boundary branch July 9, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: affects latest release Bug also exists in latest release version bug Something isn't working component: ABLASTR components shared with other PIC codes component: parallelization Guard cell exchanges and particle redistribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants