Here we define a distributed vector in 3D, containing 3 properties, a scalar double, a vector double[3], and a tensor or rank 2 double[3][3]. In this case the vector contain 0 particles initially
We define a grid iterator, to create particles on a grid like way. An important note is that the grid iterator, iterate only on the local nodes for each processor for example suppose to have a domain like the one in figure
divided in 2 processors, the processor 1 will iterate only on the points inside the portion of space marked with one. A note grid iterator follow the boundary condition specified in vector. For a perdiodic 2D 5x5 grid we have
Because we are doing a calculation that involve neighborhood particle. if a particle is near the boundary it can require particle on other processors. Ghost_get retrieve such information from the other processor. Ghost get by default synchronize the information about particle position and no properties. If we want to synchronize also properties we have to specify which one. For example with <0,1,2> here we synchronize the scalar property (0), the vector (1), and the rank 2 tensor (2)
Warning
Every ghost_get by default reset the status of the ghost so the information are lost
Here we get a Cell-list structure. A Cell-list structure is a convenient way to get the neighborhood of each particle. For each particle we get the neighborhood particles around it. Once constructed we can get an iterator over the neighborhood of the particle p
In this code as demonstration we iterate over the particle.
See also
for each neighborhood particle of we calculate the distance. This distance is accumulated on the property 0. On the vector property (1) the distance vector is accumulated. While on the tensor the moment of inertia is calculated.
If the particle does not move, or does not move that much we can create a verlet list for each particle, it internally use CellList to find the neighborhood but create a Verlet list it is still an expensive operation. Consider also that this datastructure can grow quickly its size is given in byte by Np * NN_average * 8
Np number of particle
NN_average number of neighborhood in average
Before using it we strongly suggest to estimate the size of the data-structure
auto verlet = vd.getVerlet(r_cut);
auto it3 = vd.getDomainIterator();
// For each particle i verlet.size() == Number of particles
Cell-list can have different types. The dafault that we get from getCellList is called CELL_MEMFAST. Exist other two types of Cell-list called CELL_MEMBAL and CELL_MEMMw. They all expose the same interface and same functionality so from a user prospective there is no difference. Internally they use different memory layout and they can consume more or less memory at the cost of speed. The first called CELL_MEMFAST has memory complexity equivalent to \(N_{cells} * N_mco\) where \(N_{cells}\) is the number of cells and \(N_{mco}\) is the maximum number of particles in a cell it is the fastest in access but consume a lot of memory. The CELL_MEMBAL has memory complexity \(N_{cells} + N_{parts}\) it consume less memory it can (must be evaluated case by case) be slower because access require the resolution of pointer to pointer. CELL_MEMMW has memory complexity \(N_{parts}\) access the cell list requires the calculation of an hashing function. The peculiarity of this Cell-list is that does not depend from the number of cells. We suggest in anycase to use the default until memory is not a problem.
Note
CELL_MEMBAL and CELLMEMMW are macro that require two parameters one is the dimensionality of the space the other is the type of the space
// Get cell list
auto NN4 = vd.getCellList<CELL_MEMBAL(3,float)>(r_cut);
auto NN5 = vd.getCellList<CELL_MEMMW(3,float)>(r_cut);
Finalize
At the very end of the program we have always to de-initialize the library