Molecular Dynamics Simulation  1.0
Static Public Member Functions | Static Private Member Functions | List of all members
ReflectiveBoundaryType Class Reference

#include <ReflectiveBoundaryType.h>

Collaboration diagram for ReflectiveBoundaryType:
Collaboration graph

Static Public Member Functions

static void pre (LinkedCellsContainer &container)
 Applies the preconditioning step for the reflective boundary condition. More...
 
static void applyBoundaryConditions (LinkedCellsContainer &container)
 Applies the boundary conditions for the reflective boundary condition. More...
 

Static Private Member Functions

static std::array< double, 3 > calculateReflectiveBoundaryForce (Particle &p, double distance, LinkedCellsContainer::BoundarySide side)
 Calculates the force of the reflective boundary for the given particle. More...
 

Detailed Description

Definition at line 7 of file ReflectiveBoundaryType.h.

Member Function Documentation

◆ applyBoundaryConditions()

void ReflectiveBoundaryType::applyBoundaryConditions ( LinkedCellsContainer container)
static

Applies the boundary conditions for the reflective boundary condition.

Parameters
containerThe container to apply the boundary conditions to.

This method adds the force of the reflective boundary to all particles that are in halo cells with the reflective boundary condition.

Definition at line 11 of file ReflectiveBoundaryType.cpp.

11  {
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 }
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
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)
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,...
Class to represent a particle.
Definition: Particle.h:26
static std::array< double, 3 > calculateReflectiveBoundaryForce(Particle &p, double distance, LinkedCellsContainer::BoundarySide side)
Calculates the force of the reflective boundary for the given particle.

◆ calculateReflectiveBoundaryForce()

std::array< double, 3 > ReflectiveBoundaryType::calculateReflectiveBoundaryForce ( Particle p,
double  distance,
LinkedCellsContainer::BoundarySide  side 
)
staticprivate

Calculates the force of the reflective boundary for the given particle.

Parameters
pThe particle to calculate the force for.
distanceThe distance of the particle to the boundary.
sideThe side of the boundary.
Returns
The force of the reflective boundary for the given particle.

Definition at line 73 of file ReflectiveBoundaryType.cpp.

74  {
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 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.
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35
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

◆ pre()

void ReflectiveBoundaryType::pre ( LinkedCellsContainer container)
static

Applies the preconditioning step for the reflective boundary condition.

Parameters
containerThe container to apply the boundary conditions to.

This method is empty, as the reflective boundary condition does not require any special treatment.

Definition at line 7 of file ReflectiveBoundaryType.cpp.

7  {
8 
9 };

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