16#include <forward_list>
20#define VEC_CONTAINS(vec, el) ((std::find((vec).begin(), (vec).end(), (el)) != (vec).end()))
25 using ContainerType = std::forward_list<std::reference_wrapper<Particle>>;
61 Cell(
const std::array<double, 3> &size,
const std::array<double, 3> &position,
CellType type,
int index,
62 const std::vector<HaloLocation> &haloLocation,
const std::vector<BorderLocation> &borderLocation);
70 ContainerType::iterator
begin();
77 ContainerType::iterator
end();
193 const std::array<double, 3> &
getX()
const;
242 const std::forward_list<std::reference_wrapper<Particle>> &
getParticles()
const;
Utility functions for Cell and CellContainer objects.
CellType
Enum containing the possible types of cells.
Definition CellUtils.h:20
HaloLocation
Enum containing the possible corner and edge directions of halo cells.
Definition CellUtils.h:22
Model of a single particle.
Class for storing data of a single Cell in a domain split into cells.
Definition Cell.h:23
int m_index
The index of this Cell in the overarching CellContainer.
Definition Cell.h:45
ContainerType::iterator begin()
Gets an iterator to the beginning of the Particle* forward list.
HaloLocation getCornerRegion(const Particle &p) const
Dispatch function to handle a corner 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).
const std::array< double, 3 > & getSize() const
Gets a const reference to the size array of this Cell.
const std::array< double, 3 > & getX() const
Gets a const reference to the position array of this Cell.
const std::vector< int > & getNeighbors() const
Gets a const reference to the Cell's neighbors.
CellType getType() const
Gets the type of this Cell.
std::forward_list< std::reference_wrapper< Particle > > & getParticles()
Gets a reference to the Cell's Particle pointer forward list.
std::forward_list< std::reference_wrapper< Particle > > ContainerType
Typedef for the container type used to store pointers to a Cell's Particle objects.
Definition Cell.h:25
std::array< double, 3 > m_position
The lower-left coordinates of the Cell.
Definition Cell.h:33
HaloLocation handle3DDiagonal(const std::array< double, 3 > &relPos) const
Handles the logic for determining the 3D diagonal region.
HaloLocation handle3DCorner(const std::array< double, 3 > &relPos) const
Handles the logic for 3D corner cell handling.
std::vector< HaloLocation > m_haloLocation
If this is a halo cell, the locations of this cell (North, South, West, East, Above,...
Definition Cell.h:36
CellType m_type
The type of this Cell. May be INNER, BORDER or HALO.
Definition Cell.h:43
std::vector< int > & getNeighbors()
Gets a reference to the Cell's neighbors.
int getIndex() const
Gets the index of this Cell in its CellContainer.
std::vector< BorderLocation > m_borderLocation
If this is a border cell, the locations of this cell (North, South, West, East, Above,...
Definition Cell.h:39
std::vector< int > m_neighbors
The neighboring Cell indices.
Definition Cell.h:41
HaloLocation handle2DCorner(const std::array< double, 3 > &relPos) const
Handles the logic for 2D corner cell handling.
ContainerType::iterator end()
Gets an iterator to one past the end of the Particle* forward list.
const std::vector< BorderLocation > & getBorderLocation() const
Gets a const reference to the border location (cardinal direction) vector of this Cell.
const std::forward_list< std::reference_wrapper< Particle > > & getParticles() const
Gets a const reference to the Cell's Particle pointer forward list.
void removeParticle(Particle &particle)
Removes a Particle reference from the forward list.
std::array< double, 3 > getRelativePosition(const Particle &p) const
Calculates the relative position of a particle within the current cell.
void addParticle(Particle &particle)
Adds a Particle reference to the front of the forward list.
bool isCorner(HaloLocation loc1, HaloLocation loc2) const
Checks if two HaloLocation values correspond to a corner.
std::string toString() const
Gets a string representation of this Cell.
const std::vector< HaloLocation > & getHaloLocation() const
Gets a const reference to the halo location (cardinal direction) vector of this Cell.
HaloLocation handle3DTripleCorner(const std::array< double, 3 > &relPos) const
Handles the logic for determining the 3D triple corner region.
std::array< double, 3 > m_size
The size of the Cell in each dimension.
Definition Cell.h:31
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 m_particles
A forward list of pointers to Particle objects contained within the current Cell.
Definition Cell.h:29
Particle class modeling a particle's position, velocity, force, mass and type.
Definition Particle.h:46
Enumeration class corresponding to the type schema type.
Definition vtk-unstructured.h:2125