Skip to content

Commit d3b1883

Browse files
committed
Refactor: move Element_Basis_Index::construct_range() to module_ao
1 parent 66d0bc8 commit d3b1883

File tree

8 files changed

+92
-68
lines changed

8 files changed

+92
-68
lines changed

source/source_base/element_basis_index.cpp

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
//==========================================================
55

66
#include "element_basis_index.h"
7-
#include "../../source_basis/module_ao/ORB_read.h"
8-
#include "../../source_basis/module_ao/ORB_atomic_lm.h"
97

108
namespace ModuleBase
119
{
@@ -15,17 +13,17 @@ Element_Basis_Index::construct_index( const Range &range )
1513
{
1614
IndexLNM index;
1715
index.resize( range.size() );
18-
for( size_t T=0; T!=range.size(); ++T )
16+
for( std::size_t T=0; T!=range.size(); ++T )
1917
{
20-
size_t count=0;
18+
std::size_t count=0;
2119
index[T].resize( range[T].size() );
22-
for( size_t L=0; L!=range[T].size(); ++L )
20+
for( std::size_t L=0; L!=range[T].size(); ++L )
2321
{
2422
index[T][L].resize( range[T][L].N );
25-
for( size_t N=0; N!=range[T][L].N; ++N )
23+
for( std::size_t N=0; N!=range[T][L].N; ++N )
2624
{
2725
index[T][L][N].resize( range[T][L].M );
28-
for( size_t M=0; M!=range[T][L].M; ++M )
26+
for( std::size_t M=0; M!=range[T][L].M; ++M )
2927
{
3028
index[T][L][N][M] = count;
3129
++count;
@@ -39,40 +37,4 @@ Element_Basis_Index::construct_index( const Range &range )
3937
return index;
4038
}
4139

42-
43-
ModuleBase::Element_Basis_Index::Range
44-
Element_Basis_Index::construct_range( const LCAO_Orbitals &orb )
45-
{
46-
ModuleBase::Element_Basis_Index::Range range;
47-
range.resize( orb.get_ntype() );
48-
for( size_t T=0; T!=range.size(); ++T )
49-
{
50-
range[T].resize( orb.Phi[T].getLmax()+1 );
51-
for( size_t L=0; L!=range[T].size(); ++L )
52-
{
53-
range[T][L].N = orb.Phi[T].getNchi(L);
54-
range[T][L].M = 2*L+1;
55-
}
56-
}
57-
return range;
58-
}
59-
60-
61-
ModuleBase::Element_Basis_Index::Range
62-
Element_Basis_Index::construct_range( const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &orb )
63-
{
64-
ModuleBase::Element_Basis_Index::Range range;
65-
range.resize( orb.size() );
66-
for( size_t T=0; T!=range.size(); ++T )
67-
{
68-
range[T].resize( orb[T].size() );
69-
for( size_t L=0; L!=range[T].size(); ++L )
70-
{
71-
range[T][L].N = orb[T][L].size();
72-
range[T][L].M = 2*L+1;
73-
}
74-
}
75-
return range;
76-
}
77-
7840
}

source/source_base/element_basis_index.h

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,40 @@
99
#include <cstddef>
1010
#include <vector>
1111

12-
class Numerical_Orbital_Lm;
13-
class LCAO_Orbitals;
14-
1512
namespace ModuleBase
1613
{
1714

18-
class Element_Basis_Index
15+
namespace Element_Basis_Index
1916
{
20-
private:
21-
17+
//private:
18+
2219
struct NM
2320
{
2421
public:
25-
size_t N;
26-
size_t M;
22+
std::size_t N;
23+
std::size_t M;
2724
};
28-
29-
class Index_TL: public std::vector<std::vector<size_t>>
25+
26+
class Index_TL: public std::vector<std::vector<std::size_t>>
3027
{
3128
public:
32-
size_t N;
33-
size_t M;
29+
std::size_t N;
30+
std::size_t M;
3431
};
35-
32+
3633
class Index_T: public std::vector<Index_TL>
3734
{
3835
public:
39-
size_t count_size;
40-
};
41-
42-
public:
43-
36+
std::size_t count_size;
37+
};
38+
39+
//public:
40+
4441
typedef std::vector<std::vector<NM>> Range; // range[T][L]
4542
typedef std::vector<Index_T> IndexLNM; // index[T][L][N][M]
46-
47-
static IndexLNM construct_index( const Range &range );
4843

49-
static Range construct_range( const LCAO_Orbitals &orb );
50-
static Range construct_range( const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &orb );
51-
};
44+
extern IndexLNM construct_index( const Range &range );
45+
}
5246

5347
}
5448

source/source_basis/module_ao/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if(ENABLE_LCAO)
99
ORB_nonlocal_lm.cpp
1010
ORB_read.cpp
1111
parallel_orbitals.cpp
12+
element_basis_index-ORB.cpp
1213
)
1314

1415
if(ENABLE_COVERAGE)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "element_basis_index-ORB.h"
2+
3+
#include "ORB_read.h"
4+
#include "ORB_atomic_lm.h"
5+
6+
namespace ModuleBase
7+
{
8+
9+
ModuleBase::Element_Basis_Index::Range
10+
Element_Basis_Index::construct_range( const LCAO_Orbitals &orb )
11+
{
12+
ModuleBase::Element_Basis_Index::Range range;
13+
range.resize( orb.get_ntype() );
14+
for( std::size_t T=0; T!=range.size(); ++T )
15+
{
16+
range[T].resize( orb.Phi[T].getLmax()+1 );
17+
for( std::size_t L=0; L!=range[T].size(); ++L )
18+
{
19+
range[T][L].N = orb.Phi[T].getNchi(L);
20+
range[T][L].M = 2*L+1;
21+
}
22+
}
23+
return range;
24+
}
25+
26+
27+
ModuleBase::Element_Basis_Index::Range
28+
Element_Basis_Index::construct_range( const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &orb )
29+
{
30+
ModuleBase::Element_Basis_Index::Range range;
31+
range.resize( orb.size() );
32+
for( std::size_t T=0; T!=range.size(); ++T )
33+
{
34+
range[T].resize( orb[T].size() );
35+
for( std::size_t L=0; L!=range[T].size(); ++L )
36+
{
37+
range[T][L].N = orb[T][L].size();
38+
range[T][L].M = 2*L+1;
39+
}
40+
}
41+
return range;
42+
}
43+
44+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef ELEMENT_BASIS_INDEX_ORB_H
2+
#define ELEMENT_BASIS_INDEX_ORB_H
3+
4+
#include "../../source_base/element_basis_index.h"
5+
#include <vector>
6+
7+
class Numerical_Orbital_Lm;
8+
class LCAO_Orbitals;
9+
10+
namespace ModuleBase
11+
{
12+
13+
namespace Element_Basis_Index
14+
{
15+
extern Range construct_range( const LCAO_Orbitals &orb );
16+
17+
extern Range construct_range( const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> &orb ); // orb[T][L][N]
18+
}
19+
20+
}
21+
22+
#endif

source/source_lcao/module_ri/ABFs_Construct-PCA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../../source_base/module_external/lapack_connector.h"
44
#include "../../source_base/global_function.h"
5-
#include "../../source_base/element_basis_index.h"
5+
#include "../../source_basis/module_ao/element_basis_index-ORB.h"
66
#include "../../source_base/matrix.h"
77
#include "../../source_lcao/module_ri/Matrix_Orbs11.h"
88
#include "../../source_lcao/module_ri/Matrix_Orbs21.h"

source/source_lcao/module_ri/LRI_CV.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "LRI_CV_Tools.h"
1111
#include "exx_abfs-construct_orbs.h"
1212
#include "RI_Util.h"
13+
#include "../../source_basis/module_ao/element_basis_index-ORB.h"
1314
#include "../../source_base/tool_title.h"
1415
#include "../../source_base/timer.h"
1516
#include "../../source_pw/module_pwdft/global.h"

source/source_lcao/module_ri/exx_opt_orb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "exx_abfs-construct_orbs.h"
66
#include "exx_abfs-io.h"
77
#include "exx_abfs-jle.h"
8-
#include "source_base/element_basis_index.h"
8+
#include "source_basis/module_ao/element_basis_index-ORB.h"
99
#include "source_basis/module_ao/ORB_read.h"
1010
#include "source_lcao/module_ri/Matrix_Orbs11.h"
1111
#include "source_lcao/module_ri/Matrix_Orbs21.h"

0 commit comments

Comments
 (0)