Skip to content

Commit

Permalink
[mini] reset ID incrementor before starting initializing a beam (#994)
Browse files Browse the repository at this point in the history
* reset ID incrementor before starting initializing a beam

* fix

* more

* n now?

* Update src/particles/beam/BeamParticleContainer.cpp

Co-authored-by: Severin Diederichs <65728274+SeverinDiederichs@users.noreply.github.com>

---------

Co-authored-by: Severin Diederichs <65728274+SeverinDiederichs@users.noreply.github.com>
  • Loading branch information
MaxThevenet and SeverinDiederichs authored Jul 10, 2023
1 parent d669bfd commit 1869942
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
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

0 comments on commit 1869942

Please sign in to comment.