From 50fa1faac37a428add4742ec613de6d7648d05e9 Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Fri, 7 Jul 2023 17:30:18 +0200 Subject: [PATCH 1/5] reset ID incrementor before starting initializing a beam --- docs/source/run/parameters.rst | 3 +++ src/particles/beam/BeamParticleContainer.H | 3 ++- src/particles/beam/BeamParticleContainer.cpp | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/source/run/parameters.rst b/docs/source/run/parameters.rst index d68a74dc9b..d0a145fda6 100644 --- a/docs/source/run/parameters.rst +++ b/docs/source/run/parameters.rst @@ -483,6 +483,9 @@ which are valid only for certain beam types, are introduced further below under Whether the beam particles are pushed along the z-axis. The momentum is still fully updated. Note: using ``do_z_push = 0`` results in unphysical behavior. +* `` or beams.do_reset_id_init`` (`bool`) optional (default `0`) + Wheter to reset the ID incrementor to 1 before initializing beam particles. + Option: ``fixed_weight`` ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/particles/beam/BeamParticleContainer.H b/src/particles/beam/BeamParticleContainer.H index 82888fb7c7..a04077ecd5 100644 --- a/src/particles/beam/BeamParticleContainer.H +++ b/src/particles/beam/BeamParticleContainer.H @@ -175,7 +175,8 @@ public: BeamBins m_slice_bins; unsigned long long m_total_num_particles {0}; - + /** Whether to reset the global ID incrementor to 1 before initializing this beam */ + bool m_do_reset_id_init {false}; unsigned long long get_total_num_particles () const {return m_total_num_particles;} /** \brief Store the finest level of every beam particle on which_slice in the cpu() attribute. diff --git a/src/particles/beam/BeamParticleContainer.cpp b/src/particles/beam/BeamParticleContainer.cpp index 745f5b6faf..43b6e8738e 100644 --- a/src/particles/beam/BeamParticleContainer.cpp +++ b/src/particles/beam/BeamParticleContainer.cpp @@ -62,6 +62,7 @@ BeamParticleContainer::ReadParameters () queryWithParserAlt(pp, "insitu_file_prefix", m_insitu_file_prefix, pp_alt); queryWithParser(pp, "n_subcycles", m_n_subcycles); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( m_n_subcycles >= 1, "n_subcycles must be >= 1"); + queryWithParserAlt(pp, "do_reset_id_init", m_do_reset_id_init, pp_alt); queryWithParser(pp, "do_salame", m_do_salame); if (m_injection_type == "fixed_ppc" || m_injection_type == "from_file"){ AMREX_ALWAYS_ASSERT_WITH_MESSAGE( m_duz_per_uz0_dzeta == 0., @@ -76,6 +77,7 @@ BeamParticleContainer::InitData (const amrex::Geometry& geom) amrex::ParmParse pp(m_name); amrex::ParmParse pp_alt("beams"); amrex::Real ptime {0.}; + if (m_do_reset_id_init) ParticleType::NextID(1); if (m_injection_type == "fixed_ppc") { queryWithParser(pp, "ppc", m_ppc); From 397b9709b868a83d5a4b006d0fc8d1fe52c6342e Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Fri, 7 Jul 2023 17:40:39 +0200 Subject: [PATCH 2/5] fix --- src/particles/beam/BeamParticleContainer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/particles/beam/BeamParticleContainer.cpp b/src/particles/beam/BeamParticleContainer.cpp index 43b6e8738e..edb5e97d77 100644 --- a/src/particles/beam/BeamParticleContainer.cpp +++ b/src/particles/beam/BeamParticleContainer.cpp @@ -12,6 +12,7 @@ #include "Hipace.H" #include "utils/HipaceProfilerWrapper.H" #include "utils/InsituUtil.H" +#include #ifdef HIPACE_USE_OPENPMD # include #endif From df8383f6bf87423bbac38a75744eab18774d596f Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Fri, 7 Jul 2023 17:43:00 +0200 Subject: [PATCH 3/5] more --- src/particles/beam/BeamParticleContainer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/particles/beam/BeamParticleContainer.cpp b/src/particles/beam/BeamParticleContainer.cpp index edb5e97d77..b4388a6b68 100644 --- a/src/particles/beam/BeamParticleContainer.cpp +++ b/src/particles/beam/BeamParticleContainer.cpp @@ -12,6 +12,7 @@ #include "Hipace.H" #include "utils/HipaceProfilerWrapper.H" #include "utils/InsituUtil.H" +#include #include #ifdef HIPACE_USE_OPENPMD # include From 1ac7ad71e37eabdb9db78636c9e66dbbf594c0a0 Mon Sep 17 00:00:00 2001 From: Maxence Thevenet Date: Fri, 7 Jul 2023 17:46:07 +0200 Subject: [PATCH 4/5] n now? --- src/particles/beam/BeamParticleContainer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/particles/beam/BeamParticleContainer.cpp b/src/particles/beam/BeamParticleContainer.cpp index b4388a6b68..64d1f26fc6 100644 --- a/src/particles/beam/BeamParticleContainer.cpp +++ b/src/particles/beam/BeamParticleContainer.cpp @@ -12,8 +12,7 @@ #include "Hipace.H" #include "utils/HipaceProfilerWrapper.H" #include "utils/InsituUtil.H" -#include -#include +#include "particles/particles_utils/ParticleUtil.H" #ifdef HIPACE_USE_OPENPMD # include #endif From d54b466a1a32a59354a88894eef2677e72adb0c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxence=20Th=C3=A9venet?= Date: Mon, 10 Jul 2023 12:25:04 +0200 Subject: [PATCH 5/5] Update src/particles/beam/BeamParticleContainer.cpp Co-authored-by: Severin Diederichs <65728274+SeverinDiederichs@users.noreply.github.com> --- src/particles/beam/BeamParticleContainer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/particles/beam/BeamParticleContainer.cpp b/src/particles/beam/BeamParticleContainer.cpp index 64d1f26fc6..43b6e8738e 100644 --- a/src/particles/beam/BeamParticleContainer.cpp +++ b/src/particles/beam/BeamParticleContainer.cpp @@ -12,7 +12,6 @@ #include "Hipace.H" #include "utils/HipaceProfilerWrapper.H" #include "utils/InsituUtil.H" -#include "particles/particles_utils/ParticleUtil.H" #ifdef HIPACE_USE_OPENPMD # include #endif