aboutsummaryrefslogtreecommitdiff
path: root/Source/WarpXEvolve.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WarpXEvolve.cpp')
-rw-r--r--Source/WarpXEvolve.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/Source/WarpXEvolve.cpp b/Source/WarpXEvolve.cpp
index 54c3db78f..43740727d 100644
--- a/Source/WarpXEvolve.cpp
+++ b/Source/WarpXEvolve.cpp
@@ -19,7 +19,7 @@ WarpX::Evolve (int numsteps) {
if (do_electrostatic) {
EvolveES(numsteps);
} else {
- EvolveEM(numsteps);
+ EvolveEM(numsteps);
}
#else
EvolveEM(numsteps);
@@ -49,7 +49,7 @@ WarpX::EvolveEM (int numsteps)
{
Real walltime_beg_step = amrex::second();
- // Start loop on time steps
+ // Start loop on time steps
amrex::Print() << "\nSTEP " << step+1 << " starts ...\n";
#ifdef WARPX_USE_PY
if (warpx_py_beforestep) warpx_py_beforestep();
@@ -63,16 +63,18 @@ WarpX::EvolveEM (int numsteps)
if (step > 0 && (step+1) % load_balance_int == 0)
{
LoadBalance();
- // Reset the costs to 0
- for (int lev = 0; lev <= finest_level; ++lev) {
- costs[lev]->setVal(0.0);
- }
+ // Reset the costs to 0
+ for (int lev = 0; lev <= finest_level; ++lev)
+ {
+ costs[lev]->setVal(0.0);
+ }
}
- for (int lev = 0; lev <= finest_level; ++lev) {
- // Perform running average of the costs
- // (Giving more importance to most recent costs)
- (*costs[lev].get()).mult( (1. - 2./load_balance_int) );
+ for (int lev = 0; lev <= finest_level; ++lev)
+ {
+ // Perform running average of the costs
+ // (Giving more importance to most recent costs)
+ (*costs[lev].get()).mult( (1. - 2./load_balance_int) );
}
}
@@ -84,12 +86,13 @@ WarpX::EvolveEM (int numsteps)
FillBoundaryB();
UpdateAuxilaryData();
// on first step, push p by -0.5*dt
- for (int lev = 0; lev <= finest_level; ++lev) {
+ for (int lev = 0; lev <= finest_level; ++lev)
+ {
mypc->PushP(lev, -0.5*dt[0],
*Efield_aux[lev][0],*Efield_aux[lev][1],*Efield_aux[lev][2],
*Bfield_aux[lev][0],*Bfield_aux[lev][1],*Bfield_aux[lev][2]);
}
- is_synchronized = false;
+ is_synchronized = false;
} else {
// Beyond one step, we have E^{n} and B^{n}.
// Particles have p^{n-1/2} and x^{n}.
@@ -131,7 +134,8 @@ WarpX::EvolveEM (int numsteps)
FillBoundaryE();
EvolveF(0.5*dt[0], DtType::SecondHalf);
EvolveB(0.5*dt[0]); // We now have B^{n+1}
- if (do_pml) {
+ if (do_pml)
+ {
DampPML();
FillBoundaryE();
}
@@ -144,29 +148,31 @@ WarpX::EvolveEM (int numsteps)
if (cur_time + dt[0] >= stop_time - 1.e-3*dt[0] || step == numsteps_max-1) {
// At the end of last step, push p by 0.5*dt to synchronize
UpdateAuxilaryData();
- for (int lev = 0; lev <= finest_level; ++lev) {
+ for (int lev = 0; lev <= finest_level; ++lev)
+ {
mypc->PushP(lev, 0.5*dt[0],
*Efield_aux[lev][0],*Efield_aux[lev][1],*Efield_aux[lev][2],
*Bfield_aux[lev][0],*Bfield_aux[lev][1],*Bfield_aux[lev][2]);
- }
+ }
is_synchronized = true;
}
#ifdef WARPX_USE_PY
if (warpx_py_afterEsolve) warpx_py_afterEsolve();
#endif
- for (int lev = 0; lev <= max_level; ++lev) {
+ for (int lev = 0; lev <= max_level; ++lev)
+ {
++istep[lev];
}
- cur_time += dt[0];
+ cur_time += dt[0];
bool to_make_plot = (plot_int > 0) && ((step+1) % plot_int == 0);
bool move_j = is_synchronized || to_make_plot;
// If is_synchronized we need to shift j too so that next step we can evolve E by dt/2.
// We might need to move j because we are going to make a plotfile.
- MoveWindow(move_j);
+ MoveWindow(move_j);
if (max_level == 0) {
mypc->RedistributeLocal();
@@ -183,10 +189,10 @@ WarpX::EvolveEM (int numsteps)
<< " s; This step = " << walltime_end_step-walltime_beg_step
<< " s; Avg. per step = " << walltime/(step+1) << " s\n";
- // sync up time
- for (int i = 0; i <= max_level; ++i) {
- t_new[i] = cur_time;
- }
+ // sync up time
+ for (int i = 0; i <= max_level; ++i) {
+ t_new[i] = cur_time;
+ }
if (do_boosted_frame_diagnostic) {
std::unique_ptr<MultiFab> cell_centered_data = nullptr;
@@ -196,7 +202,7 @@ WarpX::EvolveEM (int numsteps)
myBFD->writeLabFrameData(cell_centered_data.get(), *mypc, geom[0], cur_time, dt[0]);
}
- if (to_make_plot)
+ if (to_make_plot)
{
FillBoundaryE();
FillBoundaryB();
@@ -208,19 +214,19 @@ WarpX::EvolveEM (int numsteps)
*Bfield_aux[lev][0],*Bfield_aux[lev][1],*Bfield_aux[lev][2]);
}
- last_plot_file_step = step+1;
- WritePlotFile();
- }
+ last_plot_file_step = step+1;
+ WritePlotFile();
+ }
- if (check_int > 0 && (step+1) % check_int == 0) {
- last_check_file_step = step+1;
- WriteCheckPointFile();
- }
+ if (check_int > 0 && (step+1) % check_int == 0) {
+ last_check_file_step = step+1;
+ WriteCheckPointFile();
+ }
- if (cur_time >= stop_time - 1.e-3*dt[0]) {
- max_time_reached = true;
- break;
- }
+ if (cur_time >= stop_time - 1.e-3*dt[0]) {
+ max_time_reached = true;
+ break;
+ }
#ifdef WARPX_USE_PY
if (warpx_py_afterstep) warpx_py_afterstep();
@@ -240,11 +246,11 @@ WarpX::EvolveEM (int numsteps)
*Bfield_aux[lev][0],*Bfield_aux[lev][1],*Bfield_aux[lev][2]);
}
- WritePlotFile();
+ WritePlotFile();
}
if (check_int > 0 && istep[0] > last_check_file_step && (max_time_reached || istep[0] >= max_step)) {
- WriteCheckPointFile();
+ WriteCheckPointFile();
}
if (do_boosted_frame_diagnostic) {
@@ -285,9 +291,7 @@ WarpX::EvolveB (int lev, Real dt)
Bx = Bfield_fp[lev][0].get();
By = Bfield_fp[lev][1].get();
Bz = Bfield_fp[lev][2].get();
- }
- else
- {
+ } else {
Ex = Efield_cp[lev][0].get();
Ey = Efield_cp[lev][1].get();
Ez = Efield_cp[lev][2].get();
@@ -340,9 +344,9 @@ WarpX::EvolveB (int lev, Real dt)
{
const auto& pml_B = (ipatch==0) ? pml[lev]->GetB_fp() : pml[lev]->GetB_cp();
const auto& pml_E = (ipatch==0) ? pml[lev]->GetE_fp() : pml[lev]->GetE_cp();
- int patch_level = (ipatch == 0) ? lev : lev-1;
- const std::array<Real,3>& dx = WarpX::CellSize(patch_level);
- const std::array<Real,3> dtsdx {dt/dx[0], dt/dx[1], dt/dx[2]};
+ int patch_level = (ipatch == 0) ? lev : lev-1;
+ const std::array<Real,3>& dx = WarpX::CellSize(patch_level);
+ const std::array<Real,3> dtsdx {dt/dx[0], dt/dx[1], dt/dx[2]};
#ifdef _OPENMP
#pragma omp parallel
#endif
@@ -362,8 +366,8 @@ WarpX::EvolveB (int lev, Real dt)
BL_TO_FORTRAN_3D((*pml_B[0])[mfi]),
BL_TO_FORTRAN_3D((*pml_B[1])[mfi]),
BL_TO_FORTRAN_3D((*pml_B[2])[mfi]),
- &dtsdx[0], &dtsdx[1], &dtsdx[2],
- &WarpX::maxwell_fdtd_solver_id);
+ &dtsdx[0], &dtsdx[1], &dtsdx[2],
+ &WarpX::maxwell_fdtd_solver_id);
}
}
}
@@ -409,9 +413,7 @@ WarpX::EvolveE (int lev, Real dt)
jy = current_fp[lev][1].get();
jz = current_fp[lev][2].get();
F = F_fp[lev].get();
- }
- else
- {
+ } else {
Ex = Efield_cp[lev][0].get();
Ey = Efield_cp[lev][1].get();
Ez = Efield_cp[lev][2].get();
@@ -567,9 +569,7 @@ WarpX::EvolveF (int lev, Real dt, DtType dt_type)
Ez = Efield_fp[lev][2].get();
rho = rho_fp[lev].get();
F = F_fp[lev].get();
- }
- else
- {
+ } else {
Ex = Efield_cp[lev][0].get();
Ey = Efield_cp[lev][1].get();
Ez = Efield_cp[lev][2].get();