Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minor HYPRE and ADIOS2 compilation issues #3022

Open
wants to merge 24 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ee90bee
CI: Enable HYPRE in builds
ZedThree Nov 7, 2024
e8adc3f
Fix use of private variable in HYPRE laplace solver
ZedThree Nov 7, 2024
403fd19
Delete (unused) duplicate private function
ZedThree Nov 7, 2024
ff63ff8
CMake: Error if ADIOS2 requested and not found
ZedThree Nov 7, 2024
171b7ae
Fix missing parameter from overridden virtual function
ZedThree Nov 7, 2024
237207b
CI: Fix ADIOS2 build not finding ADIOS2
ZedThree Nov 7, 2024
c3c7f46
CMake: Fix FindHYPRE for non-CMake builds
ZedThree Nov 7, 2024
ae8840a
Apply clang-format changes
ZedThree Nov 7, 2024
6398368
Fix hypre3d laplace solver for 3D metrics
ZedThree Nov 8, 2024
d23cff8
Fix a bunch of clang-tidy issues
ZedThree Nov 8, 2024
9c1cfc9
Remove a couple of unused private members
ZedThree Nov 8, 2024
31567f9
Hypre3D Laplacian: Save diagnostics using outputVars
bendudson Jan 9, 2025
9e765b6
ParallelTransform: Add missing space in error message
bendudson Jan 9, 2025
90332a8
BoundaryFactory: Fix default for parallel boundary regions
bendudson Jan 9, 2025
dc3b020
elm-pb example: Fix hypre input, save performance metrics
bendudson Jan 9, 2025
f46d0a6
Apply clang-format changes
bendudson Jan 9, 2025
6e1bd45
Merge branch 'next' into fix-hypre
bendudson Jan 17, 2025
07603f0
Disable hypre with 3D metrics
bendudson Jan 17, 2025
0012914
Testing: Missed 3D + hypre combination
bendudson Jan 17, 2025
e3a4e1e
OptionsNetCDF: verifyTimesteps, write override base class
bendudson Jan 17, 2025
a188682
tests/integrated: Fix hypre tests
bendudson Jan 17, 2025
9d8cae1
hypre_interface: Add print() method to HypreMatrix
bendudson Jan 17, 2025
518bd4b
Merge branch 'next-hypre3d-laplace' into fix-hypre
bendudson Jan 17, 2025
99bce95
Apply clang-format changes
bendudson Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ jobs:
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_HYPRE=OFF
-DBOUT_USE_ADIOS2=ON
-DBOUT_ENABLE_PYTHON=ON
-DADIOS2_ROOT=/home/runner/local/adios2
-DADIOS2_ROOT=/home/runner/local
-DSUNDIALS_ROOT=/home/runner/local
-DPETSC_DIR=/home/runner/local/petsc
-DSLEPC_DIR=/home/runner/local/slepc"
Expand All @@ -74,6 +75,7 @@ jobs:
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_HYPRE=ON
-DSUNDIALS_ROOT=/home/runner/local"
on_cron: false

Expand All @@ -86,6 +88,7 @@ jobs:
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_HYPRE=ON
-DSUNDIALS_ROOT=/home/runner/local"
on_cron: false

Expand All @@ -97,6 +100,7 @@ jobs:
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_HYPRE=ON
-DBOUT_BUILD_DOCS=OFF
-DSUNDIALS_ROOT=/home/runner/local"
omp_num_threads: 2
Expand All @@ -110,6 +114,7 @@ jobs:
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_HYPRE=OFF
-DBOUT_ENABLE_PYTHON=ON
-DSUNDIALS_ROOT=/home/runner/local"
omp_num_threads: 2
Expand All @@ -123,6 +128,7 @@ jobs:
-DBOUT_USE_PETSC=ON
-DBOUT_USE_SLEPC=ON
-DBOUT_USE_SUNDIALS=ON
-DBOUT_USE_HYPRE=OFF
-DBOUT_ENABLE_PYTHON=ON
-DSUNDIALS_ROOT=/home/runner/local
-DPETSC_DIR=/home/runner/local/petsc
Expand Down Expand Up @@ -178,6 +184,7 @@ jobs:
slepc-dev
liblapack-dev
libparpack2-dev
libhypre-dev

- uses: actions/checkout@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion cmake/FindHYPRE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ include(FindPackageHandleStandardArgs)

find_package(HYPRE CONFIG QUIET)
if (HYPRE_FOUND)
message(STATUS "Found HYPRE: ${HYPRE_VERSION}")
return()
endif()

find_path(HYPRE_INCLUDE_DIR
NAMES HYPRE.h
DOC "HYPRE include directories"
REQUIRED
PATH_SUFFIXES include
PATH_SUFFIXES include include/hypre
)

find_library(HYPRE_LIBRARY
Expand Down
14 changes: 5 additions & 9 deletions cmake/SetupBOUTThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ endif()
message(STATUS "NetCDF support: ${BOUT_USE_NETCDF}")
set(BOUT_HAS_NETCDF ${BOUT_USE_NETCDF})

option(BOUT_USE_ADIOS2 "Enable support for ADIOS output" ON)
option(BOUT_USE_ADIOS2 "Enable support for ADIOS output" OFF)
option(BOUT_DOWNLOAD_ADIOS2 "Download and build ADIOS2" OFF)
if (BOUT_USE_ADIOS2)
if (BOUT_DOWNLOAD_ADIOS2)
Expand All @@ -214,14 +214,10 @@ if (BOUT_USE_ADIOS2)
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi)
message(STATUS "ADIOS2 done configuring")
else()
find_package(ADIOS2)
if (ADIOS2_FOUND)
ENABLE_LANGUAGE(C)
find_package(MPI REQUIRED COMPONENTS C)
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi MPI::MPI_C)
else()
set(BOUT_USE_ADIOS2 OFF)
endif()
find_package(ADIOS2 REQUIRED)
enable_language(C)
find_package(MPI REQUIRED COMPONENTS C)
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi MPI::MPI_C)
endif()
endif()
message(STATUS "ADIOS2 support: ${BOUT_USE_ADIOS2}")
Expand Down
59 changes: 15 additions & 44 deletions examples/elm-pb/data-hypre/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@

nout = 40 # number of time-steps
timestep = 1 # time between outputs
wall_limit = 1.55 # wall time limit (in hours)

zperiod = 15 # Fraction of a torus to simulate
MZ = 16 # Number of points in Z

grid = "cbm18_dens8.grid_nx68ny64.nc" # Grid file

dump_format = "nc" # Dump file format. "nc" = NetCDF, "pdb" = PDB
restart_format = "nc" # Restart file format

[mesh]

staggergrids = false # Use staggered grids

[mesh:paralleltransform]

type = shifted # Use shifted metric method
type = shiftedinterp

##################################################
# derivative methods

[mesh:ddx]

first = C4 # order of first x derivatives
second = C4 # order of second x derivatives
upwind = W3 # order of upwinding method W3 = Weno3
Expand All @@ -44,20 +38,6 @@ first = C4 # Z derivatives can be done using FFT
second = C4
upwind = W3

[output]
shiftoutput = true # Put the output into field-aligned coordinates

##################################################
# Laplacian inversion routines

[laplace]
type=hypre3d

flags = 0 # Flags for Laplacian inversion

rtol = 1.e-9
atol = 1.e-14

##################################################
# FFTs

Expand All @@ -71,15 +51,12 @@ fft_measurement_flag = measure # If using FFTW, perform tests to determine fast
[solver]

# mudq, mldq, mukeep, mlkeep preconditioner options
atol = 1e-08 # absolute tolerance
rtol = 1e-05 # relative tolerance
atol = 1.0e-8 # absolute tolerance
rtol = 1.0e-5 # relative tolerance

use_precon = false # Use preconditioner: User-supplied or BBD
use_jacobian = false # Use user-supplied Jacobian

mxstep = 5000 # Number of internal steps between outputs
adams_moulton = false # Use Adams-Moulton method (default is BDF)
func_iter = false # Functional iteration (default is Newton)

##################################################
# settings for high-beta reduced MHD
Expand Down Expand Up @@ -116,7 +93,7 @@ diamag_phi0 = true # Balance ExB against Vd for stationary equilibrium
bm_exb_flag = 0
bm_mag_flag = 0
##################################################################
withflow = false # With flow or not
withflow = false # With flow or not
D_0 = 130000 # differential potential
D_s = 20 # shear parameter
K_H_term = false # Contain K-H term
Expand All @@ -125,8 +102,8 @@ x0 = 0.855 # peak location
D_min = 3000 # constant
##################################################################

eHall = false # Include electron pressue effects in Ohm's law?
AA = 2.0 # ion mass in units of proton mass
eHall = false # Include electron pressure effects in Ohm's law?
AA = 2.0 # ion mass in units of proton mass

noshear = false # zero all shear

Expand Down Expand Up @@ -174,14 +151,14 @@ damp_t_const = 1e-2 # Damping time constant

## Parallel pressure diffusion

diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_p4 = -1e-05 # parallel hyper-viscous diffusion for pressure (< 0 = none)
diffusion_u4 = 1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_a4 = -1e-05 # parallel hyper-viscous diffusion for vector potential (< 0 = none)

## heat source in pressure in watts

heating_P = -1 # heat power in watts (< 0 = none)
heating_P = -1 # heat power in watts (< 0 = none)
hp_width = 0.1 # heat width, in percentage of nx (< 0 = none)
hp_length = 0.3 # heat length in percentage of nx (< 0 = none)

Expand All @@ -205,22 +182,19 @@ su_lengthr = 0.1 # right edge sink length in percentage of nx (< 0 = none)
## Viscosity and Hyper-viscosity

viscos_par = -0.1 # Parallel viscosity (< 0 = none)
viscos_perp = -1.0 # Perpendicular
viscos_perp = -1.0 # Perpendicular viscosity (< 0 = none)
hyperviscos = -1.0 # Radial hyper viscosity

## Compressional terms (only when compress = true)
phi_curv = true # Include curvature*Grad(phi) in P equation
# gamma = 1.6666

[phiSolver]
#inner_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
#outer_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
inner_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
outer_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
type = hypre3d
inner_boundary_flags = 0 # Dirichlet
outer_boundary_flags = 0 # Dirichlet

[aparSolver]
#inner_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
#outer_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
inner_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
outer_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP

Expand Down Expand Up @@ -271,12 +245,9 @@ bndry_ydown = free_o3
# Zero gradient in the core
bndry_core = neumann

[Vpar]

bndry_core = neumann

[phi]

bndry_xin = none
bndry_xout = none
bndry_target = neumann
#bndry_target = neumann

10 changes: 5 additions & 5 deletions examples/elm-pb/data/BOUT.inp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ diamag_phi0 = true # Balance ExB against Vd for stationary equilibrium
bm_exb_flag = 0
bm_mag_flag = 0
##################################################################
withflow = false # With flow or not
withflow = false # With flow or not
D_0 = 130000 # differential potential
D_s = 20 # shear parameter
K_H_term = false # Contain K-H term
Expand All @@ -104,7 +104,7 @@ D_min = 3000 # constant
##################################################################

eHall = false # Include electron pressure effects in Ohm's law?
AA = 2.0 # ion mass in units of proton mass
AA = 2.0 # ion mass in units of proton mass

noshear = false # zero all shear

Expand Down Expand Up @@ -152,14 +152,14 @@ damp_t_const = 1e-2 # Damping time constant

## Parallel pressure diffusion

diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
diffusion_p4 = -1e-05 # parallel hyper-viscous diffusion for pressure (< 0 = none)
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
diffusion_a4 = -1e-05 # parallel hyper-viscous diffusion for vector potential (< 0 = none)

## heat source in pressure in watts

heating_P = -1 # heat power in watts (< 0 = none)
heating_P = -1 # heat power in watts (< 0 = none)
hp_width = 0.1 # heat width, in percentage of nx (< 0 = none)
hp_length = 0.3 # heat length in percentage of nx (< 0 = none)

Expand Down
3 changes: 3 additions & 0 deletions examples/elm-pb/elm_pb.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,9 @@ class ELMpb : public PhysicsModel {

// Create a solver for the Laplacian
phiSolver = Laplacian::create(&globalOptions["phiSolver"]);
// Save performance metrics to output, using the
// given name as the prefix.
phiSolver->savePerformance(*solver, "phiSolver");

aparSolver = Laplacian::create(&globalOptions["aparSolver"], loc);

Expand Down
23 changes: 21 additions & 2 deletions include/bout/hypre_interface.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,15 @@ public:

bool isAssembled() const { return assembled; }

/// Call HYPRE_IJMatrixPrint
void print() const {
if (!assembled) {
output_warn.write("<HypreMatrix not assembled>");
return;
}
HYPRE_IJMatrixPrint(*hypre_matrix, "hypreIJ.matrix");
}

HypreMatrix<T> yup(int index = 0) { return ynext(index + 1); }
HypreMatrix<T> ydown(int index = 0) { return ynext(-index - 1); }
HypreMatrix<T> ynext(int dir) {
Expand Down Expand Up @@ -894,20 +903,30 @@ public:

void setMaxIter(int max_iter) { checkHypreError(solverSetMaxIter(solver, max_iter)); }

double getFinalRelResNorm() {
double getFinalRelResNorm() const {
HYPRE_Real resnorm{};
checkHypreError(solverGetFinalRelativeResidualNorm(solver, &resnorm));
return resnorm;
}

int getNumItersTaken() {
/// Return the number of solver iterations taken
int getNumItersTaken() const {
HYPRE_Int iters{};
checkHypreError(solverGetNumIterations(solver, &iters));
return iters;
}

/// Return the number of BoomerAMG preconditioner iterations taken
int getNumItersTakenAMG() const {
HYPRE_Int iters{};
checkHypreError(HYPRE_BoomerAMGGetNumIterations(precon, &iters));
return iters;
}

/// Set the HypreMatrix to be used in the solver
void setMatrix(HypreMatrix<T>* A_) { A = A_; }

/// Enable BoomerAMG preconditioner with the given HypreMatrix
int setupAMG(HypreMatrix<T>* P_) {
CALI_CXX_MARK_FUNCTION;

Expand Down
2 changes: 1 addition & 1 deletion include/bout/paralleltransform.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public:
std::vector<PositionsAndWeights>
getWeightsForYApproximation(int UNUSED(i), int UNUSED(j), int UNUSED(k),
int UNUSED(yoffset)) override {
throw BoutException("ParallelTransform::getWeightsForYApproximation not implemented"
throw BoutException("ParallelTransform::getWeightsForYApproximation not implemented "
"for `type = shifted`. Try `type = shiftedinterp`");
}

Expand Down
Loading