Skip to content

Roy/saddle point preconditioning - #1598

Open
tlroy wants to merge 16 commits into
developfrom
roy/saddle_point_preconditioning
Open

Roy/saddle point preconditioning#1598
tlroy wants to merge 16 commits into
developfrom
roy/saddle_point_preconditioning

Conversation

@tlroy

@tlroy tlroy commented May 6, 2026

Copy link
Copy Markdown
Contributor
  • Correctly handles AMG vdim for block preconditioning
  • Mixed Poisson example with saddle point schur preconditioning

To be merged after tupek/system_solver #1556

@tlroy
tlroy requested review from btalamini, lihanyu97 and tupek2 May 6, 2026 17:22
@tlroy tlroy added the enhancement New feature or request label May 6, 2026
@chapman39

Copy link
Copy Markdown
Collaborator

@lc-hubcast run pipeline

@lc-hubcast

lc-hubcast Bot commented Jun 9, 2026

Copy link
Copy Markdown

I've started a new pipeline for you!

@chapman39

Copy link
Copy Markdown
Collaborator

@lc-hubcast approve

@lc-hubcast

lc-hubcast Bot commented Jun 9, 2026

Copy link
Copy Markdown

To approve the sync of this PR, please use the GitHub review comment feature to submit an approval. This ensures the approval is tied to a specific commit to avoid unintended syncing of malicious commits.

@chapman39 chapman39 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lc-hubcast approve

@tlroy tlroy added the ready for review Ready for active inspection by reviewers label Jun 11, 2026

HYPRE_Int GetBoomerAMGNumFunctions(const mfem::HypreBoomerAMG& amg)
{
HYPRE_Solver h = amg; // mfem::HypreBoomerAMG has operator HYPRE_Solver()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a deep copy or shallow copy?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tupek2 Shallow copy

@tlroy
tlroy requested a review from tupek2 August 3, 2026 16:52
mfem::DenseMatrix inv_;
};

class GuessSensitiveIterativeSolver : public mfem::IterativeSolver {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a odd name for this class. NoOpIterativeSolver, or something like that? Also, comment to explain why it returns nan if iterative_mode.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the goal for moving SolverWithPreconditioner out of equation_solver.cpp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it can easily be included elsewhere

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a base class BlockPreconditioner that inherits mfem::Solver and owns member functions like numSubSolvers and subSolvers (essentially common member functions shared by different types of block preconditioners). It should also own shared member variables like block_offsets_. Then the specific type of block preconditioner will inherit this base class. For example class BlockDiagonalPreconditioner : public BlockPreconditioner

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lihanyu97 That's a good point. I added a base class in my latest commit. It reduces repetition.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks good. It looks like you have to document the member functions and variables in the base class in order to pass the test. Other than that, the PR is good.

Comment on lines +119 to +145
struct BlockSolverAccessor {
int n = 0;
mfem::Solver* (*get)(void*, int) = nullptr;
void* self = nullptr;
};

const BlockSolverAccessor acc = [&]() {
if (auto* p = dynamic_cast<smith::BlockDiagonalPreconditioner*>(mfem_solver)) {
return BlockSolverAccessor{p->numSubSolvers(), static_cast<mfem::Solver* (*)(void*, int)>([](void* self, int i) {
return static_cast<smith::BlockDiagonalPreconditioner*>(self)->subSolver(i);
}),
p};
}
if (auto* p = dynamic_cast<smith::BlockTriangularPreconditioner*>(mfem_solver)) {
return BlockSolverAccessor{p->numSubSolvers(), static_cast<mfem::Solver* (*)(void*, int)>([](void* self, int i) {
return static_cast<smith::BlockTriangularPreconditioner*>(self)->subSolver(i);
}),
p};
}
if (auto* p = dynamic_cast<smith::BlockSchurPreconditioner*>(mfem_solver)) {
return BlockSolverAccessor{p->numSubSolvers(), static_cast<mfem::Solver* (*)(void*, int)>([](void* self, int i) {
return static_cast<smith::BlockSchurPreconditioner*>(self)->subSolver(i);
}),
p};
}
return BlockSolverAccessor{};
}();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would not be necessary once the base block preconditioner class is defined.


if (acc.get) {
for (int i = 0; i < acc.n && static_cast<size_t>(i) < us.size(); ++i) {
configure_amg(acc.get(acc.self, i), us[static_cast<size_t>(i)]->space().GetVDim());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would become

Suggested change
configure_amg(acc.get(acc.self, i), us[static_cast<size_t>(i)]->space().GetVDim());
configure_amg(block_preconditioner.subSolver(i), us[static_cast<size_t>(i)]->space().GetVDim());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ready for review Ready for active inspection by reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants