ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
record_adj.h
Go to the documentation of this file.
1#ifndef RECORD_ADJ_H
2#define RECORD_ADJ_H
3
7
8#include <array>
9#include <vector>
10
11//---------------------------------------------------
12// FUNCTION: record the adjacent atoms for each atom
13//---------------------------------------------------
15{
16 public:
17 Record_adj();
19
20 //--------------------------------------------
21 // This will record the orbitals according to
22 // HPSEPS's 2D block division.
23 //--------------------------------------------
24 void for_2d(const UnitCell& ucell,
25 const Grid_Driver& grid_d,
27 bool gamma_only,
28 const int npol,
29 const std::vector<double>& orb_cutoff);
30
31
32 void delete_grid();
33
34 private:
35 // (1) count adjacent atoms for each atom and,
36 // for multi-k, accumulate nlocdim / nlocstart / nnr of pv.
37 void count_adjacent(const UnitCell& ucell,
38 const Grid_Driver& grid_d,
40 bool gamma_only,
41 const int npol,
42 const std::vector<double>& orb_cutoff);
43
44 // allocate info[na_proc][na_each[i]][5]
45 void allocate_info();
46
47 // fill info with (Rx, Ry, Rz, T, I) of each adjacent atom.
48 void fill_info(const UnitCell& ucell,
49 const Grid_Driver& grid_d,
50 const std::vector<double>& orb_cutoff);
51
52 public:
53 int na_proc=0;
54 std::vector<int> na_each;
55
56 //--------------------------------------------
57 // record sparse atom index in for_grid();
58 // Map iat(dense atom index) to sparse atom index
59 // Mainly removing the index dependency for OpenMP parallel loop
60 //
61 // Meaning:
62 // 1. if iat2ca[iat] > 0, it contains the sparse atom index
63 // 2. if iat2ca[iat] < 0, the sparse atom index of iat does not exist
64 //
65 // Usage:
66 // 1. iat2ca[iat] > 0 ? na_each[iat2ca[iat]] : 0
67 // 2. iat2ca[iat] > 0 ? info[iat2ca[iat]] : nullptr
68 //--------------------------------------------
69 std::vector<int> iat2ca;
70
71 //------------------------------------------------
72 // info identifies each adjacent atom in each
73 // unitcell. All adjacent records are stored flat:
74 // the records of atom iat occupy
75 // info[info_offset[iat], info_offset[iat]+na_each[iat]).
76 // Each record holds (Rx, Ry, Rz, T, I).
77 //------------------------------------------------
78 std::vector<std::array<int, 5>> info;
79 std::vector<int> info_offset;
80
81 // Access the (Rx, Ry, Rz, T, I) record of the cb-th
82 // adjacent atom of atom iat.
83 const std::array<int, 5>& get_info(const int iat, const int cb) const
84 {
85 return info[info_offset[iat] + cb];
86 }
87};
88
89#endif
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
Definition parallel_orbitals.h:16
void for_2d(const UnitCell &ucell, const Grid_Driver &grid_d, Parallel_Orbitals &pv, bool gamma_only, const int npol, const std::vector< double > &orb_cutoff)
Definition record_adj.cpp:77
int na_proc
Definition record_adj.h:53
std::vector< int > info_offset
Definition record_adj.h:79
void delete_grid()
Definition record_adj.cpp:12
std::vector< std::array< int, 5 > > info
Definition record_adj.h:78
void allocate_info()
Definition record_adj.cpp:185
const std::array< int, 5 > & get_info(const int iat, const int cb) const
Definition record_adj.h:83
void count_adjacent(const UnitCell &ucell, const Grid_Driver &grid_d, Parallel_Orbitals &pv, bool gamma_only, const int npol, const std::vector< double > &orb_cutoff)
Definition record_adj.cpp:110
void fill_info(const UnitCell &ucell, const Grid_Driver &grid_d, const std::vector< double > &orb_cutoff)
Definition record_adj.cpp:204
std::vector< int > na_each
Definition record_adj.h:54
Record_adj()
Definition record_adj.cpp:5
std::vector< int > iat2ca
Definition record_adj.h:69
~Record_adj()
Definition record_adj.cpp:8
Provide the basic information about unitcell.
Definition unitcell.h:16
Grid_Driver class for neighbor search interface.