Skip to content

Refactor: remove some unhealthy include dependencies#7512

Open
Critsium-xy wants to merge 5 commits into
deepmodeling:developfrom
Critsium-xy:refactor/remove-dead-esolver-include
Open

Refactor: remove some unhealthy include dependencies#7512
Critsium-xy wants to merge 5 commits into
deepmodeling:developfrom
Critsium-xy:refactor/remove-dead-esolver-include

Conversation

@Critsium-xy

@Critsium-xy Critsium-xy commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

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.

‎source/source_hamilt/module_surchem/surchem.h also get a header removal.

Because the codes are getting complex in some modules, so I'm starting the refactor work from simpler files instead of a whole folder.

Critsium-xy and others added 5 commits June 23, 2026 17:31
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>
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>
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>
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>
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>
@Critsium-xy Critsium-xy changed the title refactor(pw): remove dead esolver include from hamilt_pw.h Refactor: remove some unhealthy include dependencies Jun 23, 2026
@Critsium-xy Critsium-xy marked this pull request as ready for review June 23, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant