Molecular Dynamics Simulation  1.0
TargettedForceSource.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <vector>
5 
6 #include "particles/Particle.h"
7 
18  protected:
22  std::vector<size_t> target_indices;
23 
24  public:
28  inline TargettedForceSource(const std::vector<size_t>& target_indices) : target_indices(target_indices){};
29 
35  virtual ~TargettedForceSource() = default;
36 
45  virtual void applyForce(std::vector<Particle>& particle_vector, double curr_simulation_time) const = 0;
46 
50  virtual explicit operator std::string() const = 0;
51 };
52 
53 // overload the << operator for the ForceSource class to allow easier printing
54 inline std::ostream& operator<<(std::ostream& os, const TargettedForceSource& forceSource) {
55  os << static_cast<std::string>(forceSource);
56  return os;
57 }
std::ostream & operator<<(std::ostream &os, const TargettedForceSource &forceSource)
Interface for targetted force source classes.
TargettedForceSource(const std::vector< size_t > &target_indices)
virtual ~TargettedForceSource()=default
Virtual destructor for correct cleanup of derived classes.
virtual void applyForce(std::vector< Particle > &particle_vector, double curr_simulation_time) const =0
Applies the force directly to the particles with the specified indices within the vector.
std::vector< size_t > target_indices
Indices of the particles on which the force is applied.