aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/WarpXParticleContainer.H
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Particles/WarpXParticleContainer.H')
-rw-r--r--Source/Particles/WarpXParticleContainer.H78
1 files changed, 62 insertions, 16 deletions
diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H
index 050060b47..1e3dfb2ae 100644
--- a/Source/Particles/WarpXParticleContainer.H
+++ b/Source/Particles/WarpXParticleContainer.H
@@ -6,6 +6,8 @@
#include <AMReX_Particles.H>
#include <AMReX_AmrCore.H>
+enum struct ConvertDirection{WarpX_to_SI, SI_to_WarpX};
+
struct PIdx
{
enum { // Particle Attributes stored in amrex::ParticleContainer's struct of array
@@ -14,9 +16,6 @@ struct PIdx
#ifdef WARPX_RZ
theta, // RZ needs all three position components
#endif
-#ifdef WARPX_STORE_OLD_PARTICLE_ATTRIBS
- xold, yold, zold, uxold, uyold, uzold,
-#endif
nattribs
};
};
@@ -42,15 +41,7 @@ namespace ParticleStringNames
{"Ez", PIdx::Ez },
{"Bx", PIdx::Bx },
{"By", PIdx::By },
- {"Bz", PIdx::Bz },
-#ifdef WARPX_STORE_OLD_PARTICLE_ATTRIBS
- {"xold", PIdx::xold },
- {"yold", PIdx::yold },
- {"zold", PIdx::zold },
- {"uxold", PIdx::uxold},
- {"uyold", PIdx::uyold},
- {"uzold", PIdx::uzold},
-#endif
+ {"Bz", PIdx::Bz }
};
}
@@ -70,7 +61,6 @@ public:
const amrex::Cuda::ManagedDeviceVector<amrex::Real>& y,
const amrex::Cuda::ManagedDeviceVector<amrex::Real>& z);
#endif
-
const std::array<RealVector, PIdx::nattribs>& GetAttribs () const {
return GetStructOfArrays().GetRealData();
}
@@ -96,7 +86,13 @@ class WarpXParticleContainer
public:
friend MultiParticleContainer;
+ // amrex::StructOfArrays with DiagIdx::nattribs amrex::Real components
+ // and 0 int components for the particle data.
using DiagnosticParticleData = amrex::StructOfArrays<DiagIdx::nattribs, 0>;
+ // DiagnosticParticles is a vector, with one element per MR level.
+ // DiagnosticParticles[lev] is typically a key-value pair where the key is
+ // a pair [grid_index, tile_index], and the value is the corresponding
+ // DiagnosticParticleData (see above) on this tile.
using DiagnosticParticles = amrex::Vector<std::map<std::pair<int, int>, DiagnosticParticleData> >;
WarpXParticleContainer (amrex::AmrCore* amr_core, int ispecies);
@@ -194,7 +190,18 @@ public:
int thread_num,
int lev,
amrex::Real dt );
-
+
+ // If particles start outside of the domain, ContinuousInjection
+ // makes sure that they are initialized when they enter the domain, and
+ // NOT before. Virtual function, overriden by derived classes.
+ // Current status:
+ // PhysicalParticleContainer: implemented.
+ // LaserParticleContainer: implemented.
+ // RigidInjectedParticleContainer: not implemented.
+ virtual void ContinuousInjection(const amrex::RealBox& injection_box) {}
+ // Update optional sub-class-specific injection location.
+ virtual void UpdateContinuousInjectionPosition(amrex::Real dt) {}
+
///
/// This returns the total charge for all the particles in this ParticleContainer.
/// This is needed when solving Poisson's equation with periodic boundary conditions.
@@ -218,9 +225,11 @@ public:
amrex::Real x, amrex::Real y, amrex::Real z,
std::array<amrex::Real,PIdx::nattribs>& attribs);
- void ReadHeader (std::istream& is);
+ virtual void ReadHeader (std::istream& is);
+
+ virtual void WriteHeader (std::ostream& os) const;
- void WriteHeader (std::ostream& os) const;
+ virtual void ConvertUnits (ConvertDirection convert_dir){};
static void ReadParameters ();
@@ -231,8 +240,27 @@ public:
// split along axes (0) or diagonals (1)
int split_type = 0;
+ using amrex::ParticleContainer<0, 0, PIdx::nattribs>::AddRealComp;
+ using amrex::ParticleContainer<0, 0, PIdx::nattribs>::AddIntComp;
+
+ void AddRealComp (const std::string& name, bool comm=true)
+ {
+ particle_comps[name] = NumRealComps();
+ AddRealComp(comm);
+ }
+
+ void AddIntComp (const std::string& name, bool comm=true)
+ {
+ particle_comps[name] = NumIntComps();
+ AddIntComp(comm);
+ }
+
+ int DoBoostedFrameDiags () const { return do_boosted_frame_diags; }
+
protected:
+ std::map<std::string, int> particle_comps;
+
int species_id;
amrex::Real charge;
@@ -242,6 +270,14 @@ protected:
static int do_not_push;
+ // Whether to allow particles outside of the simulation domain to be
+ // initialized when they enter the domain.
+ // This is currently required because continuous injection does not
+ // support all features allowed by direct injection.
+ int do_continuous_injection = 0;
+
+ int do_boosted_frame_diags = 1;
+
amrex::Vector<amrex::FArrayBox> local_rho;
amrex::Vector<amrex::FArrayBox> local_jx;
amrex::Vector<amrex::FArrayBox> local_jy;
@@ -249,9 +285,19 @@ protected:
amrex::Vector<amrex::Cuda::ManagedDeviceVector<amrex::Real> > m_xp, m_yp, m_zp, m_giv;
+ // Whether to dump particle quantities.
+ // If true, particle position is always dumped.
+ int plot_species = 1;
+ // For all particle attribs (execept position), whether or not
+ // to dump to file.
+ amrex::Vector<int> plot_flags;
+ // list of names of attributes to dump.
+ amrex::Vector<std::string> plot_vars;
+
private:
virtual void particlePostLocate(ParticleType& p, const amrex::ParticleLocData& pld,
const int lev) override;
+
};
#endif