Skip to content

Commit a43cbfb

Browse files
Refactor: replaced the original atomlink data structure with the Standard Template Library (#5642)
* A highly aggressive change: replaced the original atomlink data structure with the Standard Template Library. * fix unittest errors * [pre-commit.ci lite] apply automatic fixes * fix a adj set clear bug and add self to adj list * use vector to refactor Cellset varible * remove adjacent set, replaced by std list * remove set fatom * [pre-commit.ci lite] apply automatic fixes * use 2 layers vector replace undered_map to improve perfermance * remove a lot useless variable * remove some useless variables * refresh unit test to code logic * [pre-commit.ci lite] apply automatic fixes * fix a bug to force quit when test * fresh unit test according to latest code logic --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent b377902 commit a43cbfb

23 files changed

+1088
-2552
lines changed

source/Makefile.Objects

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,7 @@ OBJS_MD=fire.o\
366366
run_md.o\
367367
verlet.o\
368368

369-
OBJS_NEIGHBOR=sltk_adjacent_set.o\
370-
sltk_atom.o\
369+
OBJS_NEIGHBOR=sltk_atom.o\
371370
sltk_atom_arrange.o\
372371
sltk_atom_input.o\
373372
sltk_grid.o\

source/module_cell/module_neighbor/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
add_library(
22
neighbor
33
OBJECT
4-
sltk_adjacent_set.cpp
54
sltk_atom.cpp
65
sltk_atom_arrange.cpp
76
sltk_atom_input.cpp

source/module_cell/module_neighbor/sltk_adjacent_set.cpp

Lines changed: 0 additions & 121 deletions
This file was deleted.

source/module_cell/module_neighbor/sltk_adjacent_set.h

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
#include "sltk_atom.h"
22
#include <iostream>
33

4-
class AdjacentSet;
5-
6-
//int FAtom::count1 = 0;
7-
//int FAtom::count2 = 0;
8-
94
/*** Constructors and destructor ***/
105
FAtom::FAtom()
116
{
127
d_x = 0.0;
138
d_y = 0.0;
149
d_z = 0.0;
15-
as = nullptr;
1610
type = 0;
1711
natom = 0;
1812
}
19-
20-
FAtom::~FAtom()
21-
{
22-
}
23-
24-
void FAtom::delete_vector(void)
25-
{
26-
if (as) { as->delete_vector(); }
27-
}

source/module_cell/module_neighbor/sltk_atom.h

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
#include <memory>
55
#include "sltk_util.h"
6-
#include "sltk_adjacent_set.h"
7-
8-
class AdjacentSet;
6+
#include "module_base/timer.h"
7+
#include <vector>
98

109
// a class contains the atom position,
1110
// the type and the index,
@@ -15,7 +14,7 @@ class FAtom
1514
double d_x;
1615
double d_y;
1716
double d_z;
18-
std::shared_ptr<AdjacentSet> as;
17+
std::vector<FAtom *> adjacent;
1918

2019
int type;
2120
int natom;
@@ -42,30 +41,17 @@ class FAtom
4241
cell_y = cell_y_in;
4342
cell_z = cell_z_in;
4443
}
45-
~FAtom();
46-
//2015-05-07
47-
void delete_vector();
48-
49-
// static int count1;
50-
// static int count2;
51-
52-
//==========================================================
53-
// MEMBER FUNCTION :
54-
// NAME : setAdjacent
55-
// Dangerous but high performance interface function!
56-
// no exception test.
57-
//
58-
// NAME : getAdjacentSet
59-
//
60-
// NAME : setAdjacentSet
61-
//==========================================================
62-
63-
std::shared_ptr<AdjacentSet> getAdjacentSet() const
64-
{ return this->as; }
65-
66-
void allocate_AdjacentSet()
67-
{ this->as = std::make_shared<AdjacentSet>(); }
44+
~FAtom()
45+
{
46+
adjacent.clear();
47+
}
6848

49+
void addAdjacent(FAtom& atom_in)
50+
{
51+
adjacent.push_back( &atom_in);
52+
}
53+
const std::vector<FAtom *>& getAdjacent() const { return adjacent; }
54+
void clearAdjacent() { adjacent.clear(); }
6955
//==========================================================
7056
// MEMBER FUNCTION :
7157
// EXPLAIN : get value
@@ -77,7 +63,7 @@ class FAtom
7763
const int& getNatom() const { return natom;}
7864
const int& getCellX() const { return cell_x; }
7965
const int& getCellY() const { return cell_y; }
80-
const int& getCellZ() const { return cell_z; }
66+
const int& getCellZ() const { return cell_z; }
8167
};
8268

8369
#endif

0 commit comments

Comments
 (0)