WaSH Docs
particle.hpp
1 #pragma once
2 
3 #if !defined WASH_WSER && !defined WASH_WISB && !defined WASH_WEST && !defined WASH_CSTONE && !defined WASH_WONE
4 #error "Please specify an implementation when compiling WASH"
5 #endif
6 
7 #include <string>
8 #include <vector>
9 
10 #include "vector.hpp"
11 
12 namespace wash {
13  class Particle {
14  private:
15  // All implementations
16  unsigned local_idx;
18 #if defined WASH_CSTONE
19  unsigned global_idx;
20 #elif defined WASH_WONE || defined WASH_WEST || defined WASH_WISB
21  // No further properties needed
22 #elif defined WASH_WSER
23  double density;
24  double mass;
25  double smoothing_length;
26  SimulationVecT pos;
27  SimulationVecT vel;
28  SimulationVecT acc;
29  std::unordered_map<std::string, double> force_scalars;
30  std::unordered_map<std::string, SimulationVecT> force_vectors;
31 
32  void initialise_particle_forces();
33 #endif
34 
35  public:
36  // All implementations
37  Particle(const unsigned local_idx);
38 #if defined WASH_CSTONE
39  Particle(const unsigned global_idx, const unsigned local_idx) : global_idx(global_idx), local_idx(local_idx) {}
40 #endif
41 
42 // elif defined WASH_WEST || defined WASH_WISB || defined WASH_WSER
43 // Particle(const size_t id, const double density, const double mass, const double smoothing_length,
44 // const SimulationVecT pos, const SimulationVecT vel, const SimulationVecT acc);
45 // #endif
46 
47 #if defined WASH_CSTONE || defined WASH_WEST || defined WASH_WISB || defined WASH_WSER
48 
51  int get_local_idx() const;
52 
53  std::vector<Particle> get_neighbors() const;
54 #endif
55 
59  unsigned get_id() const;
60 
61  double get_density() const;
62 
63  void set_density(const double density);
64 
65  double get_mass() const;
66 
67  void set_mass(const double mass);
68 
69  double get_smoothing_length() const;
70 
71  void set_smoothing_length(const double smoothing_length);
72 
73  SimulationVecT get_pos() const;
74 
75  void set_pos(const SimulationVecT pos);
76 
77  SimulationVecT get_vel() const;
78 
79  void set_vel(const SimulationVecT vel);
80 
81  SimulationVecT get_acc() const;
82 
83  void set_acc(const SimulationVecT acc);
84 
85  double get_force_scalar(const std::string& force) const;
86 
87  void set_force_scalar(const std::string& force, const double value);
88 
89  SimulationVecT get_force_vector(const std::string& force) const;
90 
91  void set_force_vector(const std::string& force, const SimulationVecT value);
92 
93  double get_vol() const;
94 
95  unsigned recalculate_neighbors(unsigned max_count) const;
96 
97  bool operator==(const Particle& other) const;
98 
99  bool operator!=(const Particle& other) const;
100 
101  friend std::ostream& operator<<(std::ostream& os, const Particle& p);
102 
103 #if defined WASH_WONE || defined WASH_WEST
104  // Implicit cast to unsigned so that Particle can be used as array index
105  operator unsigned() const;
106 #endif
107 
108  Particle(const Particle&) = delete; // Delete copy constructor
109  Particle& operator=(const Particle&) = delete; // Delete copy assignment operator
110 
111  };
112 }
unsigned get_id() const
Returns the global ID of the particle.
Definition: particle.cpp:9
Custom vector class for WaSH simulation.
Definition: vector.hpp:37
bool operator!=(const Particle &other) const
Inverse of equality check.
Definition: particle.cpp:80
TODO: Consider having this as a private header in WISB/WS2ST/etc implementations. ...
Definition: ascii.hpp:5
Particle(const unsigned local_idx)
TODO: see if this works if it&#39;s a glocal spec defined flag rather than in just one file...
Definition: particle.cpp:6
bool operator==(const Particle &other) const
Compare particle equality by their IDs.
Definition: particle.cpp:78
Definition: particle.hpp:13