Block structure - #119
Open
maxpaik16 wants to merge 3 commits into
Open
Conversation
AMGCL, CPUHybridSolver, GPUHybridSolver, HypreSolver, and MASSolver previously read their block size (block_size/block_dim/dimension) out of the JSON params inside set_parameters. Each now exposes a set_block_size override instead, and set_parameters no longer reads that key (removed from linear-solver-spec.json accordingly). CPUHybridSolver's override broadcasts over MPI like set_parameters does, so worker ranks stay in sync. Solver::create(json, logger, strict_validation) gained a dimension parameter that calls set_block_size before set_parameters. This is threaded through polysolve::nonlinear (Problem::dimension(), Newton, BFGS, and nonlinear::Solver::create) so a nonlinear solver's problem dimension can reach its linear solver's block size. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Wires set_block_mapping(VectorXi) through to HYPRE_BoomerAMGSetDofFunc for HypreSolver, CPUHybridSolver, and GPUHybridSolver, so callers can give BoomerAMG an explicit per-row function assignment instead of relying on its default interleaved (row i -> i % dim) mapping. HYPRE takes ownership of the dof_func array it's given, so it is allocated with hypre_CTAlloc (matching the allocator HYPRE frees it with) rather than new[]/malloc. GPUHybridSolver runs with HYPRE_MEMORY_DEVICE, so the array is built on host and copied to a HYPRE-owned device buffer via hypre_TMemcpy. CPUHybridSolver splits rows across MPI ranks, and HYPRE_BoomerAMGSetDofFunc expects a per-rank local array, so set_block_mapping broadcasts the full mapping to every rank (mirroring the existing set_parameters/ set_block_size broadcast pattern) and each rank slices out its own local rows once factorize() has partitioned them. Adds a block_mapping test that checks an explicit mapping reproducing HYPRE's own default interleaved assignment converges in the same number of iterations as never calling set_block_mapping, for both Hypre and CPUHybrid. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Problem gains block_mapping(), returning an empty VectorXi by default, that a problem subclass can override to report an explicit per-row function (block) assignment. Newton (both sparse and dense solves) and BFGS now check objFunc.block_mapping() before factorizing and call linear_solver->set_block_mapping() when the problem provides one, so a problem-specific mapping reaches the underlying multigrid solver without callers having to wire it through manually. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (35.80%) is below the target coverage (75.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #119 +/- ##
==========================================
- Coverage 80.47% 78.34% -2.13%
==========================================
Files 57 55 -2
Lines 3272 2992 -280
Branches 437 386 -51
==========================================
- Hits 2633 2344 -289
- Misses 639 648 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Remove block dimension from json spec, making it can be set through the code.
Add support for arbitrary block structures to hypre and hybrid solver classes.