Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 16 additions & 11 deletions Docs/source/SUNDIALS_Tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
SUNDIALS and Time Integrators
=============================

This example code shows how to use the AMReX TimeIntegrator class
with SUNDIALS backend for integration. It also include two example
of AMReX native integrators, Forward Euler, and Explicit Runge Kutta.
Each integration type can be chosen by selecting the corresponding
inputs file:
These example codes demonstrate how to use the AMReX TimeIntegrator class
with SUNDIALS backend for integration.

- ``inputs_forward_euler`` -- Native AMReX Forward Euler integrator
The first example code at ``amrex-tutorials/ExampleCodes/SUNDIALS/Single-Rate``
solves the heat equation:

- ``inputs_rk3`` -- Native AMReX Explicit Runge Kutta
.. math:: \frac{\partial\phi}{\partial t} = \nabla^2\phi.

- ``inputs_sundials_erk`` -- SUNDIALS backend
The inputs file contains a template for single process time integration strategies.

Both Runge Kutta and SUNDIALS have additional options which can
be set by modifying the inputs file. Please see each respective inputs
file or `AMReX User Guide:Time Integration`_ for more details.
The second example code at ``amrex-tutorials/ExampleCodes/SUNDIALS/Reaction-Diffusion``
solves the reaction-diffusion equation, where :math:`R` and :math:`D` are
user-supplied reaction and diffusion coefficients:

.. math:: \frac{\partial\phi}{\partial t} = D \nabla^2\phi - R \phi.

The inputs file contains a template for MRI approaches, where the diffusion process
can be treated as a "fast" partition relative to the reaction process.
Please see each respective inputs file or
`AMReX User Guide:Time Integration`_ for more details.

.. _`AMReX User Guide:Time Integration`: https://amrex-codes.github.io/amrex/docs_html/TimeIntegration_Chapter.html#
1 change: 1 addition & 0 deletions ExampleCodes/SUNDIALS/Reaction-Diffusion/Exec/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ USE_OMP = FALSE
COMP = gnu
DIM = 3
USE_SUNDIALS = TRUE
SUNDIALS_HOME ?= ../../../../../sundials/instdir

include $(AMREX_HOME)/Tools/GNUMake/Make.defs

Expand Down
66 changes: 3 additions & 63 deletions ExampleCodes/SUNDIALS/Reaction-Diffusion/Exec/README_sundials
Original file line number Diff line number Diff line change
@@ -1,64 +1,4 @@
SUNDIALS installation guide:
https://computing.llnl.gov/projects/sundials/faq#inst
Refer to https://amrex-codes.github.io/amrex/docs_html/TimeIntegration_Chapter.html
for SNUDIALS installation, build, and usage instructions.

Installation

# You need SUNDIALS v7.1.1 or later.
# Check https://computing.llnl.gov/projects/sundials/sundials-software to see if it's available for download.
# If so, download sundials-x.y.z.tar.gz and extract it at the same level as amrex using
>> tar -xzvf sundials-x.y.z.tar.gz # where x.y.z is the version of sundials
>> mv sundials-x.y.z sundials-src

# If v7.1.1. is not available on the website, clone the git repo directly and use the latest version
# At the same level that amrex is cloned, do:

>> git clone https://github.com/LLNL/sundials.git
>> mv sundials sundials-src

# Next

>> 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-src

######################
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-src

######################

>> 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

# Refer to inputs to see how to enable different integrators
Make sure that SUNDIALS_HOME in the GNUmakefile points to the installation directory.
1 change: 1 addition & 0 deletions ExampleCodes/SUNDIALS/Single-Rate/Exec/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ USE_OMP = FALSE
COMP = gnu
DIM = 3
USE_SUNDIALS = TRUE
SUNDIALS_HOME ?= ../../../../../sundials/instdir

include $(AMREX_HOME)/Tools/GNUMake/Make.defs

Expand Down
66 changes: 3 additions & 63 deletions ExampleCodes/SUNDIALS/Single-Rate/Exec/README_sundials
Original file line number Diff line number Diff line change
@@ -1,64 +1,4 @@
SUNDIALS installation guide:
https://computing.llnl.gov/projects/sundials/faq#inst
Refer to https://amrex-codes.github.io/amrex/docs_html/TimeIntegration_Chapter.html
for SNUDIALS installation, build, and usage instructions.

Installation

# You need SUNDIALS v7.1.1 or later.
# Check https://computing.llnl.gov/projects/sundials/sundials-software to see if it's available for download.
# If so, download sundials-x.y.z.tar.gz and extract it at the same level as amrex using
>> tar -xzvf sundials-x.y.z.tar.gz # where x.y.z is the version of sundials
>> mv sundials-x.y.z sundials-src

# If v7.1.1. is not available on the website, clone the git repo directly and use the latest version
# At the same level that amrex is cloned, do:

>> git clone https://github.com/LLNL/sundials.git
>> mv sundials sundials-src

# Next

>> 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-src

######################
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-src

######################

>> 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

# Refer to inputs to see how to enable different integrators
Make sure that SUNDIALS_HOME in the GNUmakefile points to the installation directory.
Loading