Skip to content

Block structure - #119

Open
maxpaik16 wants to merge 3 commits into
mainfrom
block-structure
Open

Block structure#119
maxpaik16 wants to merge 3 commits into
mainfrom
block-structure

Conversation

@maxpaik16

Copy link
Copy Markdown
Contributor

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.

maxpaik16 and others added 3 commits September 9, 2026 16:28
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

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.80247% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.34%. Comparing base (1983e44) to head (ecb86ee).

Files with missing lines Patch % Lines
src/polysolve/linear/CPUHybridSolver.cpp 0.00% 33 Missing ⚠️
src/polysolve/linear/HypreSolver.cpp 20.00% 8 Missing ⚠️
src/polysolve/nonlinear/Solver.cpp 53.84% 6 Missing ⚠️
.../polysolve/nonlinear/descent_strategies/Newton.cpp 84.61% 2 Missing ⚠️
src/polysolve/linear/Solver.hpp 0.00% 1 Missing ⚠️
src/polysolve/nonlinear/Problem.hpp 50.00% 1 Missing ⚠️
...rc/polysolve/nonlinear/descent_strategies/BFGS.cpp 80.00% 1 Missing ⚠️

❌ 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     
Flag Coverage Δ
polysolve 78.34% <35.80%> (-2.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant