refactor: clean up source_cell/source_estate/source_io reverse dependencies#7521
Merged
mohanchen merged 6 commits intoJun 27, 2026
Conversation
read_atom_species.cpp included source_lcao/module_ri/serialization_cereal.h (guarded by __EXX) but uses no cereal/serialization symbols. Removing it cuts a source_cell -> source_lcao reverse dependency edge. Add the direct <sstream> include the file actually needs (std::stringstream), which was previously only available transitively through the cereal header. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Magnetism class only depends on source_base and is held by value as a
member of UnitCell (source_cell/unitcell.h). It is a fundamental property of
the unit cell, so it belongs in source_cell rather than source_estate.
This removes the unitcell.h -> source_estate header dependency (a core data
structure no longer reaches up into the electronic-state module) and breaks
one direction of the source_cell <-> source_estate cycle.
- git mv source_estate/magnetism.{h,cpp} -> source_cell/
- update all includers to source_cell/magnetism.h
- move the source file entry between CMakeLists and fix the unit-test path
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The `output` class (output.{h,cpp}) is a pure formatter that only operates on
source_base types (realArray, matrix, matrix3, ComplexMatrix). It was sitting
in source_io/module_output but has no dependency on anything above source_base,
so it belongs in source_base as a leaf utility.
Relocating it removes a batch of source_cell -> source_io (and source_pw/
source_psi -> source_io) reverse edges that existed only to reach this printer,
without changing any behavior or namespace.
- git mv source_io/module_output/output.{h,cpp} -> source_base/
- fix the relocated header's own includes (drop ../../source_base/ prefix)
- repoint all includers to source_base/output.h
- move the source entry from source_io to source_base CMakeLists and update
the relative output.cpp paths in all affected unit-test CMakeLists
Verified: full abacus_basic_para executable builds and links cleanly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e8ac89c to
7e5acaa
Compare
…move-dead-cereal-include
…-include' into refactor/cell-remove-dead-cereal-include
Growl1234
added a commit
to Growl1234/abacus-develop
that referenced
this pull request
Jun 27, 2026
Growl1234
added a commit
to Growl1234/abacus-develop
that referenced
this pull request
Jun 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
Linked Issue
N/A — standalone refactor of the module dependency graph.
What's changed?
While auditing the cross-module
#includegraph undersource/source_*, I found several cases where a lower-level module depended upward on a higher-level one, creating unnecessary reverse edges in the module dependency DAG. This PR removes three of them. Each change is an isolated, mechanical move with no behavioral / numerical change — only file locations,#includepaths, and CMake source lists are touched. The relevant code is already covered by existing unit tests.1. Remove a dead
source_lcaoinclude fromsource_cellsource_cell/read_atom_species.cppcarried a dead block:Nothing in the file uses it — it was a spurious
cell → lcaoreverse edge. Removed it and added the#include <sstream>the file actually relies on (std::stringstream, previously only available transitively).2. Move
Magnetismfromsource_estate→source_cellsource/{source_estate => source_cell}/magnetism.{h,cpp}(100% rename). TheMagnetismclass only depends onsource_baseand is held by value as a member ofUnitCell(unitcell.h). Living insource_estateforced acell → estatereverse edge. Repointed all includers and updated the CMake/test source lists.3. Move the
outputprint helpers fromsource_io/module_output→source_basesource/{source_io/module_output => source_base}/output.{h,cpp}(rename).class outputis a pure formatter overModuleBasetypes (realArray,matrix,matrix3,ComplexMatrix) with no dependency abovesource_base. Sitting insource_ioforced severalcell/pw/psi → ioreverse edges. Repointed all includers, fixed the header's own internal includes, and updated the main + test CMake source lists.Test build adjustments (consequence of moving
outputintobase):Because
output.cppis now part of thebaseOBJECT library that nearly every test links, two stale patterns had to be cleaned up to avoid duplicate-symbol errors:output.cppentries frombase-linked testSOURCESlists (kept where a test hand-compilessource_base/*.cppand does not linkbase, e.g.source_md/test).output::printM3/printrmmock stubs from a few tests (symmetry_test_*,to_qo_test,read_atoms_helper_test,psi_initializer_unit_test); the realbaseimplementation now provides those symbols. Each test's still-neededMagnetism/InfoNonlocalmocks were left intact.Any changes of core modules? (ignore if not applicable)
No functional change to ElecState/Hamilt/Psi/etc.
Magnetism(used byElecStateandUnitCell) and theoutputprinter are physically relocated to lower-level modules, but their interfaces and behavior are unchanged; all call sites only have their#includepaths updated.Verification
-DBUILD_TESTING=ON(gcc/OpenMPI, LCAO enabled): 0 errors, all targets + unit-test executables link, including the fullabacus_*binary.source_estate/magnetism.horsource_io/module_output/output.{h,cpp}paths.Makefile.Objectsuses VPATH, so object names resolve regardless of whichsource_*directory a file lives in.🤖 Generated with Claude Code