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

Use id().is_valid() #1066

Merged
merged 1 commit into from
Feb 22, 2024
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
5 changes: 2 additions & 3 deletions src/particles/beam/BeamParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,7 @@ BeamParticleContainer::intializeSlice (int slice, int which_slice) {
ptd.rdata(BeamIdx::uy)[ip] = ptd_init.rdata(BeamIdx::uy)[idx_src];
ptd.rdata(BeamIdx::uz)[ip] = ptd_init.rdata(BeamIdx::uz)[idx_src];

ptd.id(ip) = ptd_init.id(idx_src);
ptd.cpu(ip) = 0;
ptd.idcpu(ip) = ptd_init.idcpu(idx_src);
ptd.idata(BeamIdx::nsubcycles)[ip] = 0;
}
);
Expand Down Expand Up @@ -472,7 +471,7 @@ BeamParticleContainer::InSituComputeDiags (int islice)

const amrex::Real uz_inv = uz == 0._rt ? 0._rt : 1._rt / uz;

if (ptd.id(ip) < 0 || x*x + y*y > insitu_radius_sq) {
if (!ptd.id(ip).is_valid() || x*x + y*y > insitu_radius_sq) {
return amrex::IdentityTuple(ReduceTuple{}, reduce_op);
}
const amrex::Real gamma = std::sqrt(1.0_rt + ux*ux + uy*uy + uz*uz);
Expand Down
1 change: 1 addition & 0 deletions src/particles/beam/BeamParticleContainerInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace
ptd.rdata(BeamIdx::w )[ip] = std::abs(weight);

ptd.id(ip) = pid > 0 ? pid + ip : pid;
ptd.cpu(ip) = 0;
}

/** \brief Adds a single beam particle into the per-slice BeamTile
Expand Down
2 changes: 1 addition & 1 deletion src/particles/deposition/BeamDepositCurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ DepositCurrentSlice (BeamParticleContainer& beam, Fields& fields,

// Skip invalid particles and ghost particles not in the last slice
// beam deposits only up to its finest level
if (ptd.id(ip) < 0 || (only_highest ? (ptd.cpu(ip)!=lev) : (ptd.cpu(ip)<lev))) return;
if (!ptd.id(ip).is_valid() || (only_highest ? (ptd.cpu(ip)!=lev) : (ptd.cpu(ip)<lev))) return;

// --- Get particle quantities
const amrex::Real ux = ptd.rdata(BeamIdx::ux)[ip];
Expand Down
2 changes: 1 addition & 1 deletion src/particles/deposition/ExplicitDeposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ExplicitDeposition (PlasmaParticleContainer& plasma, Fields& fields, const Multi

ip += idx_begin;

if (ptd.id(ip) < 0 || (lev != 0 && ptd.cpu(ip) < lev)) return;
if (!ptd.id(ip).is_valid() || (lev != 0 && ptd.cpu(ip) < lev)) return;
const amrex::Real psi_inv = 1._rt/ptd.rdata(PlasmaIdx::psi)[ip];
const amrex::Real xp = ptd.pos(0, ip);
const amrex::Real yp = ptd.pos(1, ip);
Expand Down
4 changes: 2 additions & 2 deletions src/particles/deposition/PlasmaDepositCurrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ DepositCurrent (PlasmaParticleContainer& plasma, Fields & fields, const MultiLas
const int ox = idx % outer_depos_order_x_1;

// only deposit plasma currents on or below their according MR level
if (ptd.id(ip) < 0 || (lev != 0 && ptd.cpu(ip) < lev)) return;
if (!ptd.id(ip).is_valid() || (lev != 0 && ptd.cpu(ip) < lev)) return;

const amrex::Real psi_inv = 1._rt/ptd.rdata(PlasmaIdx::psi)[ip];
const amrex::Real xp = ptd.pos(0, ip);
Expand Down Expand Up @@ -233,7 +233,7 @@ DepositCurrent (PlasmaParticleContainer& plasma, Fields & fields, const MultiLas
// This particle violates the QSA, discard it and do not deposit its current
amrex::Gpu::Atomic::Add(p_n_qsa_violation, 1);
ptd.rdata(PlasmaIdx::w)[ip] = 0.0_rt;
ptd.id(ip) = -std::abs(ptd.id(ip));
ptd.id(ip).make_invalid();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/particles/plasma/PlasmaParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ PlasmaParticleContainer::InSituComputeDiags (int islice)
const amrex::Real uy = ptd.rdata(PlasmaIdx::uy)[ip] * clight_inv;
const amrex::Real psi = ptd.rdata(PlasmaIdx::psi)[ip];

if (ptd.id(ip) < 0 || x*x + y*y > insitu_radius_sq) {
if (!ptd.id(ip).is_valid() || x*x + y*y > insitu_radius_sq) {
return amrex::IdentityTuple(ReduceTuple{}, reduce_op);
}
// particle's Lorentz factor
Expand Down
2 changes: 1 addition & 1 deletion src/particles/pusher/BeamParticleAdvance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ AdvanceBeamParticlesSlice (
beam.getNumParticlesIncludingSlipped(WhichBeamSlice::This),
[=] AMREX_GPU_DEVICE (int ip, auto depos_order, auto c_use_external_fields) {

if (ptd.id(ip) < 0) return;
if (!ptd.id(ip).is_valid()) return;

amrex::Real xp = ptd.pos(0, ip);
amrex::Real yp = ptd.pos(1, ip);
Expand Down
4 changes: 2 additions & 2 deletions src/particles/pusher/GetAndSetPosition.H
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct EnforceBCandSetPos
const bool invalid = (shifted && !m_is_per);
if (invalid) {
ptd.rdata(PlasmaIdx::w)[ip] = 0.0_rt;
p.id() = -std::abs(p.id());
p.id().make_invalid();
}
x = p.pos(0);
y = p.pos(1);
Expand Down Expand Up @@ -103,7 +103,7 @@ struct EnforceBCandSetPos
const bool invalid = (shifted && !m_is_per);
if (invalid) {
ptd.rdata(BeamIdx::w)[ip] = 0.0_rt;
p.id() = -std::abs(p.id());
p.id().make_invalid();
}
x = p.pos(0);
y = p.pos(1);
Expand Down
2 changes: 1 addition & 1 deletion src/particles/pusher/PlasmaParticleAdvance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ AdvancePlasmaParticles (PlasmaParticleContainer& plasma, const Fields & fields,
[=] AMREX_GPU_DEVICE (int idx, auto depos_order, auto use_laser) {
const int ip = idx + idx_begin;
// only push plasma particles on their according MR level
if (ptd.id(ip) < 0 || ptd.cpu(ip) != lev) return;
if (!ptd.id(ip).is_valid() || ptd.cpu(ip) != lev) return;

// define field at particle position reals
amrex::Real ExmByp = 0._rt, EypBxp = 0._rt, Ezp = 0._rt;
Expand Down
2 changes: 1 addition & 1 deletion src/salame/Salame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ SalameOnlyAdvancePlasma (Hipace* hipace, const int lev)
[=] AMREX_GPU_DEVICE (long idx, auto depos_order) {
const int ip = idx + idx_begin;
// only push plasma particles on their according MR level
if (ptd.id(ip) < 0 || ptd.cpu(ip) != lev) return;
if (!ptd.id(ip).is_valid() || ptd.cpu(ip) != lev) return;

const amrex::Real xp = ptd.rdata(PlasmaIdx::x_prev)[ip];
const amrex::Real yp = ptd.rdata(PlasmaIdx::y_prev)[ip];
Expand Down
Loading