-
Notifications
You must be signed in to change notification settings - Fork 97
fix: clean up set sparsity pattern logic + matrix setup for poromechanics with contact and wells #3834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the matrix sparsity pattern setup logic by extracting the pattern creation into a separate virtual method. The change separates concerns between system setup and sparsity pattern creation, allowing derived classes to override only the pattern logic.
Key changes:
- Introduces a new virtual
setSparsityPattern()method across solver classes - Removes redundant destructor implementations
- Updates parameter ordering for consistency (domain before dofManager)
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| PhysicsSolverBase.hpp/.cpp | Adds base setSparsityPattern() method with default implementation |
| SolidMechanicsLagrangianFEM.hpp/.cpp | Extracts sparsity pattern logic and updates setupSystem() signature |
| SolidMechanicsPenaltyContact.hpp/.cpp | Replaces setupSystem() with setSparsityPattern(), removes destructor |
| SolidMechanicsEmbeddedFractures.hpp/.cpp | Refactors to use new pattern method, removes destructor |
| LaplaceFEM.hpp/.cpp | Converts to setSparsityPattern() method, removes destructor |
| Contact solver classes | Updates to new pattern separation approach |
| Multiphysics solver classes | Adopts new sparsity pattern method |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if( m_useStaticCondensation ) | ||
| { | ||
| SolidMechanicsLagrangianFEM::setSparsityPattern( domain, dofManager, pattern ); | ||
| return; | ||
| } |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is inverted. The original code had if( !m_useStaticCondensation ) and executed the custom sparsity pattern logic. Now it's if( m_useStaticCondensation ) but calls the base class method, which reverses the intended behavior.
|
|
||
| // Add the number of nonzeros induced by coupling | ||
| this->addCouplingNumNonzeros( domain, dofManager, rowLengths.toView() ); | ||
| addCouplingNumNonzeros( domain, dofManager, rowLengths.toView()); |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent spacing in method calls. Line 234 has no space before the opening parenthesis, while line 247 has a space. The spacing should be consistent throughout the method.
| solution.setName( this->getName() + "/solution" ); | ||
| solution.create( dofManager.numLocalDofs(), MPI_COMM_GEOS ); | ||
|
|
||
| addCouplingSparsityPattern( domain, dofManager, pattern.toView()); |
Copilot
AI
Sep 25, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Inconsistent spacing in method calls. Line 234 has no space before the opening parenthesis, while line 247 has a space. The spacing should be consistent throughout the method.
| addCouplingSparsityPattern( domain, dofManager, pattern.toView()); | |
| addCouplingSparsityPattern(domain, dofManager, pattern.toView()); |
Removed USE_SCCACHE environment variable from CI workflow.
|
this is ready for review |
| void PhysicsSolverBase::setSparsityPattern( DomainPartition & GEOS_UNUSED_PARAM( domain ), | ||
| DofManager & dofManager, | ||
| SparsityPattern< globalIndex > & pattern ) | ||
| { | ||
| dofManager.setSparsityPattern( pattern ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we may want to adopt a consistent style and chose between GEOS_UNUSED_PARAM and GEOS_UNUSED_VAR.
Added parameter documentation for localMatrix in setSparsityPattern.
this is preparatory cleanup for fixing #3823in
setupSystem, matrix pattern build is moved into a separate function to allow code re-use and calling pattern build separately from full setupmerged changes from #3839