7 #ifndef SRC_INCLUDE_SMASH_PARTICLES_H_
8 #define SRC_INCLUDE_SMASH_PARTICLES_H_
11 #include <type_traits>
157 void replace(
const ParticleList &to_remove, ParticleList &to_add);
178 assert(
p.type() == new_state.
type());
200 void update(
const ParticleList &old_state, ParticleList &new_state,
205 for (std::size_t i = 0; i < old_state.size(); ++i) {
244 template <
typename T>
289 }
while (
ptr_->hole_);
317 }
while (
ptr_->hole_);
397 while (first->
hole_) {
409 while (first->
hole_) {
438 friend std::ostream &
operator<<(std::ostream &out,
498 std::unique_ptr<ParticleData[]>
data_;
ParticleData contains the dynamic information of a certain particle.
unsigned index_
Internal index in the Particles list.
const ParticleType & type() const
Get the type of the particle.
bool hole_
If true, the object is an entry in Particles::data_ and does not hold valid particle data.
uint32_t id_process() const
Get the id of the last action.
void copy_to(ParticleData &dst) const
Copies some information of the particle to the given particle dst.
int32_t id() const
Get the id of the particle.
const FourVector & position() const
Get the particle's position in Minkowski space.
bool operator>(const GenericIterator &rhs) const
bool operator==(const GenericIterator &rhs) const
std::add_const_t< pointer > const_pointer
add const qualification to a pointer
std::add_lvalue_reference_t< T > reference
Required by STL: expose reference (lvalue)
bool operator<(const GenericIterator &rhs) const
std::ptrdiff_t difference_type
Required by STL: expose difference_type
std::remove_const_t< T > value_type
Required by STL: expose value_type removing const qualification
GenericIterator & operator--()
Advance the iterator to the previous valid (not a hole) entry in Particles.
const_reference operator*() const
GenericIterator operator--(int)
Postfix variant of the above prefix decrement operator.
const_pointer operator->() const
GenericIterator operator++(int)
Postfix variant of the above prefix increment operator.
bool operator<=(const GenericIterator &rhs) const
bool operator!=(const GenericIterator &rhs) const
pointer ptr_
The entry in Particles this iterator points to.
GenericIterator & operator++()
Advance the iterator to the next valid (not a hole) entry in Particles.
GenericIterator(pointer p)
Constructs an iterator pointing to the ParticleData pointed to by p.
std::add_pointer_t< T > pointer
Required by STL: expose pointer (of a reference)
std::bidirectional_iterator_tag iterator_category
Required by STL: expose iterator_category
bool operator>=(const GenericIterator &rhs) const
std::add_const_t< reference > const_reference
add const qualification to a reference
The Particles class abstracts the storage and manipulation of particles.
double time() const
Returns the time of the computational frame.
std::unique_ptr< ParticleData[]> data_
Points to a dynamically allocated array of ParticleData objects.
const ParticleData & update_particle(const ParticleData &p, const ParticleData &new_state)
Updates the particle identified by p with the state stored in new_state.
void update(const ParticleList &old_state, ParticleList &new_state, bool do_replace)
Updates the Particles object, replacing the particles in old_state with the particles in new_state.
const_iterator cend() const
ParticleList copy_to_vector() const
void reset()
Reset the state of the Particles object to an empty list and a new id counter.
bool is_valid(const ParticleData ©) const
Check whether the ParticleData copy is still a valid copy of the one stored in the Particles object.
std::vector< unsigned > dirty_
Stores the indexes in data_ that do not hold valid particle data and should be reused when new partic...
const ParticleData & front() const
const overload of &front()
Particles(const Particles &)=delete
Cannot be copied.
const_iterator end() const
const overload of end()
void copy_in(ParticleData &to, const ParticleData &from)
Particles & operator=(const Particles &)=delete
Cannot be copied.
int id_max_
Highest id of a given particle.
const ParticleData & lookup(const ParticleData &old_state) const
Returns the particle that is currently stored in this object given an old copy of that particle.
void ensure_capacity(unsigned to_add)
Particles()
Creates a new (empty) Particles object.
void replace(const ParticleList &to_remove, ParticleList &to_add)
Replace the particles in to_remove with the particles in to_add in the list of current particles.
const ParticleData & insert(const ParticleData &p)
Inserts the particle into the list of particles.
void create(size_t n, PdgCode pdg)
Add n particles of the same type (pdg) to the list.
void increase_capacity(unsigned new_capacity)
const_iterator cbegin() const
const_iterator begin() const
const overload of begin()
const ParticleData & back() const
const overload of &back()
void remove(const ParticleData &p)
Remove the given particle p from the list.
PdgCode stores a Particle Data Group Particle Numbering Scheme particle type number.
friend std::ostream & operator<<(std::ostream &out, const Particles &particles)
Print effective mass and type name for all particles to the stream.