diff options
author | 2023-08-01 03:29:15 +0200 | |
---|---|---|
committer | 2023-08-01 01:29:15 +0000 | |
commit | 31199f61b1526f61e64d9ff3122298c08d50b81f (patch) | |
tree | 8065bcd0e47b15cefbb22af3e119bb7c42497bde | |
parent | 9867ccb4d8e00d4b331c7446253f4d2031e58952 (diff) | |
download | WarpX-31199f61b1526f61e64d9ff3122298c08d50b81f.tar.gz WarpX-31199f61b1526f61e64d9ff3122298c08d50b81f.tar.zst WarpX-31199f61b1526f61e64d9ff3122298c08d50b81f.zip |
Remove WarpX::GetInstance call from ParserFilter functor (#4132)
* remove WarpX::GetInstance from FilterFunctor
* fix bug according to NeilZaim's suggestion
* Time Doc Strings: Coarsest Level
-rw-r--r-- | Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp | 2 | ||||
-rw-r--r-- | Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H | 2 | ||||
-rw-r--r-- | Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp | 6 | ||||
-rw-r--r-- | Source/Diagnostics/WarpXOpenPMD.H | 1 | ||||
-rw-r--r-- | Source/Diagnostics/WarpXOpenPMD.cpp | 5 | ||||
-rw-r--r-- | Source/Particles/Filter/FilterFunctors.H | 18 |
6 files changed, 19 insertions, 15 deletions
diff --git a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp index de7a5a5cb..2c7e5350a 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp @@ -158,7 +158,7 @@ FlushFormatOpenPMD::WriteToFile ( varnames, mf, geom, output_levels, output_iteration, time, isBTD, full_BTD_snapshot); // particles: all (reside only on locally finest level) - m_OpenPMDPlotWriter->WriteOpenPMDParticles(particle_diags, use_pinned_pc, isBTD, isLastBTDFlush, totalParticlesFlushedAlready); + m_OpenPMDPlotWriter->WriteOpenPMDParticles(particle_diags, time, use_pinned_pc, isBTD, isLastBTDFlush, totalParticlesFlushedAlready); // signal that no further updates will be written to this iteration m_OpenPMDPlotWriter->CloseStep(isBTD, isLastBTDFlush); diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H index 744ef2e4b..429bc4823 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H @@ -48,10 +48,12 @@ public: /** \brief Write particles data to file. * \param[in] filename name of output directory * \param[in] particle_diags Each element of this vector handles output of 1 species. + * \param[in] time the simulation time on the coarsest level * \param[in] isBTD whether this is a back-transformed diagnostic */ void WriteParticles(const std::string& filename, const amrex::Vector<ParticleDiag>& particle_diags, + const amrex::Real time, bool isBTD = false) const; ~FlushFormatPlotfile() {} diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp index b543f19e9..0cf09ebf9 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp @@ -99,7 +99,7 @@ FlushFormatPlotfile::WriteToFile ( WriteAllRawFields(plot_raw_fields, nlev, filename, plot_raw_fields_guards); - WriteParticles(filename, particle_diags, isBTD); + WriteParticles(filename, particle_diags, time, isBTD); WriteJobInfo(filename); @@ -339,7 +339,7 @@ FlushFormatPlotfile::WriteWarpXHeader( void FlushFormatPlotfile::WriteParticles(const std::string& dir, const amrex::Vector<ParticleDiag>& particle_diags, - bool isBTD) const + const amrex::Real time, bool isBTD) const { for (auto& part_diag : particle_diags) { @@ -388,7 +388,7 @@ FlushFormatPlotfile::WriteParticles(const std::string& dir, ParserFilter parser_filter(part_diag.m_do_parser_filter, utils::parser::compileParser<ParticleDiag::m_nvars> (part_diag.m_particle_filter_parser.get()), - pc->getMass()); + pc->getMass(), time); parser_filter.m_units = InputUnits::SI; GeometryFilter const geometry_filter(part_diag.m_do_geom_filter, part_diag.m_diag_domain); diff --git a/Source/Diagnostics/WarpXOpenPMD.H b/Source/Diagnostics/WarpXOpenPMD.H index aaa0acba8..7cc5eda90 100644 --- a/Source/Diagnostics/WarpXOpenPMD.H +++ b/Source/Diagnostics/WarpXOpenPMD.H @@ -136,6 +136,7 @@ public: void WriteOpenPMDParticles ( const amrex::Vector<ParticleDiag>& particle_diags, + const amrex::Real time, const bool use_pinned_pc = false, const bool isBTD = false, const bool isLastBTDFlush = false, diff --git a/Source/Diagnostics/WarpXOpenPMD.cpp b/Source/Diagnostics/WarpXOpenPMD.cpp index 4b463415f..b68cd7232 100644 --- a/Source/Diagnostics/WarpXOpenPMD.cpp +++ b/Source/Diagnostics/WarpXOpenPMD.cpp @@ -514,7 +514,8 @@ WarpXOpenPMDPlot::Init (openPMD::Access access, bool isBTD) void WarpXOpenPMDPlot::WriteOpenPMDParticles (const amrex::Vector<ParticleDiag>& particle_diags, - const bool use_pinned_pc, const bool isBTD, const bool isLastBTDFlush, + const amrex::Real time, const bool use_pinned_pc, + const bool isBTD, const bool isLastBTDFlush, const amrex::Vector<int>& totalParticlesFlushedAlready) { WARPX_PROFILE("WarpXOpenPMDPlot::WriteOpenPMDParticles()"); @@ -575,7 +576,7 @@ WarpXOpenPMDPlot::WriteOpenPMDParticles (const amrex::Vector<ParticleDiag>& part ParserFilter parser_filter(particle_diags[i].m_do_parser_filter, utils::parser::compileParser<ParticleDiag::m_nvars> (particle_diags[i].m_particle_filter_parser.get()), - pc->getMass()); + pc->getMass(), time); parser_filter.m_units = InputUnits::SI; GeometryFilter const geometry_filter(particle_diags[i].m_do_geom_filter, particle_diags[i].m_diag_domain); diff --git a/Source/Particles/Filter/FilterFunctors.H b/Source/Particles/Filter/FilterFunctors.H index c029087b9..e80b0be7d 100644 --- a/Source/Particles/Filter/FilterFunctors.H +++ b/Source/Particles/Filter/FilterFunctors.H @@ -10,7 +10,6 @@ #include "Particles/Pusher/GetAndSetPosition.H" #include "Particles/WarpXParticleContainer.H" #include "Utils/WarpXConst.H" -#include "WarpX.H" #include <AMReX_Gpu.H> #include <AMReX_Parser.H> @@ -91,14 +90,15 @@ struct ParserFilter * \param a_is_active whether the test is active * \param a_filter_parser parser taking t, x, y, z, ux, uy, and uz, and returning a boolean for selected particle * \param a_mass mass of the particle species + * \param time simulation time on the coarsest level */ ParserFilter(bool a_is_active, amrex::ParserExecutor<7> const& a_filter_parser, - amrex::Real a_mass) - : m_is_active(a_is_active), m_function_partparser(a_filter_parser), m_mass(a_mass) - { - m_t = WarpX::GetInstance().gett_new(0); - m_units = InputUnits::WarpX; - } + const amrex::Real a_mass, const amrex::Real time): + m_is_active{a_is_active}, + m_function_partparser{a_filter_parser}, + m_mass{a_mass}, + m_t{time}, + m_units{InputUnits::WarpX}{} /** * \brief return 1 if the particle is selected by the parser @@ -136,10 +136,10 @@ private: public: /** Parser function with 7 input variables, t,x,y,z,ux,uy,uz */ amrex::ParserExecutor<7> const m_function_partparser; - /** Store physical time. */ - amrex::ParticleReal m_t; /** Mass of particle species */ amrex::ParticleReal m_mass; + /** Store physical time on the coarsest level. */ + amrex::ParticleReal m_t; /** keep track of momentum units particles will come in with **/ InputUnits m_units; }; |