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

Clean up field ionization #1184

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 0 additions & 65 deletions src/particles/particles_utils/FieldGather.H
Original file line number Diff line number Diff line change
Expand Up @@ -97,71 +97,6 @@ void doGatherShapeN (const amrex::Real xp,



/**
* \brief Field gather for a single particle
*
* \param[in] xp Particle position x
* \param[in] yp Particle position y
* \param[in,out] ExmByp Field on particle: Ex - c*By
* \param[in,out] EypBxp Field on particle: Ey + c*Bx
* \param[in,out] Ezp Field on particle: Ez
* \param[in,out] Bxp Magnetic field on particles: Bx
* \param[in,out] Byp Magnetic field on particles: By
* \param[in,out] Bzp Magnetic field on particles: Bz
* \param[in] slice_arr slice array for WhichSlice::This
* \param[in] psi_comp field component for field Psi
* \param[in] ez_comp field array for field Ez
* \param[in] bx_comp field array for field Bx
* \param[in] by_comp field array for field By
* \param[in] bz_comp field array for field Bz
* \param[in] dx_inv inverse cell spacing in x direction
* \param[in] dy_inv inverse cell spacing in y direction
* \param[in] x_pos_offset offset for converting positions to indexes
* \param[in] y_pos_offset offset for converting positions to indexes
* \param[in] depos_order_xy Order of the transverse shape factor for the field gather
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void doGatherShapeN (const amrex::ParticleReal xp,
const amrex::ParticleReal yp,
amrex::ParticleReal& ExmByp,
amrex::ParticleReal& EypBxp,
amrex::ParticleReal& Ezp,
amrex::ParticleReal& Bxp,
amrex::ParticleReal& Byp,
amrex::ParticleReal& Bzp,
Array3<amrex::Real const> const& slice_arr,
const int psi_comp,
const int ez_comp,
const int bx_comp,
const int by_comp,
const int bz_comp,
const amrex::Real dx_inv,
const amrex::Real dy_inv,
const amrex::Real x_pos_offset,
const amrex::Real y_pos_offset,
const int depos_order_xy)
{
if (depos_order_xy == 0) {
doGatherShapeN<0>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
dx_inv, dy_inv, x_pos_offset, y_pos_offset);
} else if (depos_order_xy == 1) {
doGatherShapeN<1>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
dx_inv, dy_inv, x_pos_offset, y_pos_offset);
} else if (depos_order_xy == 2) {
doGatherShapeN<2>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
dx_inv, dy_inv, x_pos_offset, y_pos_offset);
} else if (depos_order_xy == 3) {
doGatherShapeN<3>(xp, yp, ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
dx_inv, dy_inv, x_pos_offset, y_pos_offset);
}
}



/**
* \brief Field gather for a single particle of just Bx and By
*
Expand Down
1 change: 0 additions & 1 deletion src/particles/plasma/MultiPlasma.H
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public:
*/
void DoFieldIonization (const int lev, const amrex::Geometry& geom, const Fields& fields);

bool IonizationOn () const;
/** \brief whether any plasma species uses a neutralizing background, e.g. no ion motion */
bool AnySpeciesNeutralizeBackground () const;

Expand Down
10 changes: 0 additions & 10 deletions src/particles/plasma/MultiPlasma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,6 @@ MultiPlasma::DoFieldIonization (
}
}

bool
MultiPlasma::IonizationOn () const
{
bool ionization_on = false;
for (auto& plasma : m_all_plasmas) {
if (plasma.m_can_ionize) ionization_on = true;
}
return ionization_on;
}

bool
MultiPlasma::AnySpeciesNeutralizeBackground () const
{
Expand Down
17 changes: 13 additions & 4 deletions src/particles/plasma/PlasmaParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,17 @@ IonizationModule (const int lev,

long num_ions = ptile_ion.numParticles();

amrex::ParallelForRNG(num_ions,
[=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine) {
amrex::AnyCTO(
amrex::TypeList<
amrex::CompileTimeOptions<0, 1, 2, 3>
>{}, {
Hipace::m_depos_order_xy
},
[&] (auto cto_func) {
amrex::ParallelForRNG(num_ions, cto_func);
},
[=] AMREX_GPU_DEVICE (long ip, const amrex::RandomEngine& engine,
auto depos_order_xy) {

if (amrex::ConstParticleIDWrapper(idcpup[ip]) < 0 ||
amrex::ConstParticleCPUWrapper(idcpup[ip]) != lev) return;
Expand All @@ -345,10 +354,10 @@ IonizationModule (const int lev,
amrex::ParticleReal ExmByp = 0., EypBxp = 0., Ezp = 0.;
amrex::ParticleReal Bxp = 0., Byp = 0., Bzp = 0.;

doGatherShapeN(xp, yp,
doGatherShapeN<depos_order_xy>(xp, yp,
ExmByp, EypBxp, Ezp, Bxp, Byp, Bzp, slice_arr,
psi_comp, ez_comp, bx_comp, by_comp, bz_comp,
dx_inv, dy_inv, x_pos_offset, y_pos_offset, depos_order_xy);
dx_inv, dy_inv, x_pos_offset, y_pos_offset);

const amrex::ParticleReal Exp = ExmByp + Byp * phys_const.c;
const amrex::ParticleReal Eyp = EypBxp - Bxp * phys_const.c;
Expand Down
Loading