Skip to content

Commit

Permalink
Refactor: replaced the original atomlink data structure with the Stan…
Browse files Browse the repository at this point in the history
…dard 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>
  • Loading branch information
goodchong and pre-commit-ci-lite[bot] authored Dec 2, 2024
1 parent b377902 commit a43cbfb
Show file tree
Hide file tree
Showing 23 changed files with 1,088 additions and 2,552 deletions.
3 changes: 1 addition & 2 deletions source/Makefile.Objects
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ OBJS_MD=fire.o\
run_md.o\
verlet.o\

OBJS_NEIGHBOR=sltk_adjacent_set.o\
sltk_atom.o\
OBJS_NEIGHBOR=sltk_atom.o\
sltk_atom_arrange.o\
sltk_atom_input.o\
sltk_grid.o\
Expand Down
1 change: 0 additions & 1 deletion source/module_cell/module_neighbor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
add_library(
neighbor
OBJECT
sltk_adjacent_set.cpp
sltk_atom.cpp
sltk_atom_arrange.cpp
sltk_atom_input.cpp
Expand Down
121 changes: 0 additions & 121 deletions source/module_cell/module_neighbor/sltk_adjacent_set.cpp

This file was deleted.

117 changes: 0 additions & 117 deletions source/module_cell/module_neighbor/sltk_adjacent_set.h

This file was deleted.

15 changes: 0 additions & 15 deletions source/module_cell/module_neighbor/sltk_atom.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
#include "sltk_atom.h"
#include <iostream>

class AdjacentSet;

//int FAtom::count1 = 0;
//int FAtom::count2 = 0;

/*** Constructors and destructor ***/
FAtom::FAtom()
{
d_x = 0.0;
d_y = 0.0;
d_z = 0.0;
as = nullptr;
type = 0;
natom = 0;
}

FAtom::~FAtom()
{
}

void FAtom::delete_vector(void)
{
if (as) { as->delete_vector(); }
}
42 changes: 14 additions & 28 deletions source/module_cell/module_neighbor/sltk_atom.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

#include <memory>
#include "sltk_util.h"
#include "sltk_adjacent_set.h"

class AdjacentSet;
#include "module_base/timer.h"
#include <vector>

// a class contains the atom position,
// the type and the index,
Expand All @@ -15,7 +14,7 @@ class FAtom
double d_x;
double d_y;
double d_z;
std::shared_ptr<AdjacentSet> as;
std::vector<FAtom *> adjacent;

int type;
int natom;
Expand All @@ -42,30 +41,17 @@ class FAtom
cell_y = cell_y_in;
cell_z = cell_z_in;
}
~FAtom();
//2015-05-07
void delete_vector();

// static int count1;
// static int count2;

//==========================================================
// MEMBER FUNCTION :
// NAME : setAdjacent
// Dangerous but high performance interface function!
// no exception test.
//
// NAME : getAdjacentSet
//
// NAME : setAdjacentSet
//==========================================================

std::shared_ptr<AdjacentSet> getAdjacentSet() const
{ return this->as; }

void allocate_AdjacentSet()
{ this->as = std::make_shared<AdjacentSet>(); }
~FAtom()
{
adjacent.clear();
}

void addAdjacent(FAtom& atom_in)
{
adjacent.push_back( &atom_in);
}
const std::vector<FAtom *>& getAdjacent() const { return adjacent; }
void clearAdjacent() { adjacent.clear(); }
//==========================================================
// MEMBER FUNCTION :
// EXPLAIN : get value
Expand All @@ -77,7 +63,7 @@ class FAtom
const int& getNatom() const { return natom;}
const int& getCellX() const { return cell_x; }
const int& getCellY() const { return cell_y; }
const int& getCellZ() const { return cell_z; }
const int& getCellZ() const { return cell_z; }
};

#endif
Loading

0 comments on commit a43cbfb

Please sign in to comment.