Molecular Dynamics Simulation  1.0
DirectSumContainer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
7 
17  std::vector<Particle> particles;
18 
19  public:
27  DirectSumContainer() = default;
28 
36  explicit DirectSumContainer(int n);
37 
45  void reserve(size_t n) override;
46 
54  [[nodiscard]] std::size_t size() const override;
55 
63  [[nodiscard]] std::size_t capacity() const;
64 
72  void addParticle(const Particle& p) override;
73 
81  void addParticle(Particle&& p) override;
82 
91  Particle& operator[](int i) override;
92 
100  [[nodiscard]] std::vector<Particle>::iterator begin() override;
101 
108  [[nodiscard]] std::vector<Particle>::iterator end() override;
109 
117  [[nodiscard]] std::vector<Particle>::const_iterator begin() const override;
118 
126  [[nodiscard]] std::vector<Particle>::const_iterator end() const override;
127 
132  [[nodiscard]] const std::vector<Particle>& getParticles() const override;
133 
137  void prepareForceCalculation() override;
138 
146  void applySimpleForces(const std::vector<std::shared_ptr<SimpleForceSource>>& simple_force_sources) override;
147 
156  void applyPairwiseForces(const std::vector<std::shared_ptr<PairwiseForceSource>>& pairwise_force_sources) override;
157 
166  void applyTargettedForces(const std::vector<std::shared_ptr<TargettedForceSource>>& targetted_force_sources,
167  double curr_simulation_time) override;
168 };
Wrapper class for a set of particles.
Particle & operator[](int i) override
Returns a particle.
std::size_t capacity() const
Returns the capacity of the container.
std::vector< Particle >::iterator begin() override
Returns an iterator to the first particle.
void applyTargettedForces(const std::vector< std::shared_ptr< TargettedForceSource >> &targetted_force_sources, double curr_simulation_time) override
Applies the given targetted force sources to the particles.
std::vector< Particle >::iterator end() override
Returns an end iterator for this container.
DirectSumContainer()=default
Default constructor.
void reserve(size_t n) override
Reserves memory for particles.
void applySimpleForces(const std::vector< std::shared_ptr< SimpleForceSource >> &simple_force_sources) override
Applies the given simple force sources to the particles.
std::vector< Particle > particles
Internal data structure for the particles.
void addParticle(const Particle &p) override
Adds a particle to the container.
void applyPairwiseForces(const std::vector< std::shared_ptr< PairwiseForceSource >> &pairwise_force_sources) override
Applies the given force sources to the particles.
void prepareForceCalculation() override
Prepares everything for the force calculations (must be called before applySimpleForces and applyPair...
std::size_t size() const override
Returns the amount of particles.
const std::vector< Particle > & getParticles() const override
Returns a vector of all particles in the container.
Interface for particle containers.
Class to represent a particle.
Definition: Particle.h:26