From 768093cffd18a2c37d90be1033ae94c3ff38776a Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 9 May 2019 15:53:08 -0700 Subject: move particle plot options to PPC --- Source/Particles/PhysicalParticleContainer.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 2fa39d87d..c6bc92ff6 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -82,6 +82,26 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_splitting", do_splitting); pp.query("split_type", split_type); pp.query("do_continuous_injection", do_continuous_injection); + { + pp.queryarr("plot_vars", plot_vars); + if (plot_vars.size() == 0){ + if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ + plot_flags.resize(PIdx::nattribs + 6, 1); + } else { + plot_flags.resize(PIdx::nattribs, 1); + } + } else { + if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ + plot_flags.resize(PIdx::nattribs + 6, 0); + } else { + plot_flags.resize(PIdx::nattribs, 0); + } + + for (const auto& var : plot_vars){ + plot_flags[ParticleStringNames::to_index.at(var)] = 1; + } + } + } } PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core) -- cgit v1.2.3 From 886d49c55cd179c34197fef2880d9623ce37ce22 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 9 May 2019 19:46:35 -0700 Subject: Can select particle quantities to dump --- Source/Diagnostics/ParticleIO.cpp | 10 +++++-- Source/Particles/PhysicalParticleContainer.H | 2 ++ Source/Particles/PhysicalParticleContainer.cpp | 41 +++++++++++++++++--------- Source/Particles/WarpXParticleContainer.H | 6 ++++ 4 files changed, 42 insertions(+), 17 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index d5de96c96..12e170c24 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -32,11 +32,15 @@ MultiParticleContainer::WritePlotFile (const std::string& dir, { Vector int_names; Vector int_flags; + Vector real_flags; for (unsigned i = 0, n = species_names.size(); i < n; ++i) { - allcontainers[i]->WritePlotFile(dir, species_names[i], - allcontainers[i]->plot_flags, int_flags, - real_names, int_names); + real_flags = allcontainers[i]->plot_flags; + for(int j=0;jWritePlotFile(dir, species_names[i], + real_flags, int_flags, + real_names, int_names); } } diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index ac803494d..c9d6b2c2e 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -112,8 +112,10 @@ protected: bool boost_adjust_transverse_positions = false; bool do_backward_propagation = false; + /* amrex::Vector plot_flags; amrex::Vector plot_vars; + */ long NumParticlesToAdd (const amrex::Box& overlap_box, const amrex::RealBox& overlap_realbox, diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index c6bc92ff6..1bf41816e 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -82,22 +82,35 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_splitting", do_splitting); pp.query("split_type", split_type); pp.query("do_continuous_injection", do_continuous_injection); - { - pp.queryarr("plot_vars", plot_vars); - if (plot_vars.size() == 0){ - if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ - plot_flags.resize(PIdx::nattribs + 6, 1); - } else { - plot_flags.resize(PIdx::nattribs, 1); - } - } else { - if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ - plot_flags.resize(PIdx::nattribs + 6, 0); - } else { - plot_flags.resize(PIdx::nattribs, 0); - } + pp.query("plot_species", plot_species); + int do_user_plot_vars; + do_user_plot_vars = pp.queryarr("plot_vars", plot_vars); + if (not do_user_plot_vars){ + // By default, all particle variables are dumped to plotfiles, + // including {x,y,z,ux,uy,uz}old variables when running in a + // boosted frame + if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ + plot_flags.resize(PIdx::nattribs + 6, 1); + } else { + plot_flags.resize(PIdx::nattribs, 1); + } + } else { + // Set plot_flag to 0 for all attribs + if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ + plot_flags.resize(PIdx::nattribs + 6, 0); + } else { + // Set plot_flags to 1 for data in plot_vars + plot_flags.resize(PIdx::nattribs, 0); + Print()<<"here2"<.plot_vars argument not in ParticleStringNames"); plot_flags[ParticleStringNames::to_index.at(var)] = 1; } } diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index d56d14d96..51dc5ec05 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -272,7 +272,13 @@ protected: amrex::Vector > 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 plot_flags; + // list of names of attributes to dump. amrex::Vector plot_vars; private: -- cgit v1.2.3 From 8e5e956f751e47f6eb8435be56dc623ce770c434 Mon Sep 17 00:00:00 2001 From: MaxThevenet Date: Thu, 9 May 2019 20:08:24 -0700 Subject: some cleaning --- Source/Diagnostics/ParticleIO.cpp | 13 ++++++------- Source/Particles/PhysicalParticleContainer.H | 5 ----- Source/Particles/PhysicalParticleContainer.cpp | 4 +--- 3 files changed, 7 insertions(+), 15 deletions(-) (limited to 'Source/Particles/PhysicalParticleContainer.cpp') diff --git a/Source/Diagnostics/ParticleIO.cpp b/Source/Diagnostics/ParticleIO.cpp index 12e170c24..5cc2b9e6e 100644 --- a/Source/Diagnostics/ParticleIO.cpp +++ b/Source/Diagnostics/ParticleIO.cpp @@ -32,15 +32,14 @@ MultiParticleContainer::WritePlotFile (const std::string& dir, { Vector int_names; Vector int_flags; - Vector real_flags; for (unsigned i = 0, n = species_names.size(); i < n; ++i) { - real_flags = allcontainers[i]->plot_flags; - for(int j=0;jWritePlotFile(dir, species_names[i], - real_flags, int_flags, - real_names, int_names); + auto& pc = allcontainers[i]; + if (pc->plot_species) { + pc->WritePlotFile(dir, species_names[i], + pc->plot_flags, int_flags, + real_names, int_names); + } } } diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index c9d6b2c2e..4f365768b 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -112,11 +112,6 @@ protected: bool boost_adjust_transverse_positions = false; bool do_backward_propagation = false; - /* - amrex::Vector plot_flags; - amrex::Vector plot_vars; - */ - long NumParticlesToAdd (const amrex::Box& overlap_box, const amrex::RealBox& overlap_realbox, const amrex::RealBox& tile_real_box, diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 1bf41816e..b3c598c22 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -100,9 +100,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp if (WarpX::do_boosted_frame_diagnostic && WarpX::do_boosted_frame_particles){ plot_flags.resize(PIdx::nattribs + 6, 0); } else { - // Set plot_flags to 1 for data in plot_vars plot_flags.resize(PIdx::nattribs, 0); - Print()<<"here2"<.plot_vars argument not in ParticleStringNames"); + "plot_vars argument not in ParticleStringNames"); plot_flags[ParticleStringNames::to_index.at(var)] = 1; } } -- cgit v1.2.3