-
Notifications
You must be signed in to change notification settings - Fork 199
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
Output the potential phi on the macroparticles #4599
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…output_particle_phi
@@ -548,48 +548,6 @@ for (unsigned i = 0, n = particle_diags.size(); i < n; ++i) { | |||
pinned_pc->make_alike<amrex::PinnedArenaAllocator>() : | |||
pc->make_alike<amrex::PinnedArenaAllocator>(); | |||
|
|||
// names of amrex::Real and int particle attributes in SoA data |
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.
I had to move this code further down, so that it comes after tmp.AddRealComp("phi");
(This is because the code below reads tmp.getParticleRuntimeComps();
and sets the output flags accordingly.)
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.
LGTM - just a small separation of the functional block added into a function maybe? :)
Source/Diagnostics/WarpXOpenPMD.cpp
Outdated
"Output of the electrostatic potential (phi) on the particles was requested, " | ||
"but this is only available with `diag_type = Full`."); | ||
tmp.AddRealComp("phi"); | ||
tmp.defineAllParticleTiles(); |
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.
This line should not be needed anymore as of AMReX 24.04 :)
// Gather the electrostatic potential (phi) on the macroparticles | ||
if ( particle_diags[i].m_plot_phi ) { | ||
WARPX_ALWAYS_ASSERT_WITH_MESSAGE( |
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.
Can you make this if block a function call please so it does separate out nicely and does not make this sub-function longer? I would call it add_phi_component
or so and also declare it in ParticleIO.H
?
Co-authored-by: Axel Huebl <[email protected]>
#ifdef AMREX_USE_OMP | ||
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion()) | ||
#endif | ||
for (int lev=0; lev<=warpx.finestLevel(); lev++) { |
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.
for (int lev=0; lev<=warpx.finestLevel(); lev++) { | |
for (int lev=0; lev<=tmp.finestLevel(); lev++) { |
const amrex::Geometry& geom = warpx.Geom(lev); | ||
auto plo = geom.ProbLoArray(); | ||
auto dxi = geom.InvCellSizeArray(); | ||
amrex::MultiFab const& phi = warpx.getField( FieldType::phi_fp, lev, 0 ); |
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.
For less overhead, we should add a helper that returns an mf on all levels. -> follow-up pr
This adds the option for the user to output the field
phi
on the macroparticles.The fields are gathered after particles have been filtered for output. As a consequence, the particles are in pinned memory, when the gather kernel is called, which could be slow if this diagnostic is done frequently and/or on a large number of particles.
The automated test looks at the case of an electrostatic sphere exploding under its own space charge (Coulomb explosition). In this process, electrostatic potential energy (space charge) is converted into kinetic energy (explosion velocity). The test uses
phi
on the particles to compute the potential energy.TODO in follow-up PRs: