Skip to content

Commit

Permalink
Fix restart for rigid-injected particles
Browse files Browse the repository at this point in the history
  • Loading branch information
RemiLehe committed Sep 27, 2021
1 parent 322634c commit 33bf3a6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Particles/PhysicalParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public:
RealVector& uzp,
RealVector& wp );

virtual void PostRestart () final {}
virtual void PostRestart () override {}

void SplitParticles (int lev);

Expand Down
2 changes: 2 additions & 0 deletions Source/Particles/RigidInjectedParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public:

virtual void InitData() override;

virtual void PostRestart() override final;

virtual void RemapParticles();
virtual void BoostandRemapParticles();

Expand Down
27 changes: 25 additions & 2 deletions Source/Particles/RigidInjectedParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,37 @@ void RigidInjectedParticleContainer::InitData()

AddParticles(0); // Note - add on level 0

// Store velocity with which rigid particles move
vzbeam_ave_boosted = meanParticleVelocity(false)[2];

// Particles added by AddParticles should already be in the boosted frame
RemapParticles();

Redistribute(); // We then redistribute
}

void
RigidInjectedParticleContainer::PostRestart()
{
// Call parent class
PhysicalParticleContainer::PostRestart();

// Store velocity with which rigid particles move
vzbeam_ave_boosted = meanParticleVelocity(false)[2];

// Compute the position of the injection plane in the
// boosted frame at restart time
zinject_plane_levels.resize(finestLevel()+1,0);
for (int lev=0; lev<=finestLevel(); lev++){
Real t = WarpX::GetInstance().gett_new(0);
zinject_plane_levels[lev] = zinject_plane/WarpX::gamma_boost - WarpX::beta_boost*PhysConst::c*t;
}

// The `done_injecting` flag is only here for computational efficiency
// We set it to false at restart (`0`), but it will be reset in `Evolve`
done_injecting.resize(finestLevel()+1, 0);
}

void
RigidInjectedParticleContainer::RemapParticles()
{
Expand All @@ -104,8 +129,6 @@ RigidInjectedParticleContainer::RemapParticles()
const Real uz_boost = WarpX::gamma_boost*WarpX::beta_boost*PhysConst::c;
const Real csqi = 1./(PhysConst::c*PhysConst::c);

vzbeam_ave_boosted = meanParticleVelocity(false)[2];

for (int lev = 0; lev <= finestLevel(); lev++) {

#ifdef AMREX_USE_OMP
Expand Down

0 comments on commit 33bf3a6

Please sign in to comment.