-
Notifications
You must be signed in to change notification settings - Fork 18
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
reset particlecontainer dm and ba #199
Conversation
I think that maybe there is an inconsistency between the z positions set during https://github.com/AMReX-Codes/amrex/blob/development/Src/Particle/AMReX_ParticleUtil.H#L236 maps to |
Thanks for your reply! So in the way the code is written, the slice domain should match exactly the last cell (in z) of the 3D domain. This means that the BoxArray should have only 1 cell (indexed 0) in the z direction, the prob_domain should be the left and right edge of the last cell, etc. Note that the particles are still given a z position consistent with that. In the example I am running, I would expect, for
so I checked that these things are right in |
m_plasma_container.SetParticleBoxArray(lev, m_slice_ba); | ||
m_plasma_container.SetParticleDistributionMap(lev, m_slice_dm); | ||
m_plasma_container.SetParticleGeometry(lev, m_slice_geom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the lines I am talking about.
@atmyers I think I see what is happening here. When I add some print statements to the lines where we reset the plasma container's geometry, BA and DM, replacing m_plasma_container.SetParticleBoxArray(lev, m_slice_ba);
m_plasma_container.SetParticleDistributionMap(lev, m_slice_dm);
m_plasma_container.SetParticleGeometry(lev, m_slice_geom); by std::cout<<"m_slice_ba = \n"<<m_slice_ba<<'\n';
std::cout<<"before set: m_plasma_container.ParticleBoxArray(lev) = \n"<<m_plasma_container.ParticleBoxArray(lev)<<'\n';
m_plasma_container.SetParticleBoxArray(lev, m_slice_ba);
std::cout<<"after set: m_plasma_container.ParticleBoxArray(lev) = \n"<<m_plasma_container.ParticleBoxArray(lev)<<'\n';
std::cout<<"m_slice_dm = \n"<<m_slice_dm<<'\n';
std::cout<<"before set: m_plasma_container.ParticleDistributionMap(lev) = \n"<<m_plasma_container.ParticleDistributionMap(lev)<<'\n';
m_plasma_container.SetParticleDistributionMap(lev, m_slice_dm);
std::cout<<"before set: m_plasma_container.ParticleDistributionMap(lev) = \n"<<m_plasma_container.ParticleDistributionMap(lev)<<'\n';
std::cout<<"m_slice_geom = \n"<<m_slice_geom<<"\n\n";
std::cout<<"before set: m_plasma_container.Geom(lev) = \n"<<m_plasma_container.Geom(lev)<<"\n\n";
m_plasma_container.SetParticleGeometry(lev, m_slice_geom);
std::cout<<"after set: m_plasma_container.Geom(lev) = \n"<<m_plasma_container.Geom(lev)<<"\n\n"; I get the following output:
so it seems that the box array (and probably the DM, but that's hard to say) is properly reset, but the Geometry is not. @atmyers is this expected? Do you see something wrong in this code, or is this on the AMReX side? Note that, printing the particles longitudinal positions in |
I think it's on the AMReX side - the problem seems to be that |
Both would work for me, but indeed the first one seems much easier to do. Should we try this? |
Is this a change in AMReX, or should we override |
Yes could you try this branch: AMReX-Codes/amrex#1470 |
This is a change in AMReX, no changes to Hipace++ should be needed. |
Hi @MaxThevenet, Could you try AMReX-Codes/amrex#1532 and see if it fixes this issue? Thanks, |
@atmyers this works like a charm! More precisely, after orthogonal changes in other PRs in Hipace++, this PR did not even run anymore, with an error in |
Cool, that has been merged into AMReX now. |
Yep, thanks, I just updated this PR accordingly. I also removed the WIP tag, this is ready for review. Once this is merged, we can implement the longitudinal parallelisation for plasma particles. |
Thanks for your review :) |
This PR proposes to define the PlasmaParticleContainer on the slice domain, instead of on the whole domain, which makes more sense for it.
Old implementation
Fields::AllocData
.PlasmaParticleContainer
is defined on the whole simulation domain, we just pay attention that all particles have the same z (taken to be the center of the last cell in z)New implementation
Geometry
,DistributionMapping
andBoxArray
are defined by function Hipace::DefineSliceGDB called inHipace::MakeNewLevelFromScratch
, and store asHipace
member variables.Fields::AllocData
to initialized the slice MFHipace::InitData
, where we call the plasmaparticlecontainer Set functions for Geom, BA, DM before callingPlasmaParticleContainer::InitData
.This PR works OK for most tests, only the plasma z component checksum fails for the linear wake. But the z positions of plasma particles are meaningless, so this is not a problem (I would be curious to understand the change though).
However, when running in Debug mode, the code crashes at the
AMREX_ASSERT(OK());
assertion at the end ofPlasmaParticleContainer::InitParticles
, and putting print statements couldn't help me understand this issue. @atmyers could you have a look, and let me know if you see something off in this PR?const
isconst
)