Skip to content

Commit f7b3111

Browse files
Critsium-xyclaude
andauthored
Refactor: remove some unhealthy include dependencies (deepmodeling#7512)
* refactor(pw): remove dead esolver include from hamilt_pw.h HamiltPW does not reference any ESolver symbol; the include of source_esolver/esolver_ks_pw.h was unused. Removing it cuts the only source_pw -> source_esolver back-edge (an operator header depending on its driver) and drops 15 transitively-included headers from every consumer of hamilt_pw.h (fan 114 -> 99). All types named in the header (UnitCell, ModulePW::PW_Basis_K, etc.) remain provided by klist.h / vnl_pw.h -> structure_factor.h. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * refactor(surchem): forward-declare pw types in surchem.h Structure_Factor and Parallel_Grid are used in surchem.h only as pointer/reference parameters, so replace the heavy source_pw includes with forward declarations. This cuts the hamilt -> pw back-edge from surchem.h (hamilt->pw edge 4 -> 2) and drops 6 transitively-included headers from surchem.h's closure (54 -> 48), benefiting its ~160 transitive consumers. Two consumers relied on the transitive include and now include it directly (include-what-you-use): - esolver_fp.h: has a Parallel_Grid value member -> add parallel_grid.h - forces.cpp: accesses p_sf->strucFac -> add structure_factor.h Other surchem.h consumers use these types only via pointer/reference and are covered by the forward declarations; verified the remaining parallel_grid.h users still reach it through other includes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(surchem): include structure_factor.h in cal_pseudo.cpp cal_pseudo.cpp dereferences Structure_Factor (sf->strucFac) but only included surchem.h, which now forward-declares the type. Add the direct include so the complete type is available. Fixes the CI build error "invalid use of incomplete type 'class Structure_Factor'". Verified via closure analysis that this is the only remaining file in surchem.h's affected set that requires the complete type; all other consumers use Structure_Factor / Parallel_Grid by pointer or reference. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * style(surchem): drop verbose comment on forward declarations Match the house style used across the codebase (e.g. makov_payne.h, exx_helper_base.h, cube_io.h), where forward declarations are bare `class Foo;` lines without an explanatory comment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * style(surchem): add a one-line note on the forward declarations Brief comment explaining why the source_pw types are forward-declared (pointer/reference use only) so the includes are not re-added later. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 777f50c commit f7b3111

5 files changed

Lines changed: 8 additions & 3 deletions

File tree

source/source_esolver/esolver_fp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "source_estate/elecstate.h" // electronic states
1010
#include "source_estate/module_charge/charge_extra.h" // charge extrapolation
1111
#include "source_hamilt/module_surchem/surchem.h" // solvation model
12+
#include "source_pw/module_pwdft/parallel_grid.h" // Parallel_Grid (value member below)
1213
#include "source_pw/module_pwdft/vl_pw.h" // local pseudopotential
1314
#include "source_pw/module_pwdft/structure_factor.h" // structure factor
1415

source/source_hamilt/module_surchem/cal_pseudo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "surchem.h"
22

3+
#include "source_pw/module_pwdft/structure_factor.h" // Structure_Factor member access (sf->strucFac)
4+
35
// atom_in surchem::GetAtom;
46

57
void surchem::gauss_charge(const UnitCell& cell,

source/source_hamilt/module_surchem/surchem.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
#include "source_base/matrix.h"
77
#include "source_basis/module_pw/pw_basis.h"
88
#include "source_cell/unitcell.h"
9-
#include "source_pw/module_pwdft/parallel_grid.h"
10-
#include "source_pw/module_pwdft/structure_factor.h"
9+
10+
// forward-declared: used below only as pointer/reference
11+
class Parallel_Grid;
12+
class Structure_Factor;
1113

1214
class surchem
1315
{

source/source_pw/module_pwdft/forces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "source_estate/module_pot/gatefield.h"
1818
#include "source_hamilt/module_ewald/H_Ewald_pw.h"
1919
#include "source_hamilt/module_surchem/surchem.h"
20+
#include "source_pw/module_pwdft/structure_factor.h" // Structure_Factor member access (p_sf->strucFac)
2021
#include "source_hamilt/module_vdw/vdw.h"
2122

2223
#ifdef _OPENMP

source/source_pw/module_pwdft/hamilt_pw.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "source_base/kernels/math_kernel_op.h"
55
#include "source_base/macros.h"
66
#include "source_cell/klist.h"
7-
#include "source_esolver/esolver_ks_pw.h"
87
#include "source_estate/module_pot/potential_new.h"
98
#include "source_hamilt/hamilt.h"
109
#include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06

0 commit comments

Comments
 (0)