-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
474 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
if (AMReX_SPACEDIM EQUAL 1) | ||
return() | ||
endif () | ||
|
||
# List of source files | ||
set(_sources main.cpp myfunc.H) | ||
list(TRANSFORM _sources PREPEND "Source/") | ||
|
||
# List of input files | ||
file( GLOB_RECURSE _input_files LIST_DIRECTORIES false Exec/input* ) | ||
|
||
setup_tutorial(_sources _input_files) | ||
|
||
unset( _sources ) | ||
unset( _input_files ) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# AMREX_HOME defines the directory in which we will find all the AMReX code. | ||
AMREX_HOME ?= ../../../../../amrex | ||
|
||
DEBUG = FALSE | ||
USE_MPI = TRUE | ||
USE_OMP = FALSE | ||
COMP = gnu | ||
DIM = 3 | ||
USE_RPATH = TRUE | ||
USE_SUNDIALS = TRUE | ||
|
||
include $(AMREX_HOME)/Tools/GNUMake/Make.defs | ||
|
||
include ../Source/Make.package | ||
VPATH_LOCATIONS += ../Source | ||
INCLUDE_LOCATIONS += ../Source | ||
|
||
ifeq ($(USE_SUNDIALS),TRUE) | ||
ifeq ($(USE_CUDA),TRUE) | ||
SUNDIALS_ROOT ?= $(TOP)../../../../../sundials/instdir_cuda | ||
else | ||
SUNDIALS_ROOT ?= $(TOP)../../../../../sundials/instdir | ||
endif | ||
ifeq ($(NERSC_HOST),perlmutter) | ||
SUNDIALS_LIB_DIR ?= $(SUNDIALS_ROOT)/lib64 | ||
else | ||
SUNDIALS_LIB_DIR ?= $(SUNDIALS_ROOT)/lib | ||
endif | ||
|
||
USE_CVODE_LIBS ?= TRUE | ||
USE_ARKODE_LIBS ?= TRUE | ||
|
||
DEFINES += -DAMREX_USE_SUNDIALS | ||
INCLUDE_LOCATIONS += $(SUNDIALS_ROOT)/include | ||
LIBRARY_LOCATIONS += $(SUNDIALS_LIB_DIR) | ||
|
||
LIBRARIES += -L$(SUNDIALS_LIB_DIR) -lsundials_cvode | ||
LIBRARIES += -L$(SUNDIALS_LIB_DIR) -lsundials_arkode | ||
LIBRARIES += -L$(SUNDIALS_LIB_DIR) -lsundials_nvecmanyvector | ||
LIBRARIES += -L$(SUNDIALS_LIB_DIR) -lsundials_core | ||
|
||
ifeq ($(USE_CUDA),TRUE) | ||
LIBRARIES += -L$(SUNDIALS_LIB_DIR) -lsundials_nveccuda | ||
endif | ||
|
||
endif | ||
|
||
include $(AMREX_HOME)/Src/Base/Make.package | ||
|
||
include $(AMREX_HOME)/Tools/GNUMake/Make.rules | ||
|
85 changes: 85 additions & 0 deletions
85
ExampleCodes/SUNDIALS/Reaction-Diffusion/Exec/README_sundials
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
SUNDIALS installation guide: | ||
https://computing.llnl.gov/projects/sundials/faq#inst | ||
|
||
Installation | ||
|
||
# Download sundials-x.y.z.tar.gz file for SUNDIALS and extract it at the same level as amrex. | ||
# Update 6/11/24 - v7.0.0. tested | ||
https://computing.llnl.gov/projects/sundials/sundials-software | ||
|
||
>> tar -xzvf sundials-x.y.z.tar.gz # where x.y.z is the version of sundials | ||
|
||
# at the same level that amrex is cloned, do: | ||
|
||
>> mkdir sundials | ||
>> cd sundials | ||
|
||
###################### | ||
HOST BUILD | ||
###################### | ||
|
||
>> mkdir instdir | ||
>> mkdir builddir | ||
>> cd builddir | ||
|
||
>> cmake -DCMAKE_INSTALL_PREFIX=/pathto/sundials/instdir -DEXAMPLES_INSTALL_PATH=/pathto/sundials/instdir/examples -DENABLE_MPI=ON ../../sundials-x.y.z | ||
|
||
###################### | ||
NVIDIA/CUDA BUILD | ||
###################### | ||
|
||
# Navigate back to the 'sundials' directory and do: | ||
|
||
>> mkdir instdir_cuda | ||
>> mkdir builddir_cuda | ||
>> cd builddir_cuda | ||
|
||
>> cmake -DCMAKE_INSTALL_PREFIX=/pathto/sundials/instdir_cuda -DEXAMPLES_INSTALL_PATH=/pathto/sundials/instdir_cuda/examples -DENABLE_CUDA=ON -DENABLE_MPI=ON ../../sundials-x.y.z | ||
|
||
###################### | ||
|
||
>> make -j4 | ||
>> make install | ||
|
||
# in your .bashrc or preferred configuration file, add the following (and then "source ~/.bashrc") | ||
|
||
# If you have a CPU build: | ||
|
||
>> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pathto/sundials/instdir/lib/ | ||
|
||
# If you have a NVIDIA/CUDA build: | ||
|
||
>> export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/pathto/sundials/instdir_cuda/lib/ | ||
|
||
# now you are ready to compile amrex-tutorials/ExampleCodes/SUNDIALS/Exec with: | ||
|
||
>> make -j4 # optional to have 'USE_CUDA=TRUE' as well | ||
|
||
# in your inputs file, you will need to have: | ||
|
||
# INTEGRATION | ||
## integration.type can take on the following values: | ||
## 0 or "ForwardEuler" => Native AMReX Forward Euler integrator | ||
## 1 or "RungeKutta" => Native AMReX Explicit Runge Kutta controlled by integration.rk.type | ||
## 2 or "SUNDIALS" => SUNDIALS backend controlled by integration.sundials.strategy | ||
integration.type = <pick a value> | ||
|
||
## Native AMReX Explicit Runge-Kutta parameters | ||
# | ||
## integration.rk.type can take the following values: | ||
### 0 = User-specified Butcher Tableau | ||
### 1 = Forward Euler | ||
### 2 = Trapezoid Method | ||
### 3 = SSPRK3 Method | ||
### 4 = RK4 Method | ||
integration.rk.type = 3 | ||
|
||
## If using the SUNDIALS Submodule, then | ||
## compile with USE_SUNDIALS=TRUE or AMReX_SUNDIALS=ON and | ||
## set strategy here: | ||
# | ||
## integration.sundials.strategy can take the following values: | ||
### ERK = ERKStep from ARKode with SSPRK3 Method | ||
### MRI = MRIStep from ARKode with Explict Trapezoid Method | ||
### MRITEST = MRIStep from ARKode modified to use no-op inner f0 | ||
integration.sundials.strategy = ERK |
14 changes: 14 additions & 0 deletions
14
ExampleCodes/SUNDIALS/Reaction-Diffusion/Exec/inputs_forward_euler
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
n_cell = 32 | ||
max_grid_size = 16 | ||
|
||
nsteps = 1000 | ||
plot_int = 100 | ||
|
||
dt = 1.e-5 | ||
|
||
# INTEGRATION | ||
## integration.type can take on the following values: | ||
## 0 or "ForwardEuler" => Native AMReX Forward Euler integrator | ||
## 1 or "RungeKutta" => Native AMReX Explicit Runge Kutta controlled by integration.rk.type | ||
## 2 or "SUNDIALS" => SUNDIALS backend controlled by integration.sundials.strategy | ||
integration.type = ForwardEuler |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
n_cell = 32 | ||
max_grid_size = 16 | ||
|
||
nsteps = 1000 | ||
plot_int = 100 | ||
|
||
dt = 1.e-5 | ||
|
||
# INTEGRATION | ||
## integration.type can take on the following values: | ||
## 0 or "ForwardEuler" => Native AMReX Forward Euler integrator | ||
## 1 or "RungeKutta" => Native AMReX Explicit Runge Kutta controlled by integration.rk.type | ||
## 2 or "SUNDIALS" => SUNDIALS backend controlled by integration.sundials.strategy | ||
integration.type = RungeKutta | ||
|
||
## Native AMReX Explicit Runge-Kutta parameters | ||
# | ||
## integration.rk.type can take the following values: | ||
### 0 = User-specified Butcher Tableau | ||
### 1 = Forward Euler | ||
### 2 = Trapezoid Method | ||
### 3 = SSPRK3 Method | ||
### 4 = RK4 Method | ||
integration.rk.type = 3 |
44 changes: 44 additions & 0 deletions
44
ExampleCodes/SUNDIALS/Reaction-Diffusion/Exec/inputs_sundials
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
n_cell = 32 | ||
max_grid_size = 16 | ||
|
||
nsteps = 1000 | ||
plot_int = 100 | ||
|
||
dt = 1.e-5 | ||
|
||
# Use adaptive time stepping and set integrator relative and absolute tolerances | ||
# adapt_dt = true | ||
# reltol = 1.0e-4 | ||
# abstol = 1.0e-9 | ||
|
||
# INTEGRATION | ||
# integration.type can take on the following values: | ||
# 0 or "ForwardEuler" => Native AMReX Forward Euler integrator | ||
# 1 or "RungeKutta" => Native AMReX Explicit Runge Kutta controlled by integration.rk.type | ||
# 2 or "SUNDIALS" => SUNDIALS backend controlled by integration.sundials.type | ||
# | ||
# If using the SUNDIALS Submodule, then compile with USE_SUNDIALS=TRUE or | ||
# AMReX_SUNDIALS=ON | ||
integration.type = SUNDIALS | ||
|
||
# Set the SUNDIALS method type: | ||
# ERK = Explicit Runge-Kutta method | ||
# DIRK = Diagonally Implicit Runge-Kutta method | ||
# IMEX-RK = Implicit-Explicit Additive Runge-Kutta method | ||
# EX-MRI = Explicit Multirate Infatesimal method | ||
# IM-MRI = Implicit Multirate Infatesimal method | ||
# IMEX-MRI = Implicit-Explicit Multirate Infatesimal method | ||
# | ||
# Optionally select a specific SUNDIALS method by name, see the SUNDIALS | ||
# documentation for the supported method names | ||
|
||
# Use the SUNDIALS default method for the chosen type (fixed or adaptive step sizes) | ||
integration.sundials.type = ERK | ||
|
||
# Use forward Euler (fixed step sizes only) | ||
# integration.sundials.type = ERK | ||
# integration.sundials.method = ARKODE_FORWARD_EULER_1_1 | ||
|
||
# Use backward Euler (fixed step sizes only) | ||
# integration.sundials.type = DIRK | ||
# integration.sundials.method = ARKODE_BACKWARD_EULER_1_1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CEXE_sources += main.cpp | ||
CEXE_headers += myfunc.H |
Oops, something went wrong.