Refactor OFDFT line-search status to std::string - #7985
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues remain, and existing behavior is preserved.
Pull request overview
Refactors the OFDFT line-search buffer to use RAII-managed std::array storage while preserving behavior.
Changes:
- Replaces manual allocation with
std::array<char, 60>. - Removes matching allocation and deallocation.
- Updates buffer usage to call
.data().
File summaries
| File | Description |
|---|---|
source/source_esolver/esolver_of.h |
Declares the fixed-size array buffer. |
source/source_esolver/esolver_of.cpp |
Removes manual buffer management. |
source/source_esolver/esolver_of_interface.cpp |
Uses the array buffer through .data(). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mohanchen
reviewed
Sep 17, 2026
mohanchen
approved these changes
Sep 18, 2026
Collaborator
|
Nice try as a first PR, please keep going. @zzlinpku |
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.
What's changed?
The OFDFT line-search status was stored in a manually allocated 60-character buffer. Use
std::stringforESolver_OF::task_and pass it by reference throughOpt_DCsrch::dcSrchand the internaldcsrchfunction. Status writes now use string assignment; prefix checks use C++11-compatiblecompare. This removes manual allocation, fixed-capacity status storage, and raw character writes while preserving status text and numerical logic.Update both existing CG/TN test callers. Add three focused line-search tests for convergence/restart, error-to-short-status replacement, and a maximum-step warning; register them as
MODULE_BASE_opt_dcsrch.Linked Issue
No linked issue: self-contained ownership and status-string cleanup.
Unit Tests and/or Case Tests for my changes
Verified on the branch based on
3d200fd47b67275d2a101ea036b2634d29c29fb9. Local submitted files were SHA-256 matched to the server files.Server build configuration (unchanged):
ENABLE_LCAO=OFF,ENABLE_LIBXC=OFF,ENABLE_LIBRI=OFF,ENABLE_ELPA=OFF.Commands run:
Results:
-57.93385514279088 eV, identical to the prior array version; reference-57.93385514279199 eV; absolute difference about1.108e-12 eV, below1e-8 eV.Focused tests were also compiled locally with Clang, C++11 and GoogleTest 1.12.1:
All 3 tests passed.
Limits:
RI/global/Array_Operator.h; only the stated PW build is claimed.Governance Notes
Opt_DCsrch::dcSrchnow requiresstd::string&rather thanchar*; all in-repository callers are migrated. Out-of-tree callers must adapt. Numerical line-search operations are unchanged.<string>is required for the owned member and the string-reference interface.Reminder