@@ -163,21 +163,6 @@ void Grid::Build_Hash_Table(const UnitCell& ucell)
163163{
164164 ModuleBase::timer::tick (" Grid" , " Build_Hash_Table" );
165165
166- // TODO in case expand == false, the following code is over malloc
167- for (int i = 0 ; i < cell_nx; i++)
168- {
169- for (int j = 0 ; j < cell_ny; j++)
170- {
171- for (int k = 0 ; k < cell_nz; k++)
172- {
173- Cell[i][j][k].resize (ucell.ntype );
174- for (int it = 0 ; it < ucell.ntype ; ++it)
175- {
176- Cell[i][j][k][it].resize (ucell.atoms [it].na );
177- }
178- }
179- }
180- }
181166 ModuleBase::Vector3<double > vec1 (ucell.latvec .e11 , ucell.latvec .e12 , ucell.latvec .e13 );
182167 ModuleBase::Vector3<double > vec2 (ucell.latvec .e21 , ucell.latvec .e22 , ucell.latvec .e23 );
183168 ModuleBase::Vector3<double > vec3 (ucell.latvec .e31 , ucell.latvec .e32 , ucell.latvec .e33 );
@@ -201,7 +186,7 @@ void Grid::Build_Hash_Table(const UnitCell& ucell)
201186 b = iy + glayerY_minus;
202187 c = iz + glayerZ_minus;
203188
204- this ->Cell [a][b][c][atom. type ][ atom. natom ] = atom ;
189+ this ->Cell [a][b][c]. push_back ( atom) ;
205190 }
206191 }
207192 }
@@ -214,12 +199,9 @@ void Grid::Construct_Adjacent_expand(const int true_i, const int true_j, const i
214199{
215200 ModuleBase::timer::tick (" Grid" , " Construct_Adjacent_expand" );
216201
217- for (auto & atom_vector : this ->Cell [true_i][true_j][true_k])
202+ for (auto & fatom : this ->Cell [true_i][true_j][true_k])
218203 {
219- for (auto & fatom: atom_vector)
220- {
221- Construct_Adjacent_expand_periodic (true_i, true_j, true_k, fatom);
222- }
204+ Construct_Adjacent_expand_periodic (true_i, true_j, true_k, fatom);
223205 }
224206 ModuleBase::timer::tick (" Grid" , " Construct_Adjacent_expand" );
225207}
@@ -235,12 +217,9 @@ void Grid::Construct_Adjacent_expand_periodic(const int true_i, const int true_j
235217 {
236218 for (int k = 0 ; k < this ->cell_nz ; k++)
237219 {
238- for (auto & atom_vector : this ->Cell [i][j][k])
220+ for (auto & fatom2 : this ->Cell [i][j][k])
239221 {
240- for (auto & fatom2: atom_vector)
241- {
242- Construct_Adjacent_final (true_i, true_j, true_k, fatom, i, j, k, fatom2);
243- }
222+ Construct_Adjacent_final (true_i, true_j, true_k, fatom, i, j, k, fatom2);
244223 }
245224 }
246225 }
0 commit comments