|
Molecular Dynamics
v0.4
Project for the Practical hosted by the Scientific Computing Chair
|
Container to store the particles for simulation using the direct sum algorithm. More...
#include <DefaultParticleContainer.h>


Public Member Functions | |
| DefaultParticleContainer ()=default | |
| DefaultParticleContainer (size_t capacity) | |
| Create a ParticleContainer which can store up to capacity particles. More... | |
| void | add (Particle &p) override |
| Add one particle to this container. More... | |
| Particle & | at (size_t i) |
| Obtain particle at position i. More... | |
| size_t | size () const override |
| Retrieve the size of the data structure. More... | |
| size_t | capacity () |
| Retrieve the capacity of this container. More... | |
| std::vector< Particle >::iterator | begin () |
| Obtain an iterator to the first particle in this container. More... | |
| std::vector< Particle >::iterator | end () |
| Obtain an iterator to the last element of this container. More... | |
| void | reserve (size_t n) |
| Used to reserve the capacity of the vector used to storing particles. More... | |
| bool | contains (Particle &p) |
| Check, if this particle container contains an particle p' that equals p. More... | |
| void | applyToEachParticle (const std::function< void(Particle &)> &function) override |
| Iterate over all particles in this container and apply a lambda function to them. More... | |
| void | applyToEachParticleInDomain (const std::function< void(Particle &)> &function) override |
| Iterate over all particles that are part of the domain and apply a lambda function to them. For this container this method does the same as applyToEachParticle(), because every particle is in the simulation domain. More... | |
| void | applyToAllUniquePairsInDomain (const std::function< void(Particle &, Particle &)> &function) override |
| Iterate over all unique pairs of particles being part of the simulation domain (in this container all particles) and apply a lambda function to them. More... | |
Public Member Functions inherited from ParticleContainer | |
| virtual | ~ParticleContainer ()=default |
| Virtual default constructor to guarantee appropriate memory clean up. More... | |
Private Attributes | |
| std::vector< Particle > | particles |
Container to store the particles for simulation using the direct sum algorithm.
The storage of the particles is based on std::vector. This guarantees fast iteration over the particles, because they are stored consecutively in memory.
|
default |
|
explicit |
Create a ParticleContainer which can store up to capacity particles.
| capacity | If the capacity is exceeded the whole data structure will be extended leading to reallocation. |

|
overridevirtual |
Add one particle to this container.
| p | Particle to be added to this container. |
Add one particle to this container. It will be appended.
Implements ParticleContainer.
|
overridevirtual |
Iterate over all unique pairs of particles being part of the simulation domain (in this container all particles) and apply a lambda function to them.
| function | Lambda function that is applied to each unique pair of particles. |
The purpose of this function is provide an easy way of calculating the force between all particles by using Newton's third law of motion.
Implements ParticleContainer.
|
overridevirtual |
Iterate over all particles in this container and apply a lambda function to them.
| function | Lambda function that is applied to each particle. |
Implements ParticleContainer.

|
overridevirtual |
Iterate over all particles that are part of the domain and apply a lambda function to them. For this container this method does the same as applyToEachParticle(), because every particle is in the simulation domain.
| function | Lambda function that is applied to each particle. |
Implements ParticleContainer.

| Particle & DefaultParticleContainer::at | ( | size_t | i | ) |
| std::vector< Particle >::iterator DefaultParticleContainer::begin | ( | ) |
Obtain an iterator to the first particle in this container.
Obtain an iterator to the first particle in this container.
| size_t DefaultParticleContainer::capacity | ( | ) |
Retrieve the capacity of this container.
The capacity of this container is the number of particles which can be stored, before the data structure has to be extended.

| bool DefaultParticleContainer::contains | ( | Particle & | p | ) |
Check, if this particle container contains an particle p' that equals p.
| p | Particle to look for |
This method should only be used for testing purposes in small instances, because the implementation is not that efficient.
| std::vector< Particle >::iterator DefaultParticleContainer::end | ( | ) |
Obtain an iterator to the last element of this container.
Obtain an iterator to the last element of this container.
| void DefaultParticleContainer::reserve | ( | size_t | n | ) |
Used to reserve the capacity of the vector used to storing particles.
| n | desired size |
|
overridevirtual |
Retrieve the size of the data structure.
Provides the number of particles currently stored in the data structure.
Implements ParticleContainer.
|
private |