19#define SIGMA_DEFAULT 1
20#define EPSILON_DEFAULT 1
24#define MASS_ERROR "The mass of a particle must be positive for the currently available simulations!"
29#define DO_IF_NOT_WALL(_p, _expr) \
30 if ((_p).getType() != 1) { \
33#define SKIP_IF_WALL(_p) \
34 if ((_p).getType() == 1) \
38#define CONTINUE_IF_INACTIVE(p) (void)0
40#define CONTINUE_IF_INACTIVE(p) \
41 if (!(p).isActive()) \
49 std::array<double, 3>
x;
52 std::array<double, 3>
v;
58 std::array<double, 3>
f;
164 Particle(
const std::array<double, 3> &
x,
const std::array<double, 3> &
v,
const std::array<double, 3> &
f,
165 const std::array<double, 3> &
old_f,
double m,
int type,
double eps,
double sigma,
double k,
double r_0,
176 inline std::array<double, 3> &
getX() {
return x; }
183 inline std::array<double, 3> &
getV() {
return v; }
190 inline std::array<double, 3> &
getF() {
return f; }
236 inline const std::array<double, 3> &
getX()
const {
return x; }
243 inline const std::array<double, 3> &
getV()
const {
return v; }
257 inline const std::array<double, 3> &
getF()
const {
return f; }
271 inline double getM()
const {
return m; }
299 inline double getK()
const {
return k; }
353 void setX(
const std::array<double, 3> &new_x);
360 void setV(
const std::array<double, 3> &new_v);
388 void setF(
const std::array<double, 3> &new_f);
395 void setOldF(
const std::array<double, 3> &new_old_f);
Helper class for systems that may not have OpenMP functionality.
int omp_lock_t
Definition OMPWrapper.h:22
#define TYPE_DEFAULT
Definition Particle.h:18
std::ostream & operator<<(std::ostream &stream, const Particle &p)
Overload of the << operator for output streams, used primarily with string streams or console output.
#define K_DEFAULT
Definition Particle.h:21
#define FZUP_DEFAULT
Definition Particle.h:23
#define EPSILON_DEFAULT
Definition Particle.h:20
#define R0_DEFAULT
Definition Particle.h:22
#define SIGMA_DEFAULT
Definition Particle.h:19
Particle class modeling a particle's position, velocity, force, mass and type.
Definition Particle.h:46
std::array< double, 3 > x
Position of the particle.
Definition Particle.h:49
virtual ~Particle()
Destroys the Particle object.
double epsilon
Depth of the potential well. Lennard-Jones parameter.
Definition Particle.h:76
std::array< double, 3 > v
Velocity of the particle.
Definition Particle.h:52
bool operator==(const Particle &other) const
Overload of the equality operator for Particle objects.
void setK(double new_k)
Sets the new stiffness constant to a given value.
double getSigma() const
Gets the Lennard-Jones parameter of the particle.
Definition Particle.h:292
void setR0(double new_r_0)
Sets the new average bond length to a given value.
bool isActive() const
Checks if the particle is currently active.
Definition Particle.h:330
const std::array< double, 3 > & getThermalMotion() const
Gets the thermal motion of this particle (const).
Definition Particle.h:250
void setFZUP(double new_fzup)
Sets the new upward force to a given value.
void setV(const std::array< double, 3 > &new_v)
Sets the new velocity of the particle to a given value.
void setDirectNeighbours(const std::vector< std::reference_wrapper< Particle > > &neighbours)
Sets the direct neighbours of the particle.
double getK() const
Gets the stiffness constant .
Definition Particle.h:299
Particle(const Particle &other)
Construct a new Particle object using another Particle's data.
const std::array< double, 3 > & getOldF() const
Gets the force previously effective on this particle (const).
Definition Particle.h:264
int type
Type of the particle. 1 if wall, 0 otherwise.
Definition Particle.h:73
Particle(const std::array< double, 3 > &x, const std::array< double, 3 > &v, const std::array< double, 3 > &f, const std::array< double, 3 > &old_f, double m, int type, double eps, double sigma, double k, double r_0, double fzup, int cellIndex)
Construct a new Particle object using explicit values for every data field.
std::string toString() const
Returns a string representation of this particle.
int getId() const
Get the ID of this particle.
Definition Particle.h:339
double getFZUP() const
Gets the constant upward force .
Definition Particle.h:313
std::vector< std::reference_wrapper< Particle > > direct_neighbours
Direct (up-down, left-right) neighbours of the particle (for membranes).
Definition Particle.h:64
std::array< double, 3 > & getX()
Gets the position of this particle.
Definition Particle.h:176
int id
A unique ID for this particle. Currently only used for debug purposes.
Definition Particle.h:106
double r_0
The average bond length for membrane simulations.
Definition Particle.h:85
void setX(const std::array< double, 3 > &new_x)
Sets the new position of the particle to a given value.
void markInactive()
Sets the Particle's active status to "inactive".
void setDiagonalNeighbours(const std::vector< std::reference_wrapper< Particle > > &neighbours)
Sets the diagonal neighbours of the particle.
double k
The stiffness constant for membrane simulations.
Definition Particle.h:82
Particle(const std::array< double, 3 > &x, const std::array< double, 3 > &v, double m, int type=TYPE_DEFAULT, double eps=EPSILON_DEFAULT, double sigma=SIGMA_DEFAULT, double k=K_DEFAULT, double r_0=R0_DEFAULT, double fzup=FZUP_DEFAULT)
Construct a new Particle object using explicit values for each new data field.
bool active
The status of the particle.
Definition Particle.h:103
const std::array< double, 3 > & getF() const
Gets the force effective on this particle (const).
Definition Particle.h:257
void setEpsilon(double new_eps)
Sets the new Lennard-Jones parameter of the particle to a given value.
std::array< double, 3 > f
Force effective on this particle.
Definition Particle.h:58
omp_lock_t lock
A mutual exclusion lock, used alongside parallelization.
Definition Particle.h:94
omp_lock_t & getLock()
Get a reference to the Lock object.
Definition Particle.h:346
int getType() const
Gets the type of the particle.
Definition Particle.h:278
Particle(int type=0)
Construct a new Particle object by optionally passing its type. Prevents implicit conversions.
void setOldF(const std::array< double, 3 > &new_old_f)
Sets the new previously effective force on the particle to a given value.
void setType(double new_type)
Sets the new type of the particle to a given value.
std::array< double, 3 > old_f
Force which was effective on this particle.
Definition Particle.h:61
double getR0() const
Gets the average bond length of a molecule pair .
Definition Particle.h:306
void setFToZero()
Resets the force of the particle to 0,0,0.
const std::vector< std::reference_wrapper< Particle > > & getDiagonalNeighbours() const
Gets the diagonal neighbours of this particle (const).
Definition Particle.h:227
void setM(double new_m)
Sets the new mass of the particle to a given value.
const std::vector< std::reference_wrapper< Particle > > & getDirectNeighbours() const
Gets the direct neighbours of this particle (const).
Definition Particle.h:211
void setThermalMotion(const std::array< double, 3 > &new_thermal_motion)
Sets the new thermal motion of the particle to a given value.
double fzup
The constant upward force for membrane simulations.
Definition Particle.h:88
std::array< double, 3 > & getV()
Gets the velocity of this particle.
Definition Particle.h:183
double getM() const
Gets the mass of the particle.
Definition Particle.h:271
double sigma
Distance where the Lennard-Jones potential reaches zero. Lennard-Jones parameter.
Definition Particle.h:79
bool operator!=(const Particle &other) const
Overload of the inequality operator for Particle objects.
std::array< double, 3 > thermal_motion
Thermal motion of the particle.
Definition Particle.h:55
std::vector< std::reference_wrapper< Particle > > diagonal_neighbours
Diagonal neighbours of the particle (for membranes).
Definition Particle.h:67
std::array< double, 3 > & getOldF()
Gets the force previously effective on this particle.
Definition Particle.h:197
void setSigma(double new_sigma)
Sets the new Lennard-Jones parameter of the particle to a given value.
void setCellIndex(int new_index)
Sets the new index in a CellContainer.
double getEpsilon() const
Gets the Lennard-Jones parameter of the particle.
Definition Particle.h:285
int getCellIndex() const
Get the index of the particle in a CellContainer.
Definition Particle.h:322
const std::array< double, 3 > & getX() const
Gets the position of this particle (const).
Definition Particle.h:236
std::vector< std::reference_wrapper< Particle > > & getDiagonalNeighbours()
Gets the diagonal neighbours of this particle.
Definition Particle.h:220
int cellIndex
The cell index of the particle, to be used with the linked cell method.
Definition Particle.h:91
double m
Mass of this particle.
Definition Particle.h:70
std::array< double, 3 > & getF()
Gets the force effective on this particle.
Definition Particle.h:190
void setF(const std::array< double, 3 > &new_f)
Sets the new force effective on the particle to a given value.
std::vector< std::reference_wrapper< Particle > > & getDirectNeighbours()
Gets the direct neighbours of this particle.
Definition Particle.h:204
const std::array< double, 3 > & getV() const
Gets the velocity of this particle (const).
Definition Particle.h:243
Enumeration class corresponding to the type schema type.
Definition vtk-unstructured.h:2125