Skip to content

Commit

Permalink
revert algo back to all 2 all search
Browse files Browse the repository at this point in the history
  • Loading branch information
goodchong committed Dec 24, 2024
1 parent 76d1336 commit d298d97
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions source/module_cell/module_neighbor/sltk_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs

this->box_edge_length = sradius + 0.1; // To avoid edge cases, the size of the box is slightly increased.

/* warning box algorithm
this->box_nx = std::ceil((this->x_max - this->x_min) / box_edge_length) + 1;
this->box_ny = std::ceil((this->y_max - this->y_min) / box_edge_length) + 1;
this->box_nz = std::ceil((this->z_max - this->z_min) / box_edge_length) + 1;
Expand All @@ -208,8 +209,21 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs
atoms_in_box[i][j].resize(this->box_nz);
}
}
*/
this->box_nx = glayerX + glayerX_minus;
this->box_ny = glayerY + glayerY_minus;
this->box_nz = glayerZ + glayerZ_minus;
ModuleBase::GlobalFunc::OUT(ofs_in, "BoxNumber", box_nx, box_ny, box_nz);


atoms_in_box.resize(this->box_nx);
for (int i = 0; i < this->box_nx; i++)
{
atoms_in_box[i].resize(this->box_ny);
for (int j = 0; j < this->box_ny; j++)
{
atoms_in_box[i][j].resize(this->box_nz);
}
}
for (int ix = -glayerX_minus; ix < glayerX; ix++)
{
for (int iy = -glayerY_minus; iy < glayerY; iy++)
Expand All @@ -225,7 +239,10 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs
double z = ucell.atoms[i].tau[j].z + vec1[2] * ix + vec2[2] * iy + vec3[2] * iz;
FAtom atom(x, y, z, i, j, ix, iy, iz);
int box_i_x, box_i_y, box_i_z;
this->getBox(box_i_x, box_i_y, box_i_z, x, y, z);
//this->getBox(box_i_x, box_i_y, box_i_z, x, y, z);
box_i_x = ix + glayerX_minus;
box_i_y = iy + glayerY_minus;
box_i_z = iz + glayerZ_minus;
this->atoms_in_box[box_i_x][box_i_y][box_i_z].push_back(atom);
}
}
Expand Down Expand Up @@ -269,12 +286,19 @@ void Grid::Construct_Adjacent_near_box(const FAtom& fatom)
int box_i_x, box_i_y, box_i_z;
this->getBox(box_i_x, box_i_y, box_i_z, fatom.x, fatom.y, fatom.z);

for (int box_i_x_adj = std::max(box_i_x - 1, 0); box_i_x_adj <= std::min(box_i_x + 1, box_nx - 1); box_i_x_adj++)
/* for (int box_i_x_adj = std::max(box_i_x - 1, 0); box_i_x_adj <= std::min(box_i_x + 1, box_nx - 1); box_i_x_adj++)
{
for (int box_i_y_adj = std::max(box_i_y - 1, 0); box_i_y_adj <= std::min(box_i_y + 1, box_ny - 1); box_i_y_adj++)
{
for (int box_i_z_adj = std::max(box_i_z - 1, 0); box_i_z_adj <= std::min(box_i_z + 1, box_nz - 1); box_i_z_adj++)
{
*/
for (int box_i_x_adj = 0; box_i_x_adj < glayerX + glayerX_minus; box_i_x_adj++)
{
for (int box_i_y_adj = 0; box_i_y_adj < glayerY + glayerY_minus; box_i_y_adj++)
{
for (int box_i_z_adj = 0; box_i_z_adj < glayerZ + glayerZ_minus; box_i_z_adj++)
{
for (auto &fatom2 : this->atoms_in_box[box_i_x_adj][box_i_y_adj][box_i_z_adj])
{
this->Construct_Adjacent_final(fatom, &fatom2);
Expand Down

0 comments on commit d298d97

Please sign in to comment.