Skip to content

Commit d298d97

Browse files
committed
revert algo back to all 2 all search
1 parent 76d1336 commit d298d97

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

source/module_cell/module_neighbor/sltk_grid.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs
194194

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

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

212-
218+
atoms_in_box.resize(this->box_nx);
219+
for (int i = 0; i < this->box_nx; i++)
220+
{
221+
atoms_in_box[i].resize(this->box_ny);
222+
for (int j = 0; j < this->box_ny; j++)
223+
{
224+
atoms_in_box[i][j].resize(this->box_nz);
225+
}
226+
}
213227
for (int ix = -glayerX_minus; ix < glayerX; ix++)
214228
{
215229
for (int iy = -glayerY_minus; iy < glayerY; iy++)
@@ -225,7 +239,10 @@ void Grid::setMemberVariables(std::ofstream& ofs_in, // output data to ofs
225239
double z = ucell.atoms[i].tau[j].z + vec1[2] * ix + vec2[2] * iy + vec3[2] * iz;
226240
FAtom atom(x, y, z, i, j, ix, iy, iz);
227241
int box_i_x, box_i_y, box_i_z;
228-
this->getBox(box_i_x, box_i_y, box_i_z, x, y, z);
242+
//this->getBox(box_i_x, box_i_y, box_i_z, x, y, z);
243+
box_i_x = ix + glayerX_minus;
244+
box_i_y = iy + glayerY_minus;
245+
box_i_z = iz + glayerZ_minus;
229246
this->atoms_in_box[box_i_x][box_i_y][box_i_z].push_back(atom);
230247
}
231248
}
@@ -269,12 +286,19 @@ void Grid::Construct_Adjacent_near_box(const FAtom& fatom)
269286
int box_i_x, box_i_y, box_i_z;
270287
this->getBox(box_i_x, box_i_y, box_i_z, fatom.x, fatom.y, fatom.z);
271288

272-
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++)
289+
/* 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++)
273290
{
274291
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++)
275292
{
276293
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++)
277294
{
295+
*/
296+
for (int box_i_x_adj = 0; box_i_x_adj < glayerX + glayerX_minus; box_i_x_adj++)
297+
{
298+
for (int box_i_y_adj = 0; box_i_y_adj < glayerY + glayerY_minus; box_i_y_adj++)
299+
{
300+
for (int box_i_z_adj = 0; box_i_z_adj < glayerZ + glayerZ_minus; box_i_z_adj++)
301+
{
278302
for (auto &fatom2 : this->atoms_in_box[box_i_x_adj][box_i_y_adj][box_i_z_adj])
279303
{
280304
this->Construct_Adjacent_final(fatom, &fatom2);

0 commit comments

Comments
 (0)