Commit 196d199
Split vnl_pw.cpp into several smaller files (deepmodeling#7869)
* Refactor vnl_pw, step 1: extract getvnl into vnl_pw_getvnl.cpp
- Move getvnl<FPTYPE, Device> template body + 4 explicit
instantiations (CPU/GPU float/double) from vnl_pw.cpp
to new file vnl_pw_getvnl.cpp (~165 lines)
- Update CMakeLists.txt and Makefile.Objects accordingly
- vnl_pw.cpp reduced from 1797 to 1641 lines
Verification:
cd build_max_para_test && make -j 30
=> build passed, no undefined reference
* Style: split multi-variable declarations in vnl_pw_getvnl.cpp
- One variable per line for better readability and maintainability
- Rename pointer variables: _tab -> tab_ptr, _indv -> indv_ptr,
_nhtol -> nhtol_ptr, _nhtolm -> nhtolm_ptr
(avoid leading underscore, use _ptr suffix)
Verification:
cd build_max_para_test && make -j 30
=> build passed
* Doc: add one-variable-per-line rule to AGENTS.md
Rule deepmodeling#8 in Required Baseline: declare one variable per line;
do not use comma-separated declarations.
This improves readability, makes diffs cleaner, and helps
debugging with single-step execution.
* Refactor: replace new/delete with std::vector in vnl_pw_getvnl.cpp
- Replace int* h_atom_nh/na/nb with std::vector<int>
- Replace ModuleBase::Vector3<double>* _gk with std::vector<Vector3>
- Use .data() to get raw pointer for GPU sync operations
- Remove all delete[] calls (RAII handles cleanup automatically)
Benefits:
- Exception safety (no memory leak if exception thrown)
- Cleaner code (no manual memory management)
- Follows modern C++ best practices
Verification:
cd build_max_para_test && make -j 30
=> build passed
* Doc: add doxygen comments to vnl_pw_getvnl.cpp
- Add file-level @file/@brief documentation
- Add getvnl() function documentation with workflow steps
- Add comment explaining explicit template instantiations
* Step 2: extract qrad/radial_fft_q into vnl_pw_qrad.cpp
- Move compute_qrad(), radial_fft_q() (CPU matrix version),
radial_fft_q<FPTYPE,Device>() (template version), and
4 explicit template instantiations to vnl_pw_qrad.cpp
- Replace new[]/delete[] with std::vector in compute_qrad()
- Add doxygen comments for all functions
- Update CMakeLists.txt and Makefile.Objects
Verification:
cd build_max_para_test && make -j 30
=> build passed
* Step 3: extract cal_effective_D/newq/newd_* into vnl_pw_deeq.cpp
- Move cal_effective_D(), newq(), newd_so(), newd_nc() to vnl_pw_deeq.cpp
- Replace new[]/delete[] qnorm with std::vector in newq()
- Add doxygen comments for all functions
- Update CMakeLists.txt and Makefile.Objects
- Fix blas_connector.h include path (source_base/module_external/)
Verification:
cd build_max_para_test && make -j 30
=> build passed
* refactor(pwdft): move LCAO alpha-channel VNL helpers to vnl_pw_alpha.cpp
Step 4 of vnl_pw.cpp split:
- Move Cal_C(), CG(), init_vnl_alpha() into new vnl_pw_alpha.cpp
- Wrap whole file with #ifdef __LCAO
- Drop dead commented-out getvnl_alpha block
- Replace new[]/delete[] with std::vector for jl/aux in init_vnl_alpha
- Sync CMakeLists.txt and Makefile.Objects
Verified: make -j 30 in build_max_para_test passes.
* refactor(pwdft): move init_vnl into vnl_pw_init_vnl.cpp
Step 5 of vnl_pw.cpp split:
- Move init_vnl() into new vnl_pw_init_vnl.cpp
- Replace new[]/delete[] with std::vector for jl/aux inside the tab fill loop
- Sync CMakeLists.txt and Makefile.Objects
Verified: make -j 30 in build_max_para_test passes.
* refactor(pwdft): clean up vnl_pw.cpp after split, drop unused includes
Step 6 of vnl_pw.cpp split (final):
- Keep only ctor/dtor, release_memory(), init(), print_vnl(),
rescale_vnl() and the get_*_data<T>() template specializations
- Drop now-unused includes (clebsch_gordan, math_integral, math_polyint,
math_sphbes, math_ylmreal, parallel_reduce, vnl_op, parallel_comm)
- Add file-level doxygen comment describing the new module layout
Verified: make -j 30 in build_max_para_test passes.
* Remove accidentally added empty CONNECT file
The empty CONNECT file was unintentionally added in commit 3b53f58
during the vnl_pw_qrad split. It is not referenced by any code, build
file, or script, so it is safe to delete.
* update format
* refactor(pwdft): replace raw new/delete arrays with std::vector in vl/vnl pseudopotential code
- convert pseudopot_cell_vl local buffers (vloc1d/aux1/aux) and member zp to std::vector
- convert pseudopot_cell_vnl::indv_ijkb0 to std::vector and drop manual delete
- use std::fill/std::copy instead of ZEROS/COPYARRAY helpers on vectors
* update AGENTS.md
* docs: add std::vector conversion guideline to AGENTS.md baseline
* style(pwdft): replace tab indentation with 4 spaces in vl_pw files
* refactor(pw): decouple print_vloc from PARAM and move it out of init_vloc
- print_vloc takes out_element_info and global_out_dir explicitly instead
of reading PARAM internally
- callers invoke print_vloc right after init_vloc at all four call sites
* refactor(ofdft): cache PARAM.inp.nspin into local const in KEDF_XWM::get_energy
Cache PARAM.inp.nspin into a local const to reduce repeated global
parameter accesses, and add the missing newline at end of file.
---------
Co-authored-by: abacus_fixer <mohanchen@pku.eud.cn>1 parent 1b3baf0 commit 196d199
18 files changed
Lines changed: 1879 additions & 1718 deletions
File tree
- source
- source_esolver
- source_estate
- source_lcao
- source_pw
- module_ofdft
- module_pwdft
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| |||
83 | 90 | | |
84 | 91 | | |
85 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
86 | 96 | | |
87 | 97 | | |
88 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
723 | 723 | | |
724 | 724 | | |
725 | 725 | | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
726 | 729 | | |
| 730 | + | |
| 731 | + | |
727 | 732 | | |
728 | 733 | | |
729 | 734 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
75 | | - | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
91 | | - | |
| 92 | + | |
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
379 | 380 | | |
380 | 381 | | |
381 | 382 | | |
382 | | - | |
| 383 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | 54 | | |
| |||
0 commit comments