Skip to content

Conversation

brbass
Copy link
Contributor

@brbass brbass commented Aug 25, 2025

Summary

This PR adds linear solvers to Spheral. This supersedes the previous PR (#346), which was inefficient in both the matrix fill and factorization.

  • Any data needed for the matrix fill needed to be requested for each row instead of once.
  • The factorization was being done every time the matrix was solved rather than being done once when the matrix is done being filled.
  • When filling the vectors with data, a copy needed to be made instead of just giving the pointer to the first element of the Field.
  • When the connectivity did not change but the data did, the entire matrix was scrapped, causing a costly reallocation of memory.

The basic usage of these new solvers is:

  • Call initialize to create the matrices and vectors
  • Start filling the matrix with beginFill
  • Fill the matrix all at once with setMatRows or by row with setMatRow
  • Call assemble when fill is complete to assemble the matrix
  • Call finalize after assembly to create solvers and preconditioners
  • Each time the solver will be used:
    • Set the RHS to the source and optionally the LHS to the guess with set
    • Call solve or multiply
    • Retrieve the LHS with get

This PR probably depends on and should be merged after #405 due to the changes to FlatConnectivity .


ToDo :

  • Annotate RELEASE_NOTES.md with notable changes.
  • Create LLNLSpheral PR pointing at this branch. (PR#)
  • LLNLSpheral PR has passed all tests.

@jmikeowen jmikeowen requested review from jmikeowen and ldowen August 25, 2025 21:27
@ldowen
Copy link
Collaborator

ldowen commented Aug 25, 2025

Could you change ENABLE_SOLVERS to be SPHERAL_ENABLE_SOLVERS?

@ldowen
Copy link
Collaborator

ldowen commented Aug 25, 2025

Also, would it be possible to add tests for just FlatConnectivity independent of the solvers?

@brbass
Copy link
Contributor Author

brbass commented Aug 26, 2025

Also, would it be possible to add tests for just FlatConnectivity independent of the solvers?

Done!

@brbass
Copy link
Contributor Author

brbass commented Aug 26, 2025

Also, would it be possible to add tests for just FlatConnectivity independent of the solvers?

Yes, good call. FlatConnectivity was originally added along with the KernelIntegrator and is also tested there, but it would be good to make sure it's working correctly on its own!

@brbass
Copy link
Contributor Author

brbass commented Aug 26, 2025

Also, would it be possible to add tests for just FlatConnectivity independent of the solvers?

Yes, good call. FlatConnectivity was originally added along with the KernelIntegrator and is also tested there, but it would be good to make sure it's working correctly on its own!

I added the test for FlatConnectivity to the other PR where I modified it. You can find it there!

@ldowen
Copy link
Collaborator

ldowen commented Aug 27, 2025

I had a few questions for #405 but nothing big.

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.

2 participants