aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/WarpX.H1
-rw-r--r--Source/WarpXEvolve.cpp4
-rw-r--r--Source/WarpXMove.cpp23
3 files changed, 20 insertions, 8 deletions
diff --git a/Source/WarpX.H b/Source/WarpX.H
index c194e1038..26a5c871c 100644
--- a/Source/WarpX.H
+++ b/Source/WarpX.H
@@ -102,6 +102,7 @@ public:
void ComputeDt ();
void MoveWindow (bool move_j);
+ void UpdatePlasmaInjectionPosition (Real dt);
void EvolveE ( amrex::Real dt, DtType typ);
void EvolveE (int lev, amrex::Real dt, DtType typ);
diff --git a/Source/WarpXEvolve.cpp b/Source/WarpXEvolve.cpp
index 4bef3b2d0..b54b7f8b0 100644
--- a/Source/WarpXEvolve.cpp
+++ b/Source/WarpXEvolve.cpp
@@ -68,6 +68,7 @@ WarpX::EvolveES(int numsteps) {
if (is_synchronized) {
// on first step, push X by 0.5*dt
mypc->PushXES(0.5*dt[lev]);
+ UpdatePlasmaInjectionPosition(0.5*dt[lev]);
mypc->Redistribute();
mypc->DepositCharge(rhoNodal);
computePhi(rhoNodal, phiNodal);
@@ -92,6 +93,7 @@ WarpX::EvolveES(int numsteps) {
if (cur_time + dt[0] >= stop_time - 1.e-3*dt[0] || step == numsteps_max-1) {
// on last step, push by only 0.5*dt to synchronize all at n+1/2
mypc->PushXES(-0.5*dt[lev]);
+ UpdatePlasmaInjectionPosition(-0.5*dt[lev]);
is_synchronized = true;
}
@@ -194,6 +196,7 @@ WarpX::EvolveEM (int numsteps)
FillBoundaryB();
EvolveE(0.5*dt[0], DtType::SecondHalf);
mypc->PushX(0.5*dt[0]);
+ UpdatePlasmaInjectionPosition(0.5*dt[0]);
mypc->Redistribute(); // Redistribute particles
is_synchronized = false;
}
@@ -226,6 +229,7 @@ WarpX::EvolveEM (int numsteps)
// on last step, push by only 0.5*dt to synchronize all at n+1/2
EvolveE(0.5*dt[0], DtType::FirstHalf); // We now have E^{n+1/2}
mypc->PushX(-0.5*dt[0]);
+ UpdatePlasmaInjectionPosition(-0.5*dt[0]);
is_synchronized = true;
} else {
EvolveE(dt[0], DtType::Full); // We now have E^{n+1}
diff --git a/Source/WarpXMove.cpp b/Source/WarpXMove.cpp
index 51e6554b8..0c14178a5 100644
--- a/Source/WarpXMove.cpp
+++ b/Source/WarpXMove.cpp
@@ -5,13 +5,8 @@
using namespace amrex;
void
-WarpX::MoveWindow (bool move_j)
+WarpX::UpdatePlasmaInjectionPosition (Real dt)
{
- if (do_moving_window == 0) return;
-
- // Update the continuous position of the moving window,
- // and of the plasma injection
- moving_window_x += moving_window_v * dt[0];
int dir = moving_window_dir;
// Continuously inject plasma in new cells (by default only on level 0)
if (WarpX::do_plasma_injection and (WarpX::gamma_boost > 1)){
@@ -19,14 +14,26 @@ WarpX::MoveWindow (bool move_j)
// call to this function, and injection position needs to be updated
current_injection_position -= WarpX::beta_boost *
#if ( BL_SPACEDIM == 3 )
- WarpX::boost_direction[dir] * PhysConst::c * dt[0];
+ WarpX::boost_direction[dir] * PhysConst::c * dt;
#elif ( BL_SPACEDIM == 2 )
// In 2D, dir=0 corresponds to x and dir=1 corresponds to z
// This needs to be converted in order to index `boost_direction`
// which has 3 components, for both 2D and 3D simulations.
- WarpX::boost_direction[2*dir] * PhysConst::c * dt[0];
+ WarpX::boost_direction[2*dir] * PhysConst::c * dt;
#endif
}
+}
+
+void
+WarpX::MoveWindow (bool move_j)
+{
+ if (do_moving_window == 0) return;
+
+ // Update the continuous position of the moving window,
+ // and of the plasma injection
+ moving_window_x += moving_window_v * dt[0];
+ int dir = moving_window_dir;
+ UpdatePlasmaInjectionPosition( dt[0] );
// compute the number of cells to shift on the base level
Real new_lo[BL_SPACEDIM];