Skip to content

Conversation

@paveltomin
Copy link
Collaborator

@paveltomin paveltomin commented Sep 25, 2025

this is preparatory cleanup for fixing #3823
in setupSystem, matrix pattern build is moved into a separate function to allow code re-use and calling pattern build separately from full setup
merged changes from #3839

@paveltomin paveltomin requested a review from Copilot September 25, 2025 20:37
Copy link

Copilot AI left a 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.

Comment on lines 235 to 239
if( m_useStaticCondensation )
{
SolidMechanicsLagrangianFEM::setSparsityPattern( domain, dofManager, pattern );
return;
}
Copy link

Copilot AI Sep 25, 2025

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.

Copilot uses AI. Check for mistakes.

// Add the number of nonzeros induced by coupling
this->addCouplingNumNonzeros( domain, dofManager, rowLengths.toView() );
addCouplingNumNonzeros( domain, dofManager, rowLengths.toView());
Copy link

Copilot AI Sep 25, 2025

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.

Copilot uses AI. Check for mistakes.
solution.setName( this->getName() + "/solution" );
solution.create( dofManager.numLocalDofs(), MPI_COMM_GEOS );

addCouplingSparsityPattern( domain, dofManager, pattern.toView());
Copy link

Copilot AI Sep 25, 2025

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.

Suggested change
addCouplingSparsityPattern( domain, dofManager, pattern.toView());
addCouplingSparsityPattern(domain, dofManager, pattern.toView());

Copilot uses AI. Check for mistakes.
@paveltomin paveltomin added type: cleanup / refactor Non-functional change (NFC) flag: ready for review flag: no rebaseline Does not require rebaseline labels Sep 26, 2025
@paveltomin
Copy link
Collaborator Author

this is ready for review

Comment on lines 1212 to 1216
void PhysicsSolverBase::setSparsityPattern( DomainPartition & GEOS_UNUSED_PARAM( domain ),
DofManager & dofManager,
SparsityPattern< globalIndex > & pattern )
{
dofManager.setSparsityPattern( pattern );
Copy link
Contributor

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.

@paveltomin paveltomin changed the title refactor: clean up set sparsity pattern logic fix: clean up set sparsity pattern logic Sep 29, 2025
@paveltomin paveltomin changed the title fix: clean up set sparsity pattern logic fix: clean up set sparsity pattern logic + matrix setup for poromechanics with contact and wells Sep 29, 2025
@paveltomin paveltomin added the ci: run CUDA builds Allows to triggers (costly) CUDA jobs label Sep 29, 2025
@paveltomin paveltomin merged commit 85f0714 into develop Sep 30, 2025
25 of 26 checks passed
@paveltomin paveltomin deleted the pt/set-pattern branch September 30, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci: run CUDA builds Allows to triggers (costly) CUDA jobs ci: run integrated tests Allows to run the integrated tests in GEOS CI flag: no rebaseline Does not require rebaseline flag: ready for review type: cleanup / refactor Non-functional change (NFC)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants