9 if (container.
boundary_types[0] == LinkedCellsContainer::LinkedCellsContainer::BoundaryCondition::PERIODIC) {
12 p->setX(p->getX() + std::array<double, 3>{container.domain_size[0], 0, 0});
17 if (container.
boundary_types[1] == LinkedCellsContainer::LinkedCellsContainer::BoundaryCondition::PERIODIC) {
20 p->setX(p->getX() + std::array<double, 3>{-container.domain_size[0], 0, 0});
25 if (container.
boundary_types[2] == LinkedCellsContainer::LinkedCellsContainer::BoundaryCondition::PERIODIC) {
28 p->setX(p->getX() + std::array<double, 3>{0, container.domain_size[1], 0});
33 if (container.
boundary_types[3] == LinkedCellsContainer::LinkedCellsContainer::BoundaryCondition::PERIODIC) {
36 p->setX(p->getX() + std::array<double, 3>{0, -container.domain_size[1], 0});
41 if (container.
boundary_types[4] == LinkedCellsContainer::LinkedCellsContainer::BoundaryCondition::PERIODIC) {
44 p->setX(p->getX() + std::array<double, 3>{0, 0, container.domain_size[2]});
49 if (container.
boundary_types[5] == LinkedCellsContainer::LinkedCellsContainer::BoundaryCondition::PERIODIC) {
52 p->setX(p->getX() + std::array<double, 3>{0, 0, -container.domain_size[2]});
60 size_t original_size = container.
particles.size();
196 return original_size;
200 const std::array<double, 3>& offset) {
201 for (
Cell* cell : side_cell_references) {
202 for (
Particle* p : cell->getParticleReferences()) {
205 ghost_particle.
setX(p->getX() + offset);
212 const std::array<double, 3>& offset) {
213 std::array<int, 3> running_array{0, 0, 0};
223 ghost_particle.
setX(p->getX() + offset);
226 running_array[free_dimension] += 1;
231 std::array<int, 3> cell_coords{0, 0, 0};
237 for (
Particle* p : cell->getParticleReferences()) {
240 ghost_particle.
setX(p->getX() + offset);
Class representing a cell in the linked cells algorithm.
std::vector< Particle * > & getParticleReferences()
Get the reference vector for the particles the cell contains.
Extension of the ParticleContainer class using a linked cells data structure for improved performance...
std::vector< Cell * > right_halo_cell_references
References to the halo cells on the right (x = domain_num_cells[0])
std::vector< Cell * > bottom_boundary_cell_references
References to the boundary cells on the bottom (y = 0)
std::vector< Cell * > top_boundary_cell_references
References to the boundary cells on the top (y = domain_num_cells[1]-1)
void addParticle(const Particle &p) override
Adds a particle to the container.
std::vector< Cell * > front_halo_cell_references
References to the halo cells on the front (z = domain_num_cells[2])
std::vector< Cell * > bottom_halo_cell_references
References to the halo cells on the bottom (y = -1)
std::array< double, 3 > domain_size
Domain size in each dimension.
int cellCoordToCellIndex(int cx, int cy, int cz) const
Maps the cell coordinates to the corresponding index in the internal cell vector.
std::vector< Cell * > left_halo_cell_references
References to the halo cells on the left (x = -1)
std::array< int, 3 > domain_num_cells
Number of cells in each dimension.
std::vector< Cell > cells
Internal data structure for the cells.
std::vector< Cell * > right_boundary_cell_references
References to the boundary cells on the right (x = domain_num_cells[0]-1)
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)
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.
Class to represent a particle.
void setX(const std::array< double, 3 > &x)
Sets the position of the particle.
void setLocked(LockState new_lock_state)
Set wheter the particle is locked in space.
static size_t applyBoundaryConditions(LinkedCellsContainer &container)
Applies the boundary conditions for the periodic boundary condition.
static void addPeriodicHaloParticlesForSide(LinkedCellsContainer &container, const std::vector< Cell * > &side_cell_references, const std::array< double, 3 > &offset)
Adds the periodic halo particles for the given side of the container to the other side of the contain...
static void pre(LinkedCellsContainer &container)
Applies the preconditioning step for the periodic boundary condition.
static void addPeriodicHaloParticlesForEdge(LinkedCellsContainer &container, int free_dimension, const std::array< double, 3 > &offset)
Adds the periodic halo particles for the given edge of the container to the diagonally opposite edge ...
static void addPeriodicHaloParticlesForCorner(LinkedCellsContainer &container, const std::array< double, 3 > &offset)
Adds the periodic halo particles for the given corner of the container to the diagonally opposite cor...