11#ifndef GRID_H
22#define GRID_H
33
4- #include < stdexcept>
5- #include < functional>
6- #include " sltk_util.h"
4+ #include " module_cell/unitcell.h"
75#include " sltk_atom.h"
86#include " sltk_atom_input.h"
7+ #include " sltk_util.h"
98
10- #include " module_cell/unitcell.h "
11- #include < unordered_map >
9+ #include < functional >
10+ #include < stdexcept >
1211#include < tuple>
12+ #include < unordered_map>
1313
1414typedef std::vector<std::vector<FAtom>> AtomMap;
1515
1616struct CellSet
1717{
18- AtomMap atom_map;
19- int in_grid[3 ];
20- CellSet ();
18+ AtomMap atom_map;
19+ int in_grid[3 ];
20+ CellSet ();
2121};
2222
2323// ==========================================================
@@ -34,111 +34,132 @@ class Atom_input;
3434
3535class Grid
3636{
37- public:
38-
39- // Constructors and destructor
40- // Grid is Global class,so init it with constant number
41- Grid ():test_grid(0 ){};
42- Grid (const int &test_grid_in);
43- virtual ~Grid ();
44-
45- void init (std::ofstream &ofs,
46- const UnitCell &ucell,
47- const Atom_input &input);
48-
49- // 2015-05-07
50- void delete_vector (int i, int j, int k);
51-
52- // Data
53- bool pbc; // periodic boundary condition
54- bool expand_flag;
55- double sradius2;// searching radius squared
56- double sradius;// searching radius
57- double d_minX;// origin of all cells
58- double d_minY;
59- double d_minZ;
60- int cell_nx;
61- int cell_ny;
62- int cell_nz;
63- int layer;
64-
65- int true_cell_x;
66- int true_cell_y;
67- int true_cell_z;
68-
69- std::vector<std::vector<std::vector<CellSet>>> Cell; // dx , dy ,dz is cell number in each direction,respectly.
70- void delete_Cell () // it will replace by container soon!
71- {
72- if (this ->init_cell_flag )
73- {
74- for (int i = 0 ;i < this ->cell_nx ;i++)
75- {
76- for (int j = 0 ;j < this ->cell_ny ;j++)
77- {
78- this ->Cell [i][j].clear ();
79- }
80- }
81-
82- for (int i = 0 ;i < this ->cell_nx ;i++)
83- {
84- this ->Cell [i].clear ();
85- }
86-
87- this ->Cell .clear ();
88- this ->init_cell_flag = false ;
89- }
90- }
91- bool init_cell_flag;
92- // LiuXh add 2019-07-15
93- double getD_minX () const {return d_minX;}
94- double getD_minY () const {return d_minY;}
95- double getD_minZ () const {return d_minZ;}
96-
97-
98- int getCellX () const {return cell_nx;}
99- int getCellY () const {return cell_ny;}
100- int getCellZ () const {return cell_nz;}
101- int getTrueCellX () const {return true_cell_x;}
102- int getTrueCellY () const {return true_cell_y;}
103- int getTrueCellZ () const {return true_cell_z;}
104-
105- private:
106-
107- const int test_grid;
108- // ==========================================================
109- // MEMBER FUNCTIONS :
110- // Three Main Steps:
111- // NAME : setMemberVariables (read in datas from Atom_input,
112- // init cells.)
113- // NAME : setBoundaryAdjacent( Consider different situations,
114- // if not_expand case : nature/periodic boundary
115- // condition , if expand_case)
116- // ==========================================================
117- void setMemberVariables (std::ofstream &ofs_in,
118- const Atom_input &input);
119-
120- void setBoundaryAdjacent (std::ofstream &ofs_in,
121- const Atom_input &input);
122-
123- // ==========================================================
124- void Build_Hash_Table (const UnitCell &ucell, const Atom_input &input);
125-
126- // ==========================================================
127-
128- void Construct_Adjacent_expand (const int i, const int j, const int k);
129-
130- void Construct_Adjacent_expand_periodic (const int i,
131- const int j,
132- const int k,
133- FAtom& fatom);
134-
135- void Construct_Adjacent_begin ();
136- void Construct_Adjacent_nature (
137- const int i, const int j, const int k, FAtom & fatom1);
138- void Construct_Adjacent_periodic (
139- const int i, const int j, const int k, FAtom & fatom1);
140- void Construct_Adjacent_final (const int i, const int j, const int k, FAtom & fatom1,
141- const int i2, const int j2, const int k2, FAtom & fatom2);
37+ public:
38+ // Constructors and destructor
39+ // Grid is Global class,so init it with constant number
40+ Grid () : test_grid(0 ){};
41+ Grid (const int & test_grid_in);
42+ virtual ~Grid ();
43+
44+ void init (std::ofstream& ofs, const UnitCell& ucell, const Atom_input& input);
45+
46+ // 2015-05-07
47+ void delete_vector (int i, int j, int k);
48+
49+ // Data
50+ bool pbc; // periodic boundary condition
51+ bool expand_flag;
52+ double sradius2; // searching radius squared
53+ double sradius; // searching radius
54+ double d_minX; // origin of all cells
55+ double d_minY;
56+ double d_minZ;
57+ int cell_nx;
58+ int cell_ny;
59+ int cell_nz;
60+ int layer;
61+
62+ int true_cell_x;
63+ int true_cell_y;
64+ int true_cell_z;
65+
66+ std::vector<std::vector<std::vector<CellSet>>> Cell; // dx , dy ,dz is cell number in each direction,respectly.
67+ void delete_Cell () // it will replace by container soon!
68+ {
69+ if (this ->init_cell_flag )
70+ {
71+ for (int i = 0 ; i < this ->cell_nx ; i++)
72+ {
73+ for (int j = 0 ; j < this ->cell_ny ; j++)
74+ {
75+ this ->Cell [i][j].clear ();
76+ }
77+ }
78+
79+ for (int i = 0 ; i < this ->cell_nx ; i++)
80+ {
81+ this ->Cell [i].clear ();
82+ }
83+
84+ this ->Cell .clear ();
85+ this ->init_cell_flag = false ;
86+ }
87+ }
88+ bool init_cell_flag = false ;
89+ // LiuXh add 2019-07-15
90+ double getD_minX () const
91+ {
92+ return d_minX;
93+ }
94+ double getD_minY () const
95+ {
96+ return d_minY;
97+ }
98+ double getD_minZ () const
99+ {
100+ return d_minZ;
101+ }
102+
103+ int getCellX () const
104+ {
105+ return cell_nx;
106+ }
107+ int getCellY () const
108+ {
109+ return cell_ny;
110+ }
111+ int getCellZ () const
112+ {
113+ return cell_nz;
114+ }
115+ int getTrueCellX () const
116+ {
117+ return true_cell_x;
118+ }
119+ int getTrueCellY () const
120+ {
121+ return true_cell_y;
122+ }
123+ int getTrueCellZ () const
124+ {
125+ return true_cell_z;
126+ }
127+
128+ private:
129+ const int test_grid;
130+ // ==========================================================
131+ // MEMBER FUNCTIONS :
132+ // Three Main Steps:
133+ // NAME : setMemberVariables (read in datas from Atom_input,
134+ // init cells.)
135+ // NAME : setBoundaryAdjacent( Consider different situations,
136+ // if not_expand case : nature/periodic boundary
137+ // condition , if expand_case)
138+ // ==========================================================
139+ void setMemberVariables (std::ofstream& ofs_in, const Atom_input& input);
140+
141+ void setBoundaryAdjacent (std::ofstream& ofs_in, const Atom_input& input);
142+
143+ // ==========================================================
144+ void Build_Hash_Table (const UnitCell& ucell, const Atom_input& input);
145+
146+ // ==========================================================
147+
148+ void Construct_Adjacent_expand (const int i, const int j, const int k);
149+
150+ void Construct_Adjacent_expand_periodic (const int i, const int j, const int k, FAtom& fatom);
151+
152+ void Construct_Adjacent_begin ();
153+ void Construct_Adjacent_nature (const int i, const int j, const int k, FAtom& fatom1);
154+ void Construct_Adjacent_periodic (const int i, const int j, const int k, FAtom& fatom1);
155+ void Construct_Adjacent_final (const int i,
156+ const int j,
157+ const int k,
158+ FAtom& fatom1,
159+ const int i2,
160+ const int j2,
161+ const int k2,
162+ FAtom& fatom2);
142163};
143164
144165#endif
0 commit comments