aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/WarpX.H10
-rw-r--r--Source/WarpX.cpp30
-rw-r--r--Source/WarpXEvolve.cpp4
-rw-r--r--Source/WarpXIO.cpp36
-rw-r--r--Source/WarpXInitData.cpp5
-rw-r--r--Source/WarpXMove.cpp23
-rw-r--r--Source/WarpXPML.H2
-rw-r--r--Source/WarpXPML.cpp7
8 files changed, 78 insertions, 39 deletions
diff --git a/Source/WarpX.H b/Source/WarpX.H
index c194e1038..de3a28a77 100644
--- a/Source/WarpX.H
+++ b/Source/WarpX.H
@@ -13,6 +13,7 @@
#include <AMReX_BLProfiler.H>
#include <AMReX_Print.H>
#include <AMReX_RealVect.H>
+#include <AMReX_VisMF.H>
#include <ParticleContainer.H>
#include <WarpXPML.H>
@@ -102,6 +103,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);
@@ -381,6 +383,14 @@ private:
bool plot_raw_fields = false;
bool plot_raw_fields_guards = false;
+ amrex::VisMF::Header::Version checkpoint_headerversion = amrex::VisMF::Header::NoFabHeader_v1;
+ amrex::VisMF::Header::Version plot_headerversion = amrex::VisMF::Header::Version_v1;
+ bool use_single_read = true;
+ bool use_single_write = true;
+ int mffile_nstreams = 4;
+ int field_io_nfiles = 1024;
+ int particle_io_nfiles = 1024;
+
amrex::RealVect fine_tag_lo;
amrex::RealVect fine_tag_hi;
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp
index 6a68c473e..92a26ed8f 100644
--- a/Source/WarpX.cpp
+++ b/Source/WarpX.cpp
@@ -201,7 +201,7 @@ WarpX::ReadParameters ()
}
}
- pp.queryarr("B_external", B_external);
+ pp.queryarr("B_external", B_external);
pp.query("do_moving_window", do_moving_window);
if (do_moving_window)
@@ -299,6 +299,27 @@ WarpX::ReadParameters ()
pp.query("plot_crsepatch", plot_crsepatch);
}
+ {
+ int hv = checkpoint_headerversion;
+ pp.query("checkpoint_headerversion", hv);
+ checkpoint_headerversion = static_cast<VisMF::Header::Version>(hv);
+ hv = plot_headerversion;
+ pp.query("plot_headerversion", hv);
+ plot_headerversion = static_cast<VisMF::Header::Version>(hv);
+ pp.query("usesingleread", use_single_read);
+ pp.query("usesinglewrite", use_single_write);
+ ParmParse ppv("vismf");
+ ppv.add("usesingleread", use_single_read);
+ ppv.add("usesinglewrite", use_single_write);
+ pp.query("mffile_nstreams", mffile_nstreams);
+ VisMF::SetMFFileInStreams(mffile_nstreams);
+ pp.query("field_io_nfiles", field_io_nfiles);
+ VisMF::SetNOutFiles(field_io_nfiles);
+ pp.query("particle_io_nfiles", particle_io_nfiles);
+ ParmParse ppp("particles");
+ ppp.add("particles_nfiles", particle_io_nfiles);
+ }
+
if (maxLevel() > 0) {
Vector<Real> lo, hi;
pp.getarr("fine_tag_lo", lo);
@@ -369,7 +390,8 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d
int ngE = (WarpX::nox % 2) ? WarpX::nox+1 : WarpX::nox; // Always even number
int ngJ = ngE;
int ngRho = ngE;
-
+ int ngF = (do_moving_window) ? 2 : 0;
+
//
// The fine patch
//
@@ -387,7 +409,7 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d
if (do_dive_cleaning)
{
- F_fp[lev].reset (new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()),dm,1, 0));
+ F_fp[lev].reset (new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()),dm,1, ngF));
rho_fp[lev].reset(new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()),dm,1,ngRho));
}
@@ -440,7 +462,7 @@ WarpX::AllocLevelData (int lev, const BoxArray& ba, const DistributionMapping& d
if (do_dive_cleaning)
{
- F_cp[lev].reset (new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()),dm,1, 0));
+ F_cp[lev].reset (new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()),dm,1, ngF));
rho_cp[lev].reset(new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()),dm,1,ngRho));
}
}
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/WarpXIO.cpp b/Source/WarpXIO.cpp
index 768dd9ecc..69e7e73e1 100644
--- a/Source/WarpXIO.cpp
+++ b/Source/WarpXIO.cpp
@@ -101,9 +101,6 @@ WarpX::WriteCheckPointFile() const
amrex::Print() << " Writing checkpoint " << checkpointname << "\n";
- const int checkpoint_nfiles = 64; // could make this parameter
- VisMF::SetNOutFiles(checkpoint_nfiles);
-
const int nlevels = finestLevel()+1;
amrex::PreBuildDirectorHierarchy(checkpointname, level_prefix, nlevels, true);
@@ -181,9 +178,6 @@ WarpX::InitFromCheckpoint ()
amrex::Print() << " Restart from checkpoint " << restart_chkfile << "\n";
- const int checkpoint_nfiles = 64; // could make this parameter
- VisMF::SetNOutFiles(checkpoint_nfiles);
-
// Header
{
std::string File(restart_chkfile + "/WarpXHeader");
@@ -661,23 +655,23 @@ WarpX::WritePlotFile () const
}
#endif
+ Vector<std::string> rfs;
+ if (plot_raw_fields) rfs.emplace_back("raw_fields"); // pre-build raw_fields/
amrex::WriteMultiLevelPlotfile(plotfilename, finest_level+1,
amrex::GetVecOfConstPtrs(mf),
- varnames, Geom(), t_new[0], istep, refRatio());
+ varnames, Geom(), t_new[0], istep, refRatio(),
+ "HyperCLaw-V1.1",
+ "Level_",
+ "Cell",
+ rfs);
}
if (plot_raw_fields)
{
- const int raw_plot_nfiles = 64; // could make this parameter
- VisMF::SetNOutFiles(raw_plot_nfiles);
-
const int nlevels = finestLevel()+1;
- const std::string raw_plotfilename = plotfilename + "/raw_fields";
- amrex::PreBuildDirectorHierarchy(raw_plotfilename, level_prefix, nlevels, true);
-
for (int lev = 0; lev < nlevels; ++lev)
{
-
+ const std::string raw_plotfilename = plotfilename + "/raw_fields";
// Plot auxilary patch
if (plot_raw_fields_guards) {
VisMF::Write(*Efield_aux[lev][0], amrex::MultiFabFileFullPrefix(lev, raw_plotfilename, level_prefix, "Ex_aux"));
@@ -863,19 +857,19 @@ WritePlotFileES (const amrex::Vector<std::unique_ptr<amrex::MultiFab> >& rho,
dcomp += 1;
}
+ Vector<std::string> rfs(1,"raw_fields"); // pre-build raw_fields/
amrex::WriteMultiLevelPlotfile(plotfilename, finest_level+1,
amrex::GetVecOfConstPtrs(mf),
- varnames, Geom(), t_new[0], istep, refRatio());
+ varnames, Geom(), t_new[0], istep, refRatio(),
+ "HyperCLaw-V1.1",
+ "Level_",
+ "Cell",
+ rfs);
}
{
- const int raw_plot_nfiles = 64; // could make this parameter
- VisMF::SetNOutFiles(raw_plot_nfiles);
-
- const int nlevels = finestLevel()+1;
const std::string raw_plotfilename = plotfilename + "/raw_fields";
- amrex::PreBuildDirectorHierarchy(raw_plotfilename, level_prefix, nlevels, true);
-
+ const int nlevels = finestLevel()+1;
for (int lev = 0; lev < nlevels; ++lev) {
const DistributionMapping& dm = DistributionMap(lev);
diff --git a/Source/WarpXInitData.cpp b/Source/WarpXInitData.cpp
index 873adcbaf..df01afe88 100644
--- a/Source/WarpXInitData.cpp
+++ b/Source/WarpXInitData.cpp
@@ -92,12 +92,13 @@ WarpX::InitPML ()
if (do_pml)
{
pml[0].reset(new PML(boxArray(0), DistributionMap(0), &Geom(0), nullptr,
- pml_ncell, pml_delta, 0, do_dive_cleaning));
+ pml_ncell, pml_delta, 0, do_dive_cleaning, do_moving_window));
for (int lev = 1; lev <= finest_level; ++lev)
{
pml[lev].reset(new PML(boxArray(lev), DistributionMap(lev),
&Geom(lev), &Geom(lev-1),
- pml_ncell, pml_delta, refRatio(lev-1)[0], do_dive_cleaning));
+ pml_ncell, pml_delta, refRatio(lev-1)[0], do_dive_cleaning,
+ do_moving_window));
}
}
}
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];
diff --git a/Source/WarpXPML.H b/Source/WarpXPML.H
index 4a44bedb3..c516f012d 100644
--- a/Source/WarpXPML.H
+++ b/Source/WarpXPML.H
@@ -109,7 +109,7 @@ class PML
public:
PML (const amrex::BoxArray& ba, const amrex::DistributionMapping& dm,
const amrex::Geometry* geom, const amrex::Geometry* cgeom,
- int ncell, int delta, int ref_ratio, int do_dive_cleaning);
+ int ncell, int delta, int ref_ratio, int do_dive_cleaning, int do_moving_window);
void ComputePMLFactors (amrex::Real dt, const std::string& pml_type);
diff --git a/Source/WarpXPML.cpp b/Source/WarpXPML.cpp
index 6db887136..19e36f38a 100644
--- a/Source/WarpXPML.cpp
+++ b/Source/WarpXPML.cpp
@@ -425,7 +425,7 @@ MultiSigmaBox::ComputePMLFactorsE (const Real* dx, Real dt, const std::string& p
PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm,
const Geometry* geom, const Geometry* cgeom,
- int ncell, int delta, int ref_ratio, int do_dive_cleaning)
+ int ncell, int delta, int ref_ratio, int do_dive_cleaning, int do_moving_window)
: m_geom(geom),
m_cgeom(cgeom)
{
@@ -441,6 +441,7 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm,
int nge = 2;
int ngb = 2;
+ int ngf = (do_moving_window) ? 2 : 0;
pml_E_fp[0].reset(new MultiFab(amrex::convert(ba,WarpX::Ex_nodal_flag), dm, 3, nge));
pml_E_fp[1].reset(new MultiFab(amrex::convert(ba,WarpX::Ey_nodal_flag), dm, 3, nge));
@@ -458,7 +459,7 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm,
if (do_dive_cleaning)
{
- pml_F_fp.reset(new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()), dm, 3, 0));
+ pml_F_fp.reset(new MultiFab(amrex::convert(ba,IntVect::TheUnitVector()), dm, 3, ngf));
pml_F_fp->setVal(0.0);
}
@@ -492,7 +493,7 @@ PML::PML (const BoxArray& grid_ba, const DistributionMapping& grid_dm,
if (do_dive_cleaning)
{
- pml_F_cp.reset(new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()), cdm, 3, 0));
+ pml_F_cp.reset(new MultiFab(amrex::convert(cba,IntVect::TheUnitVector()), cdm, 3, ngf));
pml_F_cp->setVal(0.0);
}