From 2ff0825c82d980b1c81646ccde01d83292ea8d44 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Thu, 30 May 2019 15:29:04 -0400 Subject: add implementation of RigidInjectedParticleContainer's Read/Write Header methods to ParticleIO.cpp --- Source/Diagnostics/ParticleIO.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Source/Diagnostics/ParticleIO.cpp') diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index ba413dcae..2bd9b34ce 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -18,6 +18,20 @@ WarpXParticleContainer::WriteHeader (std::ostream& os) const os << charge << " " << mass << "\n"; } +void +RigidInjectedParticleContainer::ReadHeader (std::istream& is) +{ + is >> charge >> mass; + WarpX::GotoNextLine(is); +} + +void +RigidInjectedParticleContainer::WriteHeader (std::ostream& os) const +{ + // no need to write species_id + os << charge << " " << mass << "\n"; +} + void MultiParticleContainer::Checkpoint (const std::string& dir) const { -- cgit v1.2.3 From 1adca2edc7f284927cf2b977ca7d3e4f5f78d0f2 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Thu, 30 May 2019 15:48:50 -0400 Subject: add zinject and done_injecting into the Header for RigidInjectedParticleContainer --- Source/Diagnostics/ParticleIO.cpp | 41 +++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'Source/Diagnostics/ParticleIO.cpp') diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index 2bd9b34ce..0f6246715 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -5,28 +5,61 @@ using namespace amrex; void -WarpXParticleContainer::ReadHeader (std::istream& is) +RigidInjectedParticleContainer::ReadHeader (std::istream& is) { is >> charge >> mass; WarpX::GotoNextLine(is); + + int nlevs; + is >> nlevs; + WarpX::GotoNextLine(is); + + AMREX_ASSERT(zinject_plane_levels.size() == 0); + AMREX_ASSERT(done_injecting.size() == 0); + + for (int i = 0; i < nlevs; ++i) + { + int zinject_plane_tmp; + is >> zinject_plane_tmp; + zinject_plane_levels.push_back(zinject_plane_tmp); + WarpX::GotoNextLine(is); + } + + for (int i = 0; i < nlevs; ++i) + { + int done_injecting_tmp; + is >> done_injecting_tmp; + done_injecting.push_back(done_injecting_tmp); + WarpX::GotoNextLine(is); + } } void -WarpXParticleContainer::WriteHeader (std::ostream& os) const +RigidInjectedParticleContainer::WriteHeader (std::ostream& os) const { // no need to write species_id os << charge << " " << mass << "\n"; + int nlevs = zinject_plane_levels.size(); + os << nlevs << "\n"; + for (int i = 0; i < nlevs; ++i) + { + os << zinject_plane_levels[i] << "\n"; + } + for (int i = 0; i < nlevs; ++i) + { + os << done_injecting[i] << "\n"; + } } void -RigidInjectedParticleContainer::ReadHeader (std::istream& is) +WarpXParticleContainer::ReadHeader (std::istream& is) { is >> charge >> mass; WarpX::GotoNextLine(is); } void -RigidInjectedParticleContainer::WriteHeader (std::ostream& os) const +WarpXParticleContainer::WriteHeader (std::ostream& os) const { // no need to write species_id os << charge << " " << mass << "\n"; -- cgit v1.2.3 From 914373c1f395d4944aea95d520d9f3701614cd32 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Tue, 4 Jun 2019 14:26:58 -0700 Subject: set the component names on a species-by-species basis, since they will differ based on whether boosted frame diags are requested or not --- Source/Diagnostics/ParticleIO.cpp | 38 +++++++++++++++++++++++++++---- Source/Diagnostics/WarpXIO.cpp | 2 +- Source/Particles/MultiParticleContainer.H | 3 +-- 3 files changed, 36 insertions(+), 7 deletions(-) (limited to 'Source/Diagnostics/ParticleIO.cpp') diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index 0f6246715..f2a543ed5 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -74,15 +74,45 @@ MultiParticleContainer::Checkpoint (const std::string& dir) const } void -MultiParticleContainer::WritePlotFile (const std::string& dir, - const Vector& real_names) const +MultiParticleContainer::WritePlotFile (const std::string& dir) const { Vector int_names; Vector int_flags; - + for (unsigned i = 0, n = species_names.size(); i < n; ++i) { - auto& pc = allcontainers[i]; + auto& pc = allcontainers[i]; if (pc->plot_species) { + + Vector real_names; + real_names.push_back("weight"); + + real_names.push_back("momentum_x"); + real_names.push_back("momentum_y"); + real_names.push_back("momentum_z"); + + real_names.push_back("Ex"); + real_names.push_back("Ey"); + real_names.push_back("Ez"); + + real_names.push_back("Bx"); + real_names.push_back("By"); + real_names.push_back("Bz"); + +#ifdef WARPX_RZ + real_names.push_back("theta"); +#endif + + if (WarpX::do_boosted_frame_diagnostic && pc->DoBoostedFrameDiags()) + { + real_names.push_back("xold"); + real_names.push_back("yold"); + real_names.push_back("zold"); + + real_names.push_back("uxold"); + real_names.push_back("uyold"); + real_names.push_back("uzold"); + } + // Convert momentum to SI pc->ConvertUnits(ConvertDirection::WarpX_to_SI); // real_names contains a list of all particle attributes. diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp index 7e7ed278d..dedd11f4a 100644 --- a/Source/Diagnostics/WarpXIO.cpp +++ b/Source/Diagnostics/WarpXIO.cpp @@ -644,7 +644,7 @@ WarpX::WritePlotFile () const particle_varnames.push_back("uzold"); } - mypc->WritePlotFile(plotfilename, particle_varnames); + mypc->WritePlotFile(plotfilename); WriteJobInfo(plotfilename); diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index aaf7ead0e..869126fef 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -129,8 +129,7 @@ public: void Checkpoint (const std::string& dir) const; - void WritePlotFile( const std::string& dir, - const amrex::Vector& real_names) const; + void WritePlotFile (const std::string& dir) const; void Restart (const std::string& dir); -- cgit v1.2.3