Skip to content

Commit

Permalink
More work on BackTransformParticleFunctor
Browse files Browse the repository at this point in the history
  • Loading branch information
EZoni committed Jan 18, 2025
1 parent ed9b30d commit 39c4032
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ struct SelectParticles
* \brief Constructor of SelectParticles functor.
*
* @param[in] a_pti WarpX particle iterator
* @param[in] tmp_particle_data temporary particle data
* @param[in] current_z_boost current z-position of the slice in boosted frame
* @param[in] old_z_boost previous z-position of the slice in boosted frame
* @param[in] a_offset index offset for particles to be selected
*/
SelectParticles( const WarpXParIter& a_pti, TmpParticles& tmp_particle_data,
SelectParticles (const WarpXParticleContainer& pc,
const WarpXParIter& a_pti,
amrex::Real current_z_boost, amrex::Real old_z_boost,
int a_offset = 0);

Expand Down Expand Up @@ -83,15 +83,15 @@ struct LorentzTransformParticles
* \brief Constructor of the LorentzTransformParticles functor.
*
* @param[in] a_pti WarpX particle iterator
* @param[in] tmp_particle_data temporary particle data
* @param[in] t_boost time in boosted frame
* @param[in] dt timestep in boosted-frame
* @param[in] t_lab time in lab-frame
* @param[in] a_offset index offset for particles to be transformed
*/
LorentzTransformParticles ( const WarpXParIter& a_pti, TmpParticles& tmp_particle_data,
amrex::Real t_boost, amrex::Real dt,
amrex::Real t_lab, int a_offset = 0);
LorentzTransformParticles (const WarpXParticleContainer& pc,
const WarpXParIter& a_pti,
amrex::Real t_boost, amrex::Real dt,
amrex::Real t_lab, int a_offset = 0);

/**
* \brief Functor call. This method computes the Lorentz-transform for particle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,37 @@
#include <AMReX_Print.H>
#include <AMReX_BaseFwd.H>

SelectParticles::SelectParticles (const WarpXParIter& a_pti, TmpParticles& tmp_particle_data,
amrex::Real current_z_boost, amrex::Real old_z_boost,
int a_offset)
SelectParticles::SelectParticles (
const WarpXParticleContainer& pc,
const WarpXParIter& a_pti,
amrex::Real current_z_boost,
amrex::Real old_z_boost,
int a_offset
)
: m_current_z_boost(current_z_boost), m_old_z_boost(old_z_boost)
{
m_get_position = GetParticlePosition<PIdx>(a_pti, a_offset);

const auto lev = a_pti.GetLevel();
const auto index = a_pti.GetPairIndex();

zpold = tmp_particle_data[lev][index][TmpIdx::zold].dataPtr();
auto particle_comps = pc.getParticleComps();
zpold = a_pti.GetAttribs(particle_comps["z_n_btd"]).dataPtr();
}


LorentzTransformParticles::LorentzTransformParticles ( const WarpXParIter& a_pti,
TmpParticles& tmp_particle_data,
amrex::Real t_boost, amrex::Real dt,
amrex::Real t_lab, int a_offset)
LorentzTransformParticles::LorentzTransformParticles (
const WarpXParticleContainer& pc,
const WarpXParIter& a_pti,
amrex::Real t_boost,
amrex::Real dt,
amrex::Real t_lab,
int a_offset
)
: m_t_boost(t_boost), m_dt(dt), m_t_lab(t_lab)
{
using namespace amrex::literals;

if (tmp_particle_data.empty()) { return; }
// FIXME
//if (tmp_particle_data.empty()) { return; }

m_get_position = GetParticlePosition<PIdx>(a_pti, a_offset);

const auto& attribs = a_pti.GetAttribs();
Expand All @@ -46,15 +54,13 @@ LorentzTransformParticles::LorentzTransformParticles ( const WarpXParIter& a_pti
m_uypnew = attribs[PIdx::uy].dataPtr();
m_uzpnew = attribs[PIdx::uz].dataPtr();

const auto lev = a_pti.GetLevel();
const auto index = a_pti.GetPairIndex();

m_xpold = tmp_particle_data[lev][index][TmpIdx::xold].dataPtr();
m_ypold = tmp_particle_data[lev][index][TmpIdx::yold].dataPtr();
m_zpold = tmp_particle_data[lev][index][TmpIdx::zold].dataPtr();
m_uxpold = tmp_particle_data[lev][index][TmpIdx::uxold].dataPtr();
m_uypold = tmp_particle_data[lev][index][TmpIdx::uyold].dataPtr();
m_uzpold = tmp_particle_data[lev][index][TmpIdx::uzold].dataPtr();
auto particle_comps = pc.getParticleComps();
m_xpold = a_pti.GetAttribs(particle_comps["x_n_btd"]).dataPtr();
m_ypold = a_pti.GetAttribs(particle_comps["y_n_btd"]).dataPtr();
m_zpold = a_pti.GetAttribs(particle_comps["z_n_btd"]).dataPtr();
m_uxpold = a_pti.GetAttribs(particle_comps["ux_n_btd"]).dataPtr();
m_uypold = a_pti.GetAttribs(particle_comps["uy_n_btd"]).dataPtr();
m_uzpold = a_pti.GetAttribs(particle_comps["uz_n_btd"]).dataPtr();

m_betaboost = WarpX::beta_boost;
m_gammaboost = WarpX::gamma_boost;
Expand Down Expand Up @@ -84,7 +90,6 @@ BackTransformParticleFunctor::operator () (PinnedMemoryParticleContainer& pc_dst
auto &warpx = WarpX::GetInstance();
// get particle slice
const int nlevs = std::max(0, m_pc_src->finestLevel()+1);
auto tmp_particle_data = m_pc_src->getTmpParticleData();
for (int lev = 0; lev < nlevs; ++lev) {
const amrex::Real t_boost = warpx.gett_new(0);
const amrex::Real dt = warpx.getdt(0);
Expand All @@ -107,13 +112,19 @@ BackTransformParticleFunctor::operator () (PinnedMemoryParticleContainer& pc_dst

auto index = std::make_pair(pti.index(), pti.LocalTileIndex());

const auto GetParticleFilter = SelectParticles(pti, tmp_particle_data,
m_current_z_boost[i_buffer],
m_old_z_boost[i_buffer]);
const auto GetParticleFilter = SelectParticles(
*m_pc_src,
pti,
m_current_z_boost[i_buffer],
m_old_z_boost[i_buffer]
);
const auto GetParticleLorentzTransform = LorentzTransformParticles(
pti, tmp_particle_data,
t_boost, dt,
m_t_lab[i_buffer]);
*m_pc_src,
pti,
t_boost,
dt,
m_t_lab[i_buffer]
);

long const np = pti.numParticles();

Expand Down

0 comments on commit 39c4032

Please sign in to comment.