Skip to content

[WIP] Allow Hypre MLMG bottom solver - #7223

Open
roelof-groenewald wants to merge 2 commits into
BLAST-WarpX:developmentfrom
roelof-groenewald:hypre_mlmg_bottom_solver
Open

[WIP] Allow Hypre MLMG bottom solver#7223
roelof-groenewald wants to merge 2 commits into
BLAST-WarpX:developmentfrom
roelof-groenewald:hypre_mlmg_bottom_solver

Conversation

@roelof-groenewald

@roelof-groenewald roelof-groenewald commented Aug 28, 2026

Copy link
Copy Markdown
Member

This PR allows setting the bottom solve in the MLMG iterative solver to use the Hypre library. It also exposes several other bottom solve settings that can be used to help optimize the Poisson solver for a given problem.

Needs:

Closes #7210.

roelof-groenewald and others added 2 commits August 26, 2026 15:06
Adds a `WarpX_HYPRE` build option (mirroring `WarpX_PETSC`) which enables
`AMReX_HYPRE`, and plumbs the AMReX MLMG bottom solver settings through the
electrostatic solvers so that HYPRE (BoomerAMG) can be used for the solve on
the coarsest multigrid level.

The new options are collected in `ablastr::fields::MLMGOptions` and are
exposed as

    warpx.self_fields_bottom_solver
    warpx.self_fields_bottom_verbosity
    warpx.self_fields_bottom_max_iters
    warpx.self_fields_bottom_relative_tolerance
    warpx.self_fields_bottom_absolute_tolerance
    warpx.self_fields_max_coarsening_level

with matching PICMI keyword arguments. HYPRE's own options are read by AMReX
from the `hypre` input file namespace, for which a `pywarpx.hypre` bucket is
added.

A strong bottom solver only pays off when the coarsest multigrid level is
still a sizeable problem, which is why the coarsening depth is exposed as
well.

HYPRE is currently not supported for the embedded boundary and RZ solves,
since `amrex::MLEBNodeFDLaplacian` does not implement `fillIJMatrix`/`fillRHS`
yet; requesting it there (or without a HYPRE build, or in 1D) now aborts with
a descriptive message.

Adds `test_3d_electrostatic_sphere_lab_frame_hypre`, gated on `WarpX_HYPRE`,
which limits the coarsening depth so that the bottom solve is a non-trivial
problem.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
amrex::MLEBNodeFDLaplacian can now assemble its matrix, so the guard only
needs to reject RZ, where the radial metrics are still missing.

Adds test_3d_electrostatic_sphere_eb_mixed_bc_hypre, a copy of the mixed
PEC/Neumann embedded-boundary sphere test that caps coarsening so the HYPRE
bottom solve is a real problem.  Its checksums agree with the non-HYPRE test
to 2e-11.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@roelof-groenewald
roelof-groenewald requested a review from n01r August 28, 2026 21:19
@RemiLehe

RemiLehe commented Aug 30, 2026

Copy link
Copy Markdown
Member

As a side-note, when running this on GPU, I observed that running with the hypre solver triggered CPU-GPU copies that resulted in a slow bottom solve:

Screenshot 2026-08-30 at 10 48 45 AM

For the record, here is how I configured Hypre and WarpX:

git clone https://github.com/hypre-space/hypre.git
cd hypre
git checkout v3.2.0          # tag -> detached HEAD at 6bbcd4c3e

conda run -n warpx-cpu-mpich-dev cmake \
  -S $HOME/codes/hypre/src \
  -B $HOME/codes/hypre/build \
  -DCMAKE_INSTALL_PREFIX=$HOME/codes/hypre/install \
  -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
  -DHYPRE_ENABLE_MPI=ON \
  -DHYPRE_ENABLE_CUDA=ON \
  -DHYPRE_ENABLE_UNIFIED_MEMORY=ON \
  -DCMAKE_CUDA_ARCHITECTURES=80 \
  -DHYPRE_ENABLE_BIGINT=OFF -DHYPRE_ENABLE_MIXEDINT=OFF \
  -DHYPRE_ENABLE_CUSOLVER=OFF -DHYPRE_ENABLE_CUBLAS=OFF \
  -DHYPRE_ENABLE_UMPIRE=OFF

conda run -n warpx-cpu-mpich-dev cmake --build build -j 4 --target install
cd warpx

git fetch https://github.com/roelof-groenewald/WarpX.git hypre_mlmg_bottom_solver
git checkout -B hypre_mlmg_bottom_solver FETCH_HEAD   # -> 36b14d04d

conda run -n warpx-cpu-mpich-dev cmake -S . -B build_hypre_cuda \
  -DWarpX_DIMS=3 \
  -DWarpX_COMPUTE=CUDA \
  -DAMReX_CUDA_ARCH=8.0 \
  -DWarpX_HYPRE=ON \
  -DAMReX_HYPRE=ON \
  -DHYPRE_ROOT=$HOME/codes/hypre/install/ \
  -DWarpX_amrex_repo=https://github.com/roelof-groenewald/amrex.git \
  -DWarpX_amrex_branch=ebnodefdlap_hypre

conda run -n warpx-cpu-mpich-dev cmake -S . -B build_hypre_cuda \
  -C $HOME/codes/hypre_cuda_link_fix.cmake

conda run -n warpx-cpu-mpich-dev cmake --build build_hypre_cuda -j 4

@roelof-groenewald

Copy link
Copy Markdown
Member Author

Thanks for the note @RemiLehe. We (@n01r and I) are still wondering whether the -DHYPRE_ENABLE_UMPIRE=OFF is what causes the large amount of CPU-GPU copies. But we haven't been able to test that yet.

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.

MLMG "Bottom solve failed" + spurious transverse E-field with EB electrodes and Neumann/periodic BCs

2 participants