ls1-MarDyn
ls1-MarDyn molecular dynamics code
|
Linked Cell Data Structure. More...
#include <LinkedCells.h>
Public Member Functions | |
LinkedCells (double bBoxMin[3], double bBoxMax[3], double cutoffRadius) | |
initialize the Linked Cell datastructure More... | |
LinkedCells () | |
Default constructor. | |
~LinkedCells () | |
Destructor. | |
void | readXML (XMLfileUnits &xmlconfig) override |
Read in XML configuration for LinkedCells and all its included objects. More... | |
int | getHaloWidthNumCells () override |
bool | rebuild (double bBoxMin[3], double bBoxMax[3]) override |
rebuild the datastructure More... | |
void | update () override |
void | update_via_copies () |
void | update_via_coloring () |
void | update_via_traversal () |
void | update_via_sliced_traversal () |
bool | addParticle (Molecule &particle, bool inBoxCheckedAlready=false, bool checkWhetherDuplicate=false, const bool &rebuildCaches=false) override |
add a single Molecule to the ParticleContainer. More... | |
void | addParticles (std::vector< Molecule > &particles, bool checkWhetherDuplicate=false) override |
adds a whole vector of particles More... | |
void | traverseCells (CellProcessor &cellProcessor) override |
calculate the forces between the molecules. More... | |
void | traverseNonInnermostCells (CellProcessor &cellProcessor) override |
void | traversePartialInnermostCells (CellProcessor &cellProcessor, unsigned int stage, int stageCount) override |
unsigned long | getNumberOfParticles () override |
void | clear () override |
Delete all molecules in container. More... | |
void | deleteOuterParticles () override |
delete all Particles which are not within the bounding box More... | |
double | get_halo_L (int index) const override |
gets the width of the halo region in dimension index More... | |
double | getCutoff () const override |
void | setCutoff (double rc) override |
void | deleteMolecule (ParticleIterator &moleculeIter, const bool &rebuildCaches) override |
double | getEnergy (ParticlePairsHandler *particlePairsHandler, Molecule *m1, CellProcessor &cellProcessor) override |
int * | getBoxWidthInNumCells () |
double * | getCellLength () override |
std::variant< ParticleIterator, SingleCellIterator< ParticleCell > > | getMoleculeAtPosition (const double pos[3]) override |
Gets a molecule by its position. More... | |
unsigned long int | getCellIndexOfMolecule (Molecule *molecule) const |
Get the index in the cell vector to which this Molecule belongs. More... | |
unsigned long int | getCellIndexOfPoint (const double point[3]) const |
Get the index in the cell vector to which the point belongs. More... | |
ParticleCell & | getCellReference (int idx) |
virtual void | updateInnerMoleculeCaches () override |
Update the caches of the molecules, that lie in inner cells. The caches of boundary and halo cells is not updated. This method is used for a multi-step scheme of overlapping mpi communication. More... | |
virtual void | updateBoundaryAndHaloMoleculeCaches () override |
Update the caches of the molecules, that lie in the boundary or halo cells. The caches of boundary and halo cells is updated, the caches of the inner cells are not updated. This method is used for a multi-step scheme of overlapping mpi communication. More... | |
virtual void | updateMoleculeCaches () override |
Update the caches of the molecules. More... | |
ParticleIterator | iterator (ParticleIterator::Type t) override |
RegionParticleIterator | regionIterator (const double startRegion[3], const double endRegion[3], ParticleIterator::Type type) override |
size_t | getTotalSize () override |
void | printSubInfo (int offset) override |
std::string | getName () override |
bool | requiresForceExchange () const override |
unsigned long | initCubicGrid (std::array< unsigned long, 3 > numMoleculesPerDimension, std::array< double, 3 > simBoxLength, size_t seed_offset) override |
std::vector< unsigned long > | getParticleCellStatistics () override |
std::string | getConfigurationAsString () override |
![]() | |
ParticleContainer (double bBoxMin[3], double bBoxMax[3]) | |
The constructor. More... | |
ParticleContainer () | |
Default constructor. | |
virtual | ~ParticleContainer () |
The destructor. | |
virtual bool | addHaloParticle (Molecule &particle, bool inBoxCheckedAlready=false, bool checkWhetherDuplicate=false, const bool &rebuildCaches=false) |
add a single Molecule to the ParticleContainer, ensures that it is added in the halo. More... | |
virtual double | getBoundingBoxMin (int dimension) const |
returns one coordinate of the lower corner of the bounding box More... | |
virtual bool | isInBoundingBox (double r[3]) const |
checks, whether given coordinates are within the bounding box More... | |
virtual double | getBoundingBoxMax (int dimension) const |
returns one coordinate of the higher corner of the bounding box More... | |
virtual double | getSkin () const |
virtual double * | getHaloSize () |
virtual std::vector< Molecule > | getInvalidParticles () |
virtual bool | isInvalidParticleReturner () |
Friends | |
class | LinkedCellsTest |
class | VTKGridWriter |
Additional Inherited Members | |
![]() | |
double | _boundingBoxMin [3] |
coordinates of the left, lower, front corner of the bounding box | |
double | _boundingBoxMax [3] |
coordinates of the right, upper, back corner of the bounding box | |
Linked Cell Data Structure.
Without any specialized data structure, it needs O(N*N) - where N is the number of particles - time to find all neighbouring pairs of particles. The linked cell data structure is a datastructure which allows to find all neighbouring pairs of particles (neighbouring means particles pairs which have less than a certain distance) in O(N) time. The following picture shows a domain with some particles in it. The blue circle shows the neighbouring area of the red particle The problem is that all particles have to be examined to find those within the circle With the linked cell data structure, the domain is divided into cells (using a regular grid). All particles are placed in those cells. For a given cell, neighbouring cells can easily be calculated, so for a given particle, only the particles from neighbouring cells have to be examined. The following picture illustrates this The spacial domain covered by the linked cells is larger than the bounding box of the domain. This halo region surrounding the phasespace is used for (periodic) boundary conditions and has to be at least as wide as the cutoff radius.
In total, there are three different cell types:
LinkedCells::LinkedCells | ( | double | bBoxMin[3], |
double | bBoxMax[3], | ||
double | cutoffRadius | ||
) |
initialize the Linked Cell datastructure
The constructor sets the following variables:
It resized the cell vector and marks the cells as inner/halo
It fills the array innerCellIndices
It fills the array with forward and backward neighbour indices
The corner parameters for the constructor describe the bounding box of the phasespace which belongs directly to this process, so they correspond to a bounding box including inner + boundary cells but excluding halo cells.
But the corners of this class have to include the halo cells.
bBoxMin | lower corner of the bounding box of the domain belonging to this container |
bBoxMax | higher corner of the bounding box of the domain belonging to this container |
cutoffRadius | distance for which forces have to be calculated |
LJCutoffRadius | distance for which lennard jones forces have to be calculated |
cellsInCutoffRadius | describes the width of cells relative to the cutoffRadius: equal (or larger) to the cutoffRadius divided by the length of a cell as for the number of cells in each dimension only natural numbers are allowed, it can happen that it is not possible to set celllength = cutoffRadius / cellsInCutoffRadius. In that case, the celllength is chosen to be the next larger value so that the sum of the cell lengths in one dimension equals the length of the phasespace Example: phasespacelength=100, cellsInCutoffRadius=2, CutoffRadius=3 ==> celllength should be: cutoffRadius/cellsInCutoffRadius = 3/2 = 1.5 ==> cellsPerDimension = phasespacelength/celllength = 100/1.5 = 66.67 cells ==> cells have to be larger: cellsPerDimension = phasespacelength/celllength = 100/celllength = 66 cells ==> celllength = 100/66 = 1.5152 |
|
overridevirtual |
add a single Molecule to the ParticleContainer.
Note: a copy of the particle is pushed. Destroying the argument is responsibility of the programmer.
particle | reference to the particle which has to be added |
inBoxCheckedAlready | - if true, spare check whether molecule is in bounding box |
checkWhetherDuplicate | - if true, check whether molecule already exists and don't insert it. |
rebuildCaches | specifies, whether the caches should be rebuild |
Implements ParticleContainer.
|
overridevirtual |
adds a whole vector of particles
particles | reference to a vector of pointers to particles |
Implements ParticleContainer.
|
overridevirtual |
Delete all molecules in container.
Implements ParticleContainer.
|
overridevirtual |
Implements ParticleContainer.
|
overridevirtual |
delete all Particles which are not within the bounding box
Implements ParticleContainer.
|
overridevirtual |
gets the width of the halo region in dimension index
Implements ParticleContainer.
unsigned long int LinkedCells::getCellIndexOfMolecule | ( | Molecule * | molecule | ) | const |
Get the index in the cell vector to which this Molecule belongs.
each spatial position within the bounding box of the linked cells belongs unambiguously to one cell.
This method determines for a given Molecule the corresponding cell and returns the index of that cell in the cell vector.
If the molecule is not inside the bounding box, an error is printed
unsigned long int LinkedCells::getCellIndexOfPoint | ( | const double | point[3] | ) | const |
Get the index in the cell vector to which the point belongs.
each spatial position within the bounding box of the linked cells belongs unambiguously to one cell.
This method determines for a given point the corresponding cell and returns the index of that cell in the cell vector.
If the point is not inside the bounding box, an error is printed
|
inlineoverridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Return a string representation of the algorithmic configuration of the container. Only used for logging / output.
Implements ParticleContainer.
|
inlineoverridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Implements ParticleContainer.
|
inlineoverridevirtual |
Reimplemented from ParticleContainer.
|
overridevirtual |
Gets a molecule by its position.
pos | Molecule position |
result | Molecule will be returned by this pointer if found |
Implements ParticleContainer.
|
overridevirtual |
Implements MemoryProfilable.
|
overridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Get a statistics of the cells found in this container.
Reimplemented from ParticleContainer.
|
overridevirtual |
Implements MemoryProfilable.
|
overridevirtual |
Implements ParticleContainer.
|
inlineoverridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Implements MemoryProfilable.
|
overridevirtual |
Read in XML configuration for LinkedCells and all its included objects.
The following xml object structure is handled by this method:
Implements ParticleContainer.
|
overridevirtual |
rebuild the datastructure
Load-balancing decompositions change the position and size of the local region during runtime. Therefore, the datastructure needs to be rebuild completely. This method basically does what the constructor does as well, with the difference, that there are already particles stored, and particles which don't belong to the new region have to be deleted after rebuild @parameter bBoxMin minimum of the box @parameter bBoxMax maximum of the box
Reimplemented from ParticleContainer.
|
overridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Reimplemented from ParticleContainer.
|
inlineoverridevirtual |
|
overridevirtual |
calculate the forces between the molecules.
Only molecules with a distance not larger than the cutoff radius are to be used.
Only forces on the Molecules which are in the inner and boundary region have to be calculated Newton's third law should be used for faster computation:
particlePairsHandler | specified concrete action to be done for each pair |
Implements ParticleContainer.
|
overridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Implements ParticleContainer.
|
overridevirtual |
Pointers to the particles are put into cells depending on the spacial position of the particles. Before the call of this method, this distribution might have become invalid. To ensure, that all Particles (pointers to them) are put into the corresponding cells, first all cells are cleared and then filled again depending on the spacial position of the molecules. After the update, exactly one pointer for each particle in this ParticleContainer is it's corresponding cell.
Implements ParticleContainer.
|
overridevirtual |
Update the caches of the molecules, that lie in the boundary or halo cells. The caches of boundary and halo cells is updated, the caches of the inner cells are not updated. This method is used for a multi-step scheme of overlapping mpi communication.
Implements ParticleContainer.
|
overridevirtual |
Update the caches of the molecules, that lie in inner cells. The caches of boundary and halo cells is not updated. This method is used for a multi-step scheme of overlapping mpi communication.
Implements ParticleContainer.
|
overridevirtual |
Update the caches of the molecules.
Implements ParticleContainer.