Molecular Dynamics Simulation  1.0
ReflectiveBoundaryType.cpp
Go to the documentation of this file.
2 
3 #include "io/logger/Logger.h"
5 #include "utils/ArrayUtils.h"
6 
8 
9 };
10 
13  for (Cell* cell : container.left_boundary_cell_references) {
14  for (Particle* p : cell->getParticleReferences()) {
15  if (p->isLocked()) continue;
16  double distance = p->getX()[0];
18  }
19  }
20  }
21 
23  for (Cell* cell : container.right_boundary_cell_references) {
24  for (Particle* p : cell->getParticleReferences()) {
25  if (p->isLocked()) continue;
26  double distance = container.domain_size[0] - p->getX()[0];
28  }
29  }
30  }
31 
33  for (Cell* cell : container.bottom_boundary_cell_references) {
34  for (Particle* p : cell->getParticleReferences()) {
35  if (p->isLocked()) continue;
36  double distance = p->getX()[1];
38  }
39  }
40  }
41 
43  for (Cell* cell : container.top_boundary_cell_references) {
44  for (Particle* p : cell->getParticleReferences()) {
45  if (p->isLocked()) continue;
46  double distance = container.domain_size[1] - p->getX()[1];
48  }
49  }
50  }
51 
53  for (Cell* cell : container.back_boundary_cell_references) {
54  for (Particle* p : cell->getParticleReferences()) {
55  if (p->isLocked()) continue;
56  double distance = p->getX()[2];
58  }
59  }
60  }
61 
63  for (Cell* cell : container.front_boundary_cell_references) {
64  for (Particle* p : cell->getParticleReferences()) {
65  if (p->isLocked()) continue;
66  double distance = container.domain_size[2] - p->getX()[2];
68  }
69  }
70  }
71 }
72 
73 std::array<double, 3> ReflectiveBoundaryType::calculateReflectiveBoundaryForce(Particle& p, double distance,
76 
77  if (2 * distance >= std::pow(2, 1.0 / 6) * p.getSigma()) {
78  return {0, 0, 0};
79  }
80 
81  Particle ghost_particle = Particle(p);
82  ghost_particle.setX(p.getX() - std::array<double, 3>{2 * distance, 0, 0});
83 
84  auto force_vector_left_side = force.calculateForce(p, ghost_particle);
85 
86  switch (side) {
88  return force_vector_left_side;
90  return {-force_vector_left_side[0], 0, 0};
92  return {0, force_vector_left_side[0], 0};
94  return {0, -force_vector_left_side[0], 0};
96  return {0, 0, force_vector_left_side[0]};
98  return {0, 0, -force_vector_left_side[0]};
99  }
100 
101  Logger::logger->error("Faulty reflective boundary condition");
102  return {0, 0, 0};
103 }
Class representing a cell in the linked cells algorithm.
Definition: Cell.h:12
std::vector< Particle * > & getParticleReferences()
Get the reference vector for the particles the cell contains.
Definition: Cell.cpp:7
Class to calculate the Lennard-Jones force between particles. Implements the interface PairwiseForceS...
std::array< double, 3UL > calculateForce(const Particle &p, const Particle &q) const override
Calculates the Lennard-Jones forces between two particles.
Extension of the ParticleContainer class using a linked cells data structure for improved performance...
std::vector< Cell * > bottom_boundary_cell_references
References to the boundary cells on the bottom (y = 0)
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)
std::array< double, 3 > domain_size
Domain size in each dimension.
std::vector< Cell * > right_boundary_cell_references
References to the boundary cells on the right (x = domain_num_cells[0]-1)
std::vector< Cell * > left_boundary_cell_references
References to the boundary cells on the left (x = 0)
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,...
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35
Class to represent a particle.
Definition: Particle.h:26
double getSigma() const
Gets the Lennard-Jones potential parameter sigma.
Definition: Particle.h:192
const std::array< double, 3 > & getX() const
Gets the position of the particle.
Definition: Particle.h:157
void setX(const std::array< double, 3 > &x)
Sets the position of the particle.
Definition: Particle.h:109
static void applyBoundaryConditions(LinkedCellsContainer &container)
Applies the boundary conditions for the reflective boundary condition.
static void pre(LinkedCellsContainer &container)
Applies the preconditioning step for the reflective boundary condition.
static std::array< double, 3 > calculateReflectiveBoundaryForce(Particle &p, double distance, LinkedCellsContainer::BoundarySide side)
Calculates the force of the reflective boundary for the given particle.