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

Class for storing data of a single Cell in a domain split into cells. More...

#include <Cell.h>

Public Member Functions

 Cell (const std::array< double, 3 > &size, const std::array< double, 3 > &position, CellType type, int index, const std::vector< HaloLocation > &haloLocation, const std::vector< BorderLocation > &borderLocation)
 Constructs a new Cell object.
 
ContainerType::iterator begin ()
 Gets an iterator to the beginning of the Particle* forward list.
 
ContainerType::iterator end ()
 Gets an iterator to one past the end of the Particle* forward list.
 
std::array< double, 3 > getRelativePosition (const Particle &p) const
 Calculates the relative position of a particle within the current cell.
 
void validatePosition (const std::array< double, 3 > &relPos) const
 Validates if the provided relative position is within the bounds of the current cell (debug).
 
bool isCorner (HaloLocation loc1, HaloLocation loc2) const
 Checks if two HaloLocation values correspond to a corner.
 
HaloLocation handle2DCorner (const std::array< double, 3 > &relPos) const
 Handles the logic for 2D corner cell handling.
 
HaloLocation handle3DCorner (const std::array< double, 3 > &relPos) const
 Handles the logic for 3D corner cell handling.
 
HaloLocation handle3DDiagonal (const std::array< double, 3 > &relPos) const
 Handles the logic for determining the 3D diagonal region.
 
HaloLocation handle3DTripleCorner (const std::array< double, 3 > &relPos) const
 Handles the logic for determining the 3D triple corner region.
 
void addParticle (Particle &particle)
 Adds a Particle reference to the front of the forward list.
 
void removeParticle (Particle &particle)
 Removes a Particle reference from the forward list.
 
HaloLocation getCornerRegion (const Particle &p) const
 Dispatch function to handle a corner cell.
 
const std::array< double, 3 > & getX () const
 Gets a const reference to the position array of this Cell.
 
const std::array< double, 3 > & getSize () const
 Gets a const reference to the size array of this Cell.
 
const std::vector< HaloLocation > & getHaloLocation () const
 Gets a const reference to the halo location (cardinal direction) vector of this Cell.
 
const std::vector< BorderLocation > & getBorderLocation () const
 Gets a const reference to the border location (cardinal direction) vector of this Cell.
 
std::vector< int > & getNeighbors ()
 Gets a reference to the Cell's neighbors.
 
const std::vector< int > & getNeighbors () const
 Gets a const reference to the Cell's neighbors.
 
std::forward_list< std::reference_wrapper< Particle > > & getParticles ()
 Gets a reference to the Cell's Particle pointer forward list.
 
const std::forward_list< std::reference_wrapper< Particle > > & getParticles () const
 Gets a const reference to the Cell's Particle pointer forward list.
 
CellType getType () const
 Gets the type of this Cell.
 
int getIndex () const
 Gets the index of this Cell in its CellContainer.
 
std::string toString () const
 Gets a string representation of this Cell.
 

Private Types

using ContainerType = std::forward_list< std::reference_wrapper< Particle > >
 Typedef for the container type used to store pointers to a Cell's Particle objects.
 

Private Attributes

ContainerType m_particles {}
 A forward list of pointers to Particle objects contained within the current Cell.
 
std::array< double, 3 > m_size
 The size of the Cell in each dimension.
 
std::array< double, 3 > m_position
 The lower-left coordinates of the Cell.
 
std::vector< HaloLocationm_haloLocation
 If this is a halo cell, the locations of this cell (North, South, West, East, Above, Below) are stored here.
 
std::vector< BorderLocationm_borderLocation
 If this is a border cell, the locations of this cell (North, South, West, East, Above, Below) are stored here.
 
std::vector< int > m_neighbors
 The neighboring Cell indices.
 
CellType m_type
 The type of this Cell. May be INNER, BORDER or HALO.
 
int m_index
 The index of this Cell in the overarching CellContainer.
 

Detailed Description

Class for storing data of a single Cell in a domain split into cells.

Member Typedef Documentation

◆ ContainerType

using Cell::ContainerType = std::forward_list<std::reference_wrapper<Particle> >
private

Typedef for the container type used to store pointers to a Cell's Particle objects.

Constructor & Destructor Documentation

◆ Cell()

Cell::Cell ( const std::array< double, 3 > &  size,
const std::array< double, 3 > &  position,
CellType  type,
int  index,
const std::vector< HaloLocation > &  haloLocation,
const std::vector< BorderLocation > &  borderLocation 
)

Constructs a new Cell object.

Typically called from a CellContainer.

Parameters
sizeThe size of the Cell in each dimension.
positionThe lower-left coordinates of the Cell.
typeThe type of this Cell.
indexThe index of this Cell in the CellContainer.
haloLocationThe cardinal direction(s) of this cell if this is a halo Cell.
borderLocationThe cardinal direction(s) of this cell if this is a border Cell.

Member Function Documentation

◆ addParticle()

void Cell::addParticle ( Particle particle)

Adds a Particle reference to the front of the forward list.

Parameters
particleThe Particle reference to be added.

◆ begin()

ContainerType::iterator Cell::begin ( )

Gets an iterator to the beginning of the Particle* forward list.

Returns
An iterator to the beginning of the Cell's forward list.

◆ end()

ContainerType::iterator Cell::end ( )

Gets an iterator to one past the end of the Particle* forward list.

Returns
An iterator to one past the end of the Cell's forward list.

◆ getBorderLocation()

const std::vector< BorderLocation > & Cell::getBorderLocation ( ) const

Gets a const reference to the border location (cardinal direction) vector of this Cell.

Returns
A const reference to the border location vector of this Cell.

◆ getCornerRegion()

HaloLocation Cell::getCornerRegion ( const Particle p) const

Dispatch function to handle a corner cell.

This function calls the above corner cell routines to determine which boundary conditon should be applied based on the Particle's position inside the corner cell, if it even is inside a corner cell.

Parameters
pThe Particle to analyze.
Returns
The singular cardinal direction of the Halo Cell based on the Particle's position.

◆ getHaloLocation()

const std::vector< HaloLocation > & Cell::getHaloLocation ( ) const

Gets a const reference to the halo location (cardinal direction) vector of this Cell.

Returns
A const reference to the halo location vector of this Cell.

◆ getIndex()

int Cell::getIndex ( ) const

Gets the index of this Cell in its CellContainer.

Returns
The index of this Cell in its CellContainer.

◆ getNeighbors() [1/2]

std::vector< int > & Cell::getNeighbors ( )

Gets a reference to the Cell's neighbors.

Returns
A const reference to the Cell's neighbors.

◆ getNeighbors() [2/2]

const std::vector< int > & Cell::getNeighbors ( ) const

Gets a const reference to the Cell's neighbors.

Returns
A const reference to the Cell's neighbors.

◆ getParticles() [1/2]

std::forward_list< std::reference_wrapper< Particle > > & Cell::getParticles ( )

Gets a reference to the Cell's Particle pointer forward list.

Returns
A reference to the Cell's Particle pointer forward list.

◆ getParticles() [2/2]

const std::forward_list< std::reference_wrapper< Particle > > & Cell::getParticles ( ) const

Gets a const reference to the Cell's Particle pointer forward list.

Returns
A const reference to the Cell's Particle pointer forward list.

◆ getRelativePosition()

std::array< double, 3 > Cell::getRelativePosition ( const Particle p) const

Calculates the relative position of a particle within the current cell.

Parameters
pThe particle whose relative position is to be calculated.
Returns
An array representing the relative position of the particle within the cell.

◆ getSize()

const std::array< double, 3 > & Cell::getSize ( ) const

Gets a const reference to the size array of this Cell.

Returns
A const reference to the size array of this Cell.

◆ getType()

CellType Cell::getType ( ) const

Gets the type of this Cell.

Returns
The type of this Cell.

◆ getX()

const std::array< double, 3 > & Cell::getX ( ) const

Gets a const reference to the position array of this Cell.

Returns
A const reference to the position array of this Cell.

◆ handle2DCorner()

HaloLocation Cell::handle2DCorner ( const std::array< double, 3 > &  relPos) const

Handles the logic for 2D corner cell handling.

This function handles the determination of the corner region in a 2D context based on the relative position within the cell. It returns the appropriate HaloLocation (NORTH, SOUTH, EAST, or WEST) based on the position.

See the report for Worksheet 3 for more info.

Parameters
relPosThe relative position of the particle in 2D within the cell, represented as a 3D array.
Returns
The appropriate HaloLocation for the 2D corner (e.g., NORTH, SOUTH, EAST, WEST).

◆ handle3DCorner()

HaloLocation Cell::handle3DCorner ( const std::array< double, 3 > &  relPos) const

Handles the logic for 3D corner cell handling.

This function handles the determination of the corner region in a 3D context based on the relative position within the cell. It returns the appropriate HaloLocation based on the position in the 3D corner regions.

See the report for Worksheet 5 for a detailed explanation.

Parameters
relPosThe relative position of the particle in 3D within the cell, represented as a 3D array.
Returns
The appropriate HaloLocation for the 3D corner (e.g., NORTH, SOUTH, EAST, WEST, ABOVE, BELOW).

◆ handle3DDiagonal()

HaloLocation Cell::handle3DDiagonal ( const std::array< double, 3 > &  relPos) const

Handles the logic for determining the 3D diagonal region.

This function handles the determination of the diagonal region in a 3D context, where the relative position determines if the corner is on the diagonal. It returns the appropriate HaloLocation based on the diagonal logic.

See the report for Worksheet 5 for a detailed explanation.

Parameters
relPosThe relative position of the particle in 3D within the cell, represented as a 3D array.
Returns
The appropriate HaloLocation for the 3D diagonal region.

◆ handle3DTripleCorner()

HaloLocation Cell::handle3DTripleCorner ( const std::array< double, 3 > &  relPos) const

Handles the logic for determining the 3D triple corner region.

This function handles the 3D triple corner region case, where the relative position is used to determine the specific triple corner region in 3D (e.g. NORTH, WEST and ABOVE). It returns the appropriate HaloLocation for the triple corner.

See the report for Worksheet 5 for a detailed explanation.

Parameters
relPosThe relative position of the particle in 3D within the cell, represented as a 3D array.
Returns
The appropriate HaloLocation for the 3D triple corner region.

◆ isCorner()

bool Cell::isCorner ( HaloLocation  loc1,
HaloLocation  loc2 
) const

Checks if two HaloLocation values correspond to a corner.

This function determines if the two given HaloLocation values represent opposite corners of the cell.

Parameters
loc1The first HaloLocation to check.
loc2The second HaloLocation to check.
Returns
true if the two locations represent a corner.
false if the two locations do not represent a corner.

◆ removeParticle()

void Cell::removeParticle ( Particle particle)

Removes a Particle reference from the forward list.

Parameters
particleThe Particle reference to be removed.

◆ toString()

std::string Cell::toString ( ) const

Gets a string representation of this Cell.

Returns
A string representation of the Cell data.

◆ validatePosition()

void Cell::validatePosition ( const std::array< double, 3 > &  relPos) const

Validates if the provided relative position is within the bounds of the current cell (debug).

This function uses the assert macro. As such, it has no effect in Release builds.

Parameters
relPosThe relative position to be validated, represented as a 3D array of doubles.

Member Data Documentation

◆ m_borderLocation

std::vector<BorderLocation> Cell::m_borderLocation
private

If this is a border cell, the locations of this cell (North, South, West, East, Above, Below) are stored here.

◆ m_haloLocation

std::vector<HaloLocation> Cell::m_haloLocation
private

If this is a halo cell, the locations of this cell (North, South, West, East, Above, Below) are stored here.

◆ m_index

int Cell::m_index
private

The index of this Cell in the overarching CellContainer.

◆ m_neighbors

std::vector<int> Cell::m_neighbors
private

The neighboring Cell indices.

◆ m_particles

ContainerType Cell::m_particles {}
private

A forward list of pointers to Particle objects contained within the current Cell.

◆ m_position

std::array<double, 3> Cell::m_position
private

The lower-left coordinates of the Cell.

◆ m_size

std::array<double, 3> Cell::m_size
private

The size of the Cell in each dimension.

◆ m_type

CellType Cell::m_type
private

The type of this Cell. May be INNER, BORDER or HALO.


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