83 void applySimpleForces(
const std::vector<std::shared_ptr<SimpleForceSource>>& simple_force_sources)
override;
95 void applyPairwiseForces(
const std::vector<std::shared_ptr<PairwiseForceSource>>& force_sources)
override;
105 void applyTargettedForces(
const std::vector<std::shared_ptr<TargettedForceSource>>& targetted_force_sources,
106 double curr_simulation_time)
override;
114 void reserve(
size_t n)
override;
121 size_t size()
const override;
136 std::vector<Particle>::iterator
begin()
override;
143 std::vector<Particle>::iterator
end()
override;
150 std::vector<Particle>::const_iterator
begin()
const override;
157 std::vector<Particle>::const_iterator
end()
const override;
163 [[nodiscard]]
const std::vector<Particle>&
getParticles()
const override;
190 const std::vector<Cell>&
getCells();
Class representing a cell in the linked cells algorithm.
Extension of the ParticleContainer class using a linked cells data structure for improved performance...
void deleteHaloParticles()
Removes all particles in the halo cells from the particles vector. ATTENTION: A particle reference up...
std::vector< Cell * > right_halo_cell_references
References to the halo cells on the right (x = domain_num_cells[0])
void reserve(size_t n) override
Reserves space for n particles. This is useful if the number of particles is known in advance and pre...
std::vector< Cell * > bottom_boundary_cell_references
References to the boundary cells on the bottom (y = 0)
void applySimpleForces(const std::vector< std::shared_ptr< SimpleForceSource >> &simple_force_sources) override
Applies the given simple force sources to the particles.
const std::vector< Cell * > & getBoundaryCells() const
Returns the pointers of the boundary cells.
LinkedCellsContainer(const std::array< double, 3 > &domain_size, double cutoff_radius, const std::array< BoundaryCondition, 6 > &boundary_types={BoundaryCondition::OUTFLOW, BoundaryCondition::OUTFLOW, BoundaryCondition::OUTFLOW, BoundaryCondition::OUTFLOW, BoundaryCondition::OUTFLOW, BoundaryCondition::OUTFLOW}, int n=0)
Construct a new Linked Cells Particle Container object.
void applyTargettedForces(const std::vector< std::shared_ptr< TargettedForceSource >> &targetted_force_sources, double curr_simulation_time) override
Applies the given targetted force sources to the particles.
BoundarySide
Boundary side enum for labeling the sides of the domain.
std::vector< Cell * > top_boundary_cell_references
References to the boundary cells on the top (y = domain_num_cells[1]-1)
void updateCellsParticleReferences()
Updates the particle references in the cells. This is necessary after a reallocation of the internal ...
std::vector< Cell * > domain_cell_references
References to the domain cells.
std::vector< std::vector< Cell * > > iteration_orders
void addParticle(const Particle &p) override
Adds a particle to the container.
std::vector< Cell * > boundary_cell_references
References to the boundary cells.
std::vector< Cell * > front_halo_cell_references
References to the halo cells on the front (z = domain_num_cells[2])
void initIterationOrders()
Sets the iteration orders for parallel execution.
std::vector< Cell * > bottom_halo_cell_references
References to the halo cells on the bottom (y = -1)
std::array< double, 3 > cell_size
Cell size in each dimension.
std::vector< Particle >::iterator begin() override
The begin iterator for the internal data structure.
std::array< double, 3 > domain_size
Domain size in each dimension.
std::vector< Particle >::iterator end() override
The end iterator for the internal data structure.
int cellCoordToCellIndex(int cx, int cy, int cz) const
Maps the cell coordinates to the corresponding index in the internal cell vector.
Cell * particlePosToCell(const std::array< double, 3 > &pos)
Maps the particle position to the corresponding cell index in the internal cell vector.
std::vector< Cell * > left_halo_cell_references
References to the halo cells on the left (x = -1)
Particle & operator[](int i) override
Overload of the [] operator to access the particles in the container.
const std::vector< Particle > & getParticles() const override
Returns a vector of all particles in the container.
std::array< int, 3 > domain_num_cells
Number of cells in each dimension.
std::vector< Cell > cells
Internal data structure for the cells.
const std::array< double, 3 > & getCellSize() const
Returns the cell size.
double getCutoffRadius() const
Returns the cutoff radius.
void initCells()
Populates the cell vector and sets the cells types.
void prepareForceCalculation() override
Prepares everything for the force calculations (must be called before applySimpleForces and applyPair...
const std::vector< Cell > & getCells()
Returns the cells.
void initCellNeighbourReferences()
Sets the neighbour references for each cell in the cell vector.
std::vector< Cell * > right_boundary_cell_references
References to the boundary cells on the right (x = domain_num_cells[0]-1)
std::vector< Cell * > halo_cell_references
References to the halo cells.
const std::array< double, 3 > & getDomainSize() const
Returns the domain size.
BoundaryCondition
Boundary type enum for labeling the sides of the domain.
std::vector< Cell * > top_halo_cell_references
References to the halo cells on the top (y = domain_num_cells[1])
std::vector< Cell * > left_boundary_cell_references
References to the boundary cells on the left (x = 0)
std::vector< Cell * > back_halo_cell_references
References to the halo cells on the back (z = -1)
std::vector< Cell * > back_boundary_cell_references
References to the boundary cells on the back (z = 0)
size_t size() const override
Returns the number of particles in the container.
static std::string boundaryConditionToString(const BoundaryCondition &bc)
Returns a string description of a boundary condition.
double cutoff_radius
Cutoff radius for the force calculation.
void applyPairwiseForces(const std::vector< std::shared_ptr< PairwiseForceSource >> &force_sources) override
Applies the given force sources to the particles.
std::vector< Cell * > front_boundary_cell_references
References to the boundary cells on the front (z = domain_num_cells[2]-1)
std::array< BoundaryCondition, 6 > boundary_types
The boundary types for each side of the domain (order in array: left, right, bottom,...
std::vector< Particle > particles
Internal data structure for the particles.
const std::array< int, 3 > & getDomainNumCells() const
Returns the number of cells in each dimension.
Interface for particle containers.
Class to represent a particle.