Skip to content

Commit 06a49f4

Browse files
committed
A highly aggressive change: replaced the original atomlink data structure with the Standard Template Library.
1 parent 6df9240 commit 06a49f4

File tree

8 files changed

+156
-801
lines changed

8 files changed

+156
-801
lines changed

source/module_cell/module_neighbor/sltk_adjacent_set.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ AdjacentSet::~AdjacentSet() {}
2424

2525

2626

27-
void AdjacentSet::set
28-
(
29-
const int box_x,
30-
const int box_y,
31-
const int box_z,
32-
const int offset_in,
33-
const int &test_grid_in
34-
)
27+
void AdjacentSet::set(const int box_x,
28+
const int box_y,
29+
const int box_z,
30+
const int offset_in,
31+
const int &test_grid_in)
3532
{
3633
int index_box=0; // mohan update 2021-06-22
3734

@@ -113,9 +110,3 @@ void AdjacentSet::getBox
113110

114111
return;
115112
}
116-
//2015-05-07
117-
void AdjacentSet::delete_vector()
118-
{
119-
std::vector<int>().swap(box);
120-
std::vector<int>().swap(offset);
121-
}

source/module_cell/module_neighbor/sltk_adjacent_set.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ class AdjacentSet
6161
//==========================================================
6262
AdjacentSet();
6363
~AdjacentSet();
64-
//2015-05-07
65-
void delete_vector(void);
6664

6765
int getLength(void) const {return length;}
6866

source/module_cell/module_neighbor/sltk_atom.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ FAtom::FAtom()
1212
d_x = 0.0;
1313
d_y = 0.0;
1414
d_z = 0.0;
15-
as = nullptr;
1615
type = 0;
1716
natom = 0;
1817
}
1918

2019
FAtom::~FAtom()
2120
{
2221
}
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: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include <memory>
55
#include "sltk_util.h"
66
#include "sltk_adjacent_set.h"
7-
7+
#include "module_base/timer.h"
8+
#include <list>
89
class AdjacentSet;
910

1011
// a class contains the atom position,
@@ -15,7 +16,7 @@ class FAtom
1516
double d_x;
1617
double d_y;
1718
double d_z;
18-
std::shared_ptr<AdjacentSet> as;
19+
std::list<FAtom *> adjacent;
1920

2021
int type;
2122
int natom;
@@ -43,29 +44,13 @@ class FAtom
4344
cell_z = cell_z_in;
4445
}
4546
~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>(); }
6847

48+
void addAdjacent(FAtom& atom_in)
49+
{
50+
adjacent.push_back( &atom_in);
51+
}
52+
const std::list<FAtom *>& getAdjacent() const { return adjacent; }
53+
void clearAdjacent() { adjacent.clear(); }
6954
//==========================================================
7055
// MEMBER FUNCTION :
7156
// EXPLAIN : get value
@@ -77,7 +62,7 @@ class FAtom
7762
const int& getNatom() const { return natom;}
7863
const int& getCellX() const { return cell_x; }
7964
const int& getCellY() const { return cell_y; }
80-
const int& getCellZ() const { return cell_z; }
65+
const int& getCellZ() const { return cell_z; }
8166
};
8267

8368
#endif

0 commit comments

Comments
 (0)