Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mini] reset ID incrementor before starting initializing a beam #994

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/run/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

* ``<beam name> 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``
^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
3 changes: 2 additions & 1 deletion src/particles/beam/BeamParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/particles/beam/BeamParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.,
Expand All @@ -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);
Expand Down