Skip to content

Commit 1a002d2

Browse files
authored
Merge pull request #3022 from boutproject/fix-hypre
Fix minor HYPRE and ADIOS2 compilation issues
2 parents 0b3dc08 + d32c70f commit 1a002d2

23 files changed

Lines changed: 204 additions & 213 deletions

File tree

.github/workflows/tests.yml

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ jobs:
4747
-DBOUT_USE_PETSC=ON
4848
-DBOUT_USE_SLEPC=ON
4949
-DBOUT_USE_SUNDIALS=ON
50+
-DBOUT_USE_HYPRE=OFF
5051
-DBOUT_USE_ADIOS2=ON
5152
-DBOUT_ENABLE_PYTHON=ON
52-
-DADIOS2_ROOT=/home/runner/local/adios2
53+
-DADIOS2_ROOT=/home/runner/local
5354
-DSUNDIALS_ROOT=/home/runner/local
5455
-DPETSC_DIR=/home/runner/local/petsc
5556
-DSLEPC_DIR=/home/runner/local/slepc"
@@ -74,6 +75,7 @@ jobs:
7475
-DBOUT_USE_PETSC=ON
7576
-DBOUT_USE_SLEPC=ON
7677
-DBOUT_USE_SUNDIALS=ON
78+
-DBOUT_USE_HYPRE=ON
7779
-DSUNDIALS_ROOT=/home/runner/local"
7880
on_cron: false
7981

@@ -86,6 +88,7 @@ jobs:
8688
-DBOUT_USE_PETSC=ON
8789
-DBOUT_USE_SLEPC=ON
8890
-DBOUT_USE_SUNDIALS=ON
91+
-DBOUT_USE_HYPRE=ON
8992
-DSUNDIALS_ROOT=/home/runner/local"
9093
on_cron: false
9194

@@ -97,6 +100,7 @@ jobs:
97100
-DBOUT_USE_PETSC=ON
98101
-DBOUT_USE_SLEPC=ON
99102
-DBOUT_USE_SUNDIALS=ON
103+
-DBOUT_USE_HYPRE=ON
100104
-DBOUT_BUILD_DOCS=OFF
101105
-DSUNDIALS_ROOT=/home/runner/local"
102106
omp_num_threads: 2
@@ -110,6 +114,7 @@ jobs:
110114
-DBOUT_USE_PETSC=ON
111115
-DBOUT_USE_SLEPC=ON
112116
-DBOUT_USE_SUNDIALS=ON
117+
-DBOUT_USE_HYPRE=OFF
113118
-DBOUT_ENABLE_PYTHON=ON
114119
-DSUNDIALS_ROOT=/home/runner/local"
115120
omp_num_threads: 2
@@ -123,32 +128,15 @@ jobs:
123128
-DBOUT_USE_PETSC=ON
124129
-DBOUT_USE_SLEPC=ON
125130
-DBOUT_USE_SUNDIALS=ON
131+
-DBOUT_USE_HYPRE=OFF
126132
-DBOUT_ENABLE_PYTHON=ON
127133
-DSUNDIALS_ROOT=/home/runner/local
128134
-DPETSC_DIR=/home/runner/local/petsc
129135
-DSLEPC_DIR=/home/runner/local/slepc"
130136
build_petsc: -petsc
131137
on_cron: false
132138

133-
- name: "Coverage"
134-
os: ubuntu-latest
135-
cmake_options: "-DBUILD_SHARED_LIBS=ON
136-
-DCMAKE_BUILD_TYPE=Debug
137-
-DCHECK=3
138-
-DENABLE_COVERAGE=ON
139-
-DBOUT_USE_PETSC=ON
140-
-DBOUT_USE_SLEPC=ON
141-
-DBOUT_USE_HDF5=ON
142-
-DBOUT_USE_SUNDIALS=ON
143-
-DBOUT_ENABLE_PYTHON=ON
144-
-DSUNDIALS_ROOT=/home/runner/local"
145-
unit_only: YES
146-
on_cron: false
147139
exclude:
148-
# Don't run the coverage tests if the branch isn't master or next
149-
- is_master_or_next: false
150-
config:
151-
name: "Coverage"
152140
- is_cron: true
153141
config:
154142
on_cron: false
@@ -178,6 +166,7 @@ jobs:
178166
slepc-dev
179167
liblapack-dev
180168
libparpack2-dev
169+
libhypre-dev
181170

182171
- uses: actions/checkout@v4
183172
with:
@@ -210,22 +199,6 @@ jobs:
210199
- name: Build BOUT++
211200
run: UNIT_ONLY=${{ matrix.config.unit_only }} ./.ci_with_cmake.sh ${{ matrix.config.cmake_options }}
212201

213-
- name: Capture coverage
214-
if: ${{ matrix.config.name == 'Coverage' }}
215-
# Explicitly run the coverage capture target, because
216-
# ci_script.sh also does the upload, and we're going to do
217-
# that ourselves in the next step
218-
run: |
219-
# Ensure that there is a corresponding .gcda file for every .gcno file
220-
# This is to try and make the coverage report slightly more accurate
221-
# It still won't include, e.g. any solvers we don't build with though
222-
find . -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
223-
make -C build code-coverage-capture
224-
225-
- name: Upload coverage
226-
if: ${{ matrix.config.name == 'Coverage' }}
227-
uses: codecov/codecov-action@v4
228-
229202
Fedora:
230203
# This is its own job as it doesn't use most of the steps of the
231204
# standard_tests

bout++Config.cmake.in

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ elseif(EXISTS "@NCXX4_CONFIG@")
9191
set(NCXX4_CONFIG "@NCXX4_CONFIG@")
9292
elseif(EXISTS "@NCXX_BINARY_DIR@")
9393
# If we downloaded netCDF-cxx4, then we need to add its build directory to our search paths
94-
list(APPEND CMAKE_PREFIX_PATH "@NCXX_BINARY_DIR@")
94+
list(APPEND CMAKE_PREFIX_PATH "@NCXX_BINARY_DIR@")
9595
endif()
9696
if(EXISTS "@PVODE_ROOT@")
9797
set(PVODE_ROOT "@PVODE_ROOT@")
@@ -103,6 +103,12 @@ endif()
103103
if(EXISTS "@Libuuid_ROOT@")
104104
set(Libuuid_ROOT "@Libuuid_ROOT@")
105105
endif()
106+
if(EXISTS "@ADIOS2_ROOT@")
107+
set(ADIOS2_ROOT "@ADIOS2_ROOT@")
108+
elseif(EXISTS "@ADIOS2_BINARY_DIR@")
109+
# If we downloaded ADIOS2, then we need to add its build directory to our search paths
110+
list(APPEND CMAKE_PREFIX_PATH "@ADIOS2_BINARY_DIR@")
111+
endif()
106112

107113
if(@BOUT_USE_SYSTEM_MPARK_VARIANT@)
108114
set(mpark_variant_ROOT "@mpark_variant_ROOT@")
@@ -117,6 +123,11 @@ endif()
117123

118124
set(MPIEXEC_EXECUTABLE @MPIEXEC_EXECUTABLE@)
119125
find_dependency(MPI @MPI_CXX_VERSION@ EXACT)
126+
if (BOUT_HAS_ADIOS2 OR BOUT_HAS_HYPRE OR BOUT_HAS_SUNDIALS)
127+
# These libraries may also require MPI_C
128+
enable_language(C)
129+
find_dependency(MPI COMPONENTS C)
130+
endif()
120131

121132
if (BOUT_USE_OPENMP)
122133
find_dependency(OpenMP)
@@ -158,5 +169,8 @@ endif()
158169
if (BOUT_USE_UUID_SYSTEM_GENERATOR)
159170
find_dependency(Libuuid)
160171
endif()
172+
if (BOUT_HAS_ADIOS2)
173+
find_dependency(ADIOS2 @ADIOS2_VERSION@ EXACT)
174+
endif()
161175

162176
include("${CMAKE_CURRENT_LIST_DIR}/bout++Targets.cmake")

cmake/FindHYPRE.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ include(FindPackageHandleStandardArgs)
77

88
find_package(HYPRE CONFIG QUIET)
99
if (HYPRE_FOUND)
10+
message(STATUS "Found HYPRE: ${HYPRE_VERSION}")
1011
return()
1112
endif()
1213

1314
find_path(HYPRE_INCLUDE_DIR
1415
NAMES HYPRE.h
1516
DOC "HYPRE include directories"
1617
REQUIRED
17-
PATH_SUFFIXES include
18+
PATH_SUFFIXES include include/hypre
1819
)
1920

2021
find_library(HYPRE_LIBRARY

cmake/SetupBOUTThirdParty.cmake

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,12 @@ endif()
190190
message(STATUS "NetCDF support: ${BOUT_USE_NETCDF}")
191191
set(BOUT_HAS_NETCDF ${BOUT_USE_NETCDF})
192192

193-
option(BOUT_USE_ADIOS2 "Enable support for ADIOS output" ON)
193+
option(BOUT_USE_ADIOS2 "Enable support for ADIOS output" OFF)
194194
option(BOUT_DOWNLOAD_ADIOS2 "Download and build ADIOS2" OFF)
195195
if (BOUT_USE_ADIOS2)
196+
enable_language(C)
197+
find_package(MPI REQUIRED COMPONENTS C)
198+
196199
if (BOUT_DOWNLOAD_ADIOS2)
197200
message(STATUS "Downloading and configuring ADIOS2")
198201
include(FetchContent)
@@ -211,18 +214,11 @@ if (BOUT_USE_ADIOS2)
211214
# Note: SST requires <rdma/fabric.h> but doesn't check at configure time
212215
set(ADIOS2_USE_SST OFF CACHE BOOL "" FORCE)
213216
FetchContent_MakeAvailable(adios2)
214-
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi)
215217
message(STATUS "ADIOS2 done configuring")
216218
else()
217-
find_package(ADIOS2)
218-
if (ADIOS2_FOUND)
219-
ENABLE_LANGUAGE(C)
220-
find_package(MPI REQUIRED COMPONENTS C)
221-
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi MPI::MPI_C)
222-
else()
223-
set(BOUT_USE_ADIOS2 OFF)
224-
endif()
219+
find_package(ADIOS2 REQUIRED)
225220
endif()
221+
target_link_libraries(bout++ PUBLIC adios2::cxx11_mpi MPI::MPI_C)
226222
endif()
227223
message(STATUS "ADIOS2 support: ${BOUT_USE_ADIOS2}")
228224
set(BOUT_HAS_ADIOS2 ${BOUT_USE_ADIOS2})

examples/elm-pb/data-hypre/BOUT.inp

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
wall_limit = 1.55 # wall time limit (in hours)
2-
31
zperiod = 15 # Fraction of a torus to simulate
42
MZ = 16 # Number of points in Z
53

6-
dump_format = "nc" # Dump file format. "nc" = NetCDF, "pdb" = PDB
7-
restart_format = "nc" # Restart file format
8-
94
[mesh]
10-
115
staggergrids = false # Use staggered grids
126

137
file = "cbm18_dens8.grid_nx68ny64.nc" # Grid file
148

159
[mesh:paralleltransform]
16-
17-
type = shifted # Use shifted metric method
10+
type = shiftedinterp
1811

1912
##################################################
2013
# derivative methods
2114

2215
[mesh:ddx]
23-
2416
first = C4 # order of first x derivatives
2517
second = C4 # order of second x derivatives
2618
upwind = W3 # order of upwinding method W3 = Weno3
@@ -36,20 +28,6 @@ first = C4 # Z derivatives can be done using FFT
3628
second = C4
3729
upwind = W3
3830

39-
[output]
40-
shiftoutput = true # Put the output into field-aligned coordinates
41-
42-
##################################################
43-
# Laplacian inversion routines
44-
45-
[laplace]
46-
type = hypre3d
47-
48-
flags = 0 # Flags for Laplacian inversion
49-
50-
rtol = 1e-09
51-
atol = 1e-14
52-
5331
##################################################
5432
# FFTs
5533

@@ -63,23 +41,12 @@ fft_measurement_flag = measure # If using FFTW, perform tests to determine fast
6341
[solver]
6442

6543
# mudq, mldq, mukeep, mlkeep preconditioner options
66-
atol = 1e-08 # absolute tolerance
67-
rtol = 1e-05 # relative tolerance
44+
atol = 1.0e-8 # absolute tolerance
45+
rtol = 1.0e-5 # relative tolerance
6846

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

7249
mxstep = 5000 # Number of internal steps between outputs
73-
adams_moulton = false # Use Adams-Moulton method (default is BDF)
74-
func_iter = false # Functional iteration (default is Newton)
75-
output_step = 1 # time between outputs
76-
# settings file for BOUT++
77-
# High-Beta reduced MHD case
78-
79-
##################################################
80-
# Global settings used by the core code
81-
82-
nout = 40 # number of time-steps
8350

8451
##################################################
8552
# settings for high-beta reduced MHD
@@ -116,7 +83,7 @@ diamag_phi0 = true # Balance ExB against Vd for stationary equilibrium
11683
bm_exb_flag = 0
11784
bm_mag_flag = 0
11885
##################################################################
119-
withflow = false # With flow or not
86+
withflow = false # With flow or not
12087
D_0 = 1.3e5 # differential potential
12188
D_s = 20 # shear parameter
12289
K_H_term = false # Contain K-H term
@@ -125,8 +92,8 @@ x0 = 0.855 # peak location
12592
D_min = 3000 # constant
12693
##################################################################
12794

128-
eHall = false # Include electron pressue effects in Ohm's law?
129-
AA = 2.0 # ion mass in units of proton mass
95+
eHall = false # Include electron pressure effects in Ohm's law?
96+
AA = 2.0 # ion mass in units of proton mass
13097

13198
noshear = false # zero all shear
13299

@@ -174,14 +141,14 @@ damp_t_const = 0.01 # Damping time constant
174141

175142
## Parallel pressure diffusion
176143

177-
diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
144+
diffusion_par = -1.0 # Parallel pressure diffusion (< 0 = none)
178145
diffusion_p4 = -1e-05 # parallel hyper-viscous diffusion for pressure (< 0 = none)
179-
diffusion_u4 = 1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
146+
diffusion_u4 = -1e-05 # parallel hyper-viscous diffusion for vorticity (< 0 = none)
180147
diffusion_a4 = -1e-05 # parallel hyper-viscous diffusion for vector potential (< 0 = none)
181148

182149
## heat source in pressure in watts
183150

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

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

207174
viscos_par = -0.1 # Parallel viscosity (< 0 = none)
208-
viscos_perp = -1.0 # Perpendicular
175+
viscos_perp = -1.0 # Perpendicular viscosity (< 0 = none)
209176
hyperviscos = -1.0 # Radial hyper viscosity
210177

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

215182
[phiSolver]
216-
#inner_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
217-
#outer_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
218-
inner_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
219-
outer_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
183+
type = hypre3d
184+
inner_boundary_flags = 0 # Dirichlet
185+
outer_boundary_flags = 0 # Dirichlet
220186

221187
[aparSolver]
222-
#inner_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
223-
#outer_boundary_flags = 1 + 2 + 128 # INVERT_DC_GRAD + INVERT_AC_GRAD + INVERT_BNDRY_ONE
224188
inner_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
225189
outer_boundary_flags = 1 + 4 # INVERT_DC_GRAD + INVERT_AC_LAP
226190

@@ -271,12 +235,9 @@ bndry_ydown = free_o3
271235
# Zero gradient in the core
272236
bndry_core = neumann
273237

274-
[Vpar]
275-
276-
bndry_core = neumann
277-
278238
[phi]
279239

280240
bndry_xin = none
281241
bndry_xout = none
282-
bndry_target = neumann
242+
#bndry_target = neumann
243+

examples/elm-pb/data/BOUT.inp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ diamag_phi0 = true # Balance ExB against Vd for stationary equilibrium
9494
bm_exb_flag = 0
9595
bm_mag_flag = 0
9696
##################################################################
97-
withflow = false # With flow or not
97+
withflow = false # With flow or not
9898
D_0 = 1.3e5 # differential potential
9999
D_s = 20 # shear parameter
100100
K_H_term = false # Contain K-H term
@@ -104,7 +104,7 @@ D_min = 3000 # constant
104104
##################################################################
105105

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

109109
noshear = false # zero all shear
110110

@@ -152,14 +152,14 @@ damp_t_const = 0.01 # Damping time constant
152152

153153
## Parallel pressure diffusion
154154

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

160160
## heat source in pressure in watts
161161

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

0 commit comments

Comments
 (0)