-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid_meshk.cpp
48 lines (40 loc) · 1006 Bytes
/
grid_meshk.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "grid_meshk.h"
#include "module_hamilt_pw/hamilt_pwdft/global.h"
Grid_MeshK::Grid_MeshK()
{
ucell_index2x = nullptr;
ucell_index2y = nullptr;
ucell_index2z = nullptr;
}
Grid_MeshK::~Grid_MeshK()
{
if(ucell_index2x!=nullptr)
{
delete[] ucell_index2x;
}
if(ucell_index2y!=nullptr)
{
delete[] ucell_index2y;
}
if(ucell_index2z!=nullptr)
{
delete[] ucell_index2z;
}
}
int Grid_MeshK::cal_Rindex(const int &u1, const int &u2, const int &u3)const
{
const int x1 = u1 - this->minu1;
const int x2 = u2 - this->minu2;
const int x3 = u3 - this->minu3;
if(x1<0 || x2<0 || x3<0)
{
std::cout << " u1=" << u1 << " minu1=" << minu1 << std::endl;
std::cout << " u2=" << u2 << " minu2=" << minu2 << std::endl;
std::cout << " u3=" << u3 << " minu3=" << minu3 << std::endl;
ModuleBase::WARNING_QUIT("Grid_MeshK::cal_Rindex","x1<0 || x2<0 || x3<0 !");
}
assert(x1>=0);
assert(x2>=0);
assert(x3>=0);
return (x3 + x2 * this->nu3 + x1 * this->nu2 * this->nu3);
}