MolSim
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Types | Private Attributes | List of all members
ParticleContainer Class Reference

Class for encapsulating multiple Particle objects.. More...

#include <ParticleContainer.h>

Classes

class  PairIterator
 Custom pair iterator for iterating through all possible pairs of Particle objects. More...
 

Public Member Functions

ContainerType::iterator begin ()
 Standard library iterator function for marking the beginning of the iteration process.
 
ContainerType::iterator end ()
 Standard library iterator function for marking the end of the iteration process.
 
ContainerType::const_iterator begin () const
 Standard library iterator function for marking the beginning of the iteration process of a const ParticleContainer.
 
ContainerType::const_iterator end () const
 Standard library iterator function for marking the end of the iteration process of a const ParticleContainer.
 
Particleoperator[] (size_t index)
 Override of the [] operator.
 
const Particleoperator[] (size_t index) const
 Override of the [] operator (const).
 
PairIterator beginPairs ()
 Function marking the beginning of the pair iteration process.
 
PairIterator endPairs ()
 Function marking the end of the pair iteration process.
 
 ParticleContainer ()
 Constructs a ParticleContainer with an empty default-initialized ContainerType.
 
 ParticleContainer (size_t num_particles)
 Constructs a ParticleContainer with an empty ContainerType and reserves space for num_particle Particle entries.
 
virtual ~ParticleContainer ()
 Destroys the ParticleContainer object.
 
void addParticle (const Particle &particle)
 Adds an already existing Particle to the container.
 
void addParticle (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)
 Creates and adds a new particle to the container.
 
void addParticle (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)
 Creates and adds a new complete particle to the container.
 
void reserve (size_t capacity)
 Reserves a certain amount of spaces inside the Particle vector.
 
Particleget (size_t index)
 Gets a Particle by index. Performs bounds checking and terminates on invalid index.
 
const Particleget (size_t index) const
 Gets a const Particle by index. Performs bounds checking and terminates on invalid index.
 
int getSpecialForceLimit () const
 Gets the number of iterations after which the special upward force will no longer be applied.
 
void setSpecialForceLimit (int limit)
 Sets the number of iterations after which the special upward force will no longer be applied.
 
void decrementSpecialForceLimit ()
 Decrements the number of iterations after which the special upward force will no longer be applied by one.
 
size_t size () const
 Returns the size of the container.
 
size_t activeSize () const
 Returns the amount of active particles in the container.
 
size_t nonWallSize () const
 Returns the amount of active, mobile, non-wall particles in the container.
 
bool isEmpty () const
 Checks if the container is empty.
 
ContainerTypegetParticles ()
 Gets a reference to the inner Particle container.
 
bool operator== (const ParticleContainer &other) const
 Overload of the equality operator. Checks if two ParticleContainers have the same Particle objects.
 
bool operator!= (const ParticleContainer &other) const
 Overload of the inequality operator. Checks if two ParticleContainers have the at least one differing Particle object or different sizes.
 
std::string toString () const
 Returns a string representation of this container.
 

Private Types

using ContainerType = std::vector< Particle >
 The chosen data type for storing Particle objects dynamically and contiguously is a std::vector.
 

Private Attributes

ContainerType m_particles
 A ContainerType storing multiple Particle objects, forming the base of this class.
 
int m_specialForceLimit
 The number of iterations after which the special upward force will no longer be applied, for membrane simulations.
 

Detailed Description

Class for encapsulating multiple Particle objects..

Member Typedef Documentation

◆ ContainerType

using ParticleContainer::ContainerType = std::vector<Particle>
private

The chosen data type for storing Particle objects dynamically and contiguously is a std::vector.

Constructor & Destructor Documentation

◆ ParticleContainer() [1/2]

ParticleContainer::ParticleContainer ( )

Constructs a ParticleContainer with an empty default-initialized ContainerType.

◆ ParticleContainer() [2/2]

ParticleContainer::ParticleContainer ( size_t  num_particles)
explicit

Constructs a ParticleContainer with an empty ContainerType and reserves space for num_particle Particle entries.

Parameters
num_particlesThe amount of space to be reserved in the empty ContainerType.

◆ ~ParticleContainer()

virtual ParticleContainer::~ParticleContainer ( )
virtual

Destroys the ParticleContainer object.

Member Function Documentation

◆ activeSize()

size_t ParticleContainer::activeSize ( ) const

Returns the amount of active particles in the container.

Returns
The number of active particles in the container.

◆ addParticle() [1/3]

void ParticleContainer::addParticle ( const Particle particle)

Adds an already existing Particle to the container.

Parameters
particleThe Particle to be added to m_particles.

◆ addParticle() [2/3]

void ParticleContainer::addParticle ( 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 
)

Creates and adds a new complete particle to the container.

Parameters
xA reference to the array containing data for the position \( x \).
vA reference to the array containing data for the velocity \( v \).
fA reference to the array containing data for the force \( F \) effective on this particle.
old_fA reference to the array containing data for the old force \( F \) effective on this particle.
mThe mass \( m \) of the particle.
typeThe type of the particle.
epsThe Lennard-Jones parameter \( \epsilon \) of the particle.
sigmaThe Lennard-Jones parameter \( \sigma \) of the particle.
kThe stiffness constant \( k \), used for membrane simulations.
r_0The average bond length \( r_0 \), used for membrane simulations.
fzupThe constant upward force \( F_{Z-UP} \), used for membrane simulations.
cellIndexThe index of this particle inside a cell. For use with the linked cell method.

◆ addParticle() [3/3]

void ParticleContainer::addParticle ( 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 
)

Creates and adds a new particle to the container.

Parameters
xThe position of the new particle.
vThe velocity of the new particle.
mThe mass of the new particle.
typeThe type of the new particle.
epsThe Lennard-Jones parameter \( \epsilon \) of the particle.
sigmaThe Lennard-Jones parameter \( \sigma \) of the particle.
kThe stiffness constant \( k \), used for membrane simulations.
r_0The average bond length \( r_0 \), used for membrane simulations.
fzupThe constant upward force \( F_{Z-UP} \), used for membrane simulations.

◆ begin() [1/2]

ContainerType::iterator ParticleContainer::begin ( )

Standard library iterator function for marking the beginning of the iteration process.

Returns
An iterator pointing to the first element of m_particles.

◆ begin() [2/2]

ContainerType::const_iterator ParticleContainer::begin ( ) const

Standard library iterator function for marking the beginning of the iteration process of a const ParticleContainer.

Returns
An iterator pointing to the first element of m_particles.

◆ beginPairs()

PairIterator ParticleContainer::beginPairs ( )

Function marking the beginning of the pair iteration process.

Returns
A PairIterator pointing to the first possible particle pair.

◆ decrementSpecialForceLimit()

void ParticleContainer::decrementSpecialForceLimit ( )

Decrements the number of iterations after which the special upward force will no longer be applied by one.

◆ end() [1/2]

ContainerType::iterator ParticleContainer::end ( )

Standard library iterator function for marking the end of the iteration process.

Returns
An iterator pointing to the last element of m_particles.

◆ end() [2/2]

ContainerType::const_iterator ParticleContainer::end ( ) const

Standard library iterator function for marking the end of the iteration process of a const ParticleContainer.

Returns
An iterator pointing to the last element of m_particles.

◆ endPairs()

PairIterator ParticleContainer::endPairs ( )

Function marking the end of the pair iteration process.

Returns
A PairIterator pointing to the last possible particle pair.

◆ get() [1/2]

Particle & ParticleContainer::get ( size_t  index)

Gets a Particle by index. Performs bounds checking and terminates on invalid index.

Parameters
indexThe index of the Particle to get.
Returns
A reference to the Particle at the specified index.

◆ get() [2/2]

const Particle & ParticleContainer::get ( size_t  index) const

Gets a const Particle by index. Performs bounds checking and terminates on invalid index.

Parameters
indexThe index of the Particle to get.
Returns
A const reference to the Particle at the specified index.

◆ getParticles()

ContainerType & ParticleContainer::getParticles ( )

Gets a reference to the inner Particle container.

Returns
A ContainerType& referencing m_particles.

◆ getSpecialForceLimit()

int ParticleContainer::getSpecialForceLimit ( ) const

Gets the number of iterations after which the special upward force will no longer be applied.

Returns
The number of iterations after which the special upward force will no longer be applied.

◆ isEmpty()

bool ParticleContainer::isEmpty ( ) const

Checks if the container is empty.

Returns
true if there are no Particle objects in the container.
false if there is at least one Particle objects in the container.

◆ nonWallSize()

size_t ParticleContainer::nonWallSize ( ) const

Returns the amount of active, mobile, non-wall particles in the container.

Returns
The number of active, mobile, non-wall particles in the container.

◆ operator!=()

bool ParticleContainer::operator!= ( const ParticleContainer other) const

Overload of the inequality operator. Checks if two ParticleContainers have the at least one differing Particle object or different sizes.

Parameters
otherThe ParticleContainer to compare the current one with.
Returns
true if there is at least one differing particle in one of the containers or the sizes differ.
false if both ParticleContainers contain the same particles.

◆ operator==()

bool ParticleContainer::operator== ( const ParticleContainer other) const

Overload of the equality operator. Checks if two ParticleContainers have the same Particle objects.

Parameters
otherThe ParticleContainer to compare the current one with.
Returns
true if both ParticleContainers contain the same particles.
false if there is at least one differing particle in one of the containers or the sizes differ.

◆ operator[]() [1/2]

Particle & ParticleContainer::operator[] ( size_t  index)

Override of the [] operator.

Gets a Particle by index. Does NOT perform bounds checking.

Parameters
indexThe index of the Particle to get.
Returns
A reference to the Particle at the specified index.

◆ operator[]() [2/2]

const Particle & ParticleContainer::operator[] ( size_t  index) const

Override of the [] operator (const).

Gets a Particle by index. Does NOT perform bounds checking.

Parameters
indexThe index of the Particle to get.
Returns
A const reference to the Particle at the specified index.

◆ reserve()

void ParticleContainer::reserve ( size_t  capacity)

Reserves a certain amount of spaces inside the Particle vector.

Parameters
capacityThe amount of contiguous spaces to reserve in m_particles.

◆ setSpecialForceLimit()

void ParticleContainer::setSpecialForceLimit ( int  limit)

Sets the number of iterations after which the special upward force will no longer be applied.

Parameters
limitThe number of iterations after which the special upward force will no longer be applied.

◆ size()

size_t ParticleContainer::size ( ) const

Returns the size of the container.

Returns
The size of the container.

◆ toString()

std::string ParticleContainer::toString ( ) const

Returns a string representation of this container.

Returns
A std::string of this container.

Member Data Documentation

◆ m_particles

ContainerType ParticleContainer::m_particles
private

A ContainerType storing multiple Particle objects, forming the base of this class.

◆ m_specialForceLimit

int ParticleContainer::m_specialForceLimit
private

The number of iterations after which the special upward force will no longer be applied, for membrane simulations.


The documentation for this class was generated from the following file: